port to value based KPluginInfo

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=691115
This commit is contained in:
Matthias Kretz 2007-07-22 23:10:53 +00:00
parent bef5a33ed5
commit 1fd776be2e
2 changed files with 22 additions and 23 deletions

View File

@ -52,7 +52,7 @@ public:
: appletId(uniqueID),
globalConfig(0),
appletConfig(0),
appletDescription(service ? new KPluginInfo(service) : 0),
appletDescription(service),
package(0),
background(0),
failureText(0),
@ -68,14 +68,14 @@ public:
s_maxAppletId = appletId;
}
if (appletDescription &&
!appletDescription->property("X-Plasma-Language").toString().isEmpty()) {
if (appletDescription.isValid() &&
!appletDescription.property("X-Plasma-Language").toString().isEmpty()) {
QString path = KStandardDirs::locate("appdata",
"plasmoids/" +
appletDescription->pluginName());
appletDescription.pluginName());
if (!path.isEmpty()) {
package = new Package(path,
appletDescription->pluginName(),
appletDescription.pluginName(),
PlasmoidStructure());
if (!package->isValid()) {
delete package;
@ -90,14 +90,13 @@ public:
foreach ( const QString& engine, loadedEngines ) {
DataEngineManager::self()->unloadDataEngine( engine );
}
delete appletDescription;
delete background;
delete package;
}
void init(Applet* applet)
{
if (!appletDescription) {
if (!appletDescription.isValid()) {
applet->setFailedToLaunch(true);
}
@ -117,7 +116,7 @@ public:
uint appletId;
KSharedConfig::Ptr globalConfig;
KSharedConfig::Ptr appletConfig;
KPluginInfo* appletDescription;
KPluginInfo appletDescription;
Package* package;
QList<QObject*> watchedForFocus;
QStringList loadedEngines;
@ -214,25 +213,25 @@ void Applet::constraintsUpdated()
QString Applet::name() const
{
if (!d->appletDescription) {
if (!d->appletDescription.isValid()) {
return i18n("Unknown Applet");
}
return d->appletDescription->name();
return d->appletDescription.name();
}
QString Applet::category() const
{
if (!d->appletDescription) {
if (!d->appletDescription.isValid()) {
return i18n("Misc");
}
return d->appletDescription->property("X-KDE-PluginInfo-Category").toString();
return d->appletDescription.property("X-KDE-PluginInfo-Category").toString();
}
QString Applet::category(const KPluginInfo* applet)
QString Applet::category(const KPluginInfo& applet)
{
return applet->property("X-KDE-PluginInfo-Category").toString();
return applet.property("X-KDE-PluginInfo-Category").toString();
}
QString Applet::category(const QString& appletName)
@ -385,20 +384,20 @@ Location Applet::location() const
QString Applet::globalName() const
{
if (!d->appletDescription) {
if (!d->appletDescription.isValid()) {
return QString();
}
return d->appletDescription->service()->library();
return d->appletDescription.service()->library();
}
QString Applet::instanceName() const
{
if (!d->appletDescription) {
if (!d->appletDescription.isValid()) {
return QString();
}
return d->appletDescription->service()->library() + QString::number( d->appletId );
return d->appletDescription.service()->library() + QString::number( d->appletId );
}
void Applet::watchForFocus(QObject *widget, bool watch)
@ -545,13 +544,13 @@ Applet* Applet::loadApplet(const QString& appletName, uint appletId, const QStri
return applet;
}
Applet* Applet::loadApplet(const KPluginInfo* info, uint appletId, const QStringList& args)
Applet* Applet::loadApplet(const KPluginInfo& info, uint appletId, const QStringList& args)
{
if (!info) {
if (!info.isValid()) {
return 0;
}
return loadApplet(info->pluginName(), appletId, args);
return loadApplet(info.pluginName(), appletId, args);
}
} // Plasma namespace

View File

@ -245,7 +245,7 @@ class PLASMA_EXPORT Applet : public QObject, public Widget
* assigned automatically.
* @return a pointer to the loaded applet, or 0 on load failure
**/
static Applet* loadApplet(const KPluginInfo* info, uint appletId = 0,
static Applet* loadApplet(const KPluginInfo& info, uint appletId = 0,
const QStringList& args = QStringList());
/**
@ -276,7 +276,7 @@ class PLASMA_EXPORT Applet : public QObject, public Widget
*
* @param a KPluginInfo object for the applet
*/
static QString category(const KPluginInfo* applet);
static QString category(const KPluginInfo& applet);
/**
* Get the category of the given applet