won't be using these anymore

svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=492423
This commit is contained in:
Aaron J. Seigo 2005-12-29 22:10:34 +00:00
parent b645137010
commit 468bc137a9
2 changed files with 0 additions and 440 deletions

View File

@ -1,249 +0,0 @@
/*****************************************************************
Copyright (c) 2000-2001 Matthias Elter <elter@kde.org>
Copyright (c) 2001 John Firebaugh <jfirebaugh@kde.org>
Copyright (c) 2001-2005 Aaron Seigo <aseigo@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
******************************************************************/
#include <QtCore/QBuffer>
#include <QtCore/QFileInfo>
#include <QtCore/QMimeData>
#include <QtCore/QDataStream>
#include <kdesktopfile.h>
#include <kapplication.h>
#include <krandom.h>
#include "appletinfo.h"
namespace Plasma
{
class AppletInfo::Private
{
public:
Private()
: unique(false),
hidden(false)
{}
QString name;
QString comment;
QString icon;
QString lib;
QString languageBindings;
QString desktopFile;
QString desktopFilePath;
bool unique;
bool hidden;
};
AppletInfo::AppletInfo(const QString& desktopFile)
{
d = new Private;
QFileInfo fi(desktopFile);
d->desktopFilePath = fi.absoluteFilePath();
d->desktopFile = fi.fileName();
KDesktopFile df(desktopFile, true);
// set the appletssimple attributes
setName(df.readName());
setComment(df.readComment());
setIcon(df.readIcon());
// library
setLibrary(df.readEntry("X-KDE-Library"));
// language the applet is written in
setLanguageBindings(df.readEntry("X-KDE-LanguageBindings", "native").toLower());
// is it a unique applet?
setUnique(df.readBoolEntry("X-KDE-UniqueApplet", false));
// should it be shown in the gui?
d->hidden = df.readBoolEntry("Hidden", false);
}
AppletInfo::AppletInfo(const AppletInfo &copy)
{
d = new Private;
*d = *copy.d;
}
AppletInfo::~AppletInfo()
{
delete d;
}
AppletInfo& AppletInfo::operator=(const AppletInfo &rhs)
{
*d = *rhs.d;
return *this;
}
QString AppletInfo::name() const
{
return d->name;
}
QString AppletInfo::comment() const
{
return d->comment;
}
QString AppletInfo::icon() const
{
return d->icon;
}
QString AppletInfo::library() const
{
return d->lib;
}
QString AppletInfo::languageBindings() const
{
return d->languageBindings;
}
QString AppletInfo::desktopFilePath() const
{
return d->desktopFilePath;
}
QString AppletInfo::desktopFile() const
{
return d->desktopFile;
}
QString AppletInfo::generateConfigFileName() const
{
// generate a config file base name from the library name
QString configFile = "plasmaApplet_" + d->lib.toLower();
if (d->unique)
{
configFile.append("rc");
}
else
{
configFile.append("_")
.append(KRandom::randomString(20).toLower())
.append("_rc");
}
return configFile;
}
bool AppletInfo::unique() const
{
return d->unique;
}
bool AppletInfo::hidden() const
{
return d->hidden;
}
void AppletInfo::setName(const QString &name)
{
d->name = name;
}
void AppletInfo::setComment(const QString &comment)
{
d->comment = comment;
}
void AppletInfo::setIcon(const QString &icon)
{
d->icon = icon;
}
void AppletInfo::setLibrary(const QString &lib)
{
d->lib = lib;
}
void AppletInfo::setLanguageBindings(const QString &language)
{
d->languageBindings = language;
}
void AppletInfo::setUnique(bool u)
{
d->unique = u;
}
bool AppletInfo::operator!=(const AppletInfo& rhs) const
{
return library() != rhs.library();
}
bool AppletInfo::operator==(const AppletInfo& rhs) const
{
return library() == rhs.library();
}
bool AppletInfo::operator<(const AppletInfo& rhs) const
{
return name().toLower() < rhs.name().toLower();
}
bool AppletInfo::operator>(const AppletInfo& rhs) const
{
return name().toLower() > rhs.name().toLower();
}
bool AppletInfo::operator<=(const AppletInfo& rhs) const
{
return name().toLower() <= rhs.name().toLower();
}
void AppletInfo::populateMimeData(QMimeData* mimeData)
{
QByteArray a;
QDataStream s(&a, QIODevice::WriteOnly);
s << desktopFilePath();
mimeData->setData("application/plasmaAppletInfo", a);
}
bool AppletInfo::canDecode(const QMimeData* mimeData)
{
return mimeData->hasFormat("application/plasmaAppletInfo");
}
AppletInfo AppletInfo::fromMimeData(const QMimeData* mimeData)
{
QByteArray a = mimeData->data("application/plasmaAppletInfo");
if (a.isEmpty())
{
return AppletInfo();
}
QBuffer buff(&a);
buff.open(QIODevice::ReadOnly);
QDataStream s(&buff);
QString desktopFile;
s >> desktopFile;
AppletInfo info(desktopFile);
return info;
}
} // Plasma namespace

