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

View File

@ -245,7 +245,7 @@ class PLASMA_EXPORT Applet : public QObject, public Widget
* assigned automatically. * assigned automatically.
* @return a pointer to the loaded applet, or 0 on load failure * @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()); const QStringList& args = QStringList());
/** /**
@ -276,7 +276,7 @@ class PLASMA_EXPORT Applet : public QObject, public Widget
* *
* @param a KPluginInfo object for the applet * @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 * Get the category of the given applet