View File

@ -1,191 +0,0 @@
/*****************************************************************
Copyright (c) 2000-2001 Matthias Elter <elter@kde.org>
Copyright (c) 2001 John Firebaugh <jfirebaugh@kde.org>
Copyright (c) 2001-2005 Aaron Seigo <aseigo@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
******************************************************************/
#ifndef appletinfo_h_
#define appletinfo_h_
#include <QList>
#include <QVector>
#include <kdemacros.h>
namespace Plasma
{
class KDE_EXPORT AppletInfo
{
public:
typedef QList<AppletInfo> List;
typedef QMap<QObject*, AppletInfo*> Dict;
/**
* AppletInfo constructor
* Each AppletInfo describes a specific applet
* @arg desktopFile the name of the desktop file describing this applet
*/
AppletInfo(const QString& desktopFile = QString::null);
/**
* Destructor
*/
virtual ~AppletInfo();
/**
* Copy constructor
*/
AppletInfo(const AppletInfo& copy);
/**
* Returns the name of the applet, suitable for use in user interfaces.
*/
QString name() const;
/**
* Returns a descriptive comment for the applet, suitable for use in
* user interfaces.
*/
QString comment() const;
/**
* Returns the type of the applet, allowing one to distinguish between
* applets, buttons
*/
QString icon() const;
/**
* Returns the name of the library containing the applet
*/
QString library() const;
/**
* Returns the language this applet is written in. "native" means it is
* a compiled plugin that can be loaded via dlopen. anything else is
* taken to be the name of the language (and therefore the bindings)
* required for this applet, e.g. "javascript"
*/
QString languageBindings() const;
/**
* Returns the full path to the desktop file being used for this applet
*/
QString desktopFilePath() const;
/**
* Returns the name of the desktop file that describes this applet
*/
QString desktopFile() const;
/**
* Returns a configuration file name that can be used for an instance
* of this applet. If it is a unique applet, this will return the same
* name each time, otherwise each time this is called the name may be
* different.
*/
QString generateConfigFileName() const;
/**
* Some applets only allow for one instance of the applet to be
* instantiated at a time. This method returns true if this is the case
* for this applet.
*/
bool unique() const;
/**
* Not all applets are meant to be visible to the user, though they may
* be available for use by the application internally. This method
* returns true if this is the case for this applet.
*/
bool hidden() const;
/**
* Assignment operator
*/
AppletInfo &operator=(const AppletInfo& rhs);
/**
* Less than operator, for sorting by name in lists
*/
bool operator<(const AppletInfo& rhs) const;
/**
* Greater than operator, for sorting by name in lists
*/
bool operator>(const AppletInfo& rhs) const;
/**
* Less than or equals to operator, for sorting by name in lists
*/
bool operator<=(const AppletInfo& rhs) const;
/**
* Inequality operator. Compares the library used by each.
*/
bool operator!=(const AppletInfo& rhs) const;
/**
* Less than operator. Compares the library used by each.
*/
bool operator==(const AppletInfo& rhs) const;
/**
* Part of the drag and drop support for AppletInfo.
* Populates a QMimeData object with the necessary data to create an
* equivalent AppletInfo object on the receiving end.
* @param mimeData a pointer to a QMimeData object. Any Applet Info
* previously added to this object will be overwritten.
*/
void populateMimeData(QMimeData* mimeData);
/**
* Part of the drag and drop support for AppletInfo.
* Returns true if the QMimeData object passed in contains the proper
* mimetype for an AppletInfo
* @param mimeData a pointer to a QMimeData object which may contain
* AppletInfo data
*/
static bool canDecode(const QMimeData* mimeData);
/**
* Part of the drag and drop support for AppletInfo.
* Given a QMimeData object that contains an AppletInfo, returns a
* corresponding AppletInfo object
* @param mimeData a pointer to a QMimeData object which should contain
* AppletInfo data.
* @see canDecode
*/
static AppletInfo fromMimeData(const QMimeData* mimeData);
private:
void setName(const QString& name);
void setComment(const QString& comment);
void setIcon(const QString& icon);
void setLibrary(const QString& lib);
void setLanguageBindings(const QString& language);
void setUnique(bool u);
class Private;
Private *d;
};
} // Plasma namespace
#endif