diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index cd52d91fc..b1064c741 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -483,72 +483,6 @@ int Containment::screen() const return d->screen; } -KPluginInfo::List Containment::listContainments(const QString &category, - const QString &parentApp) -{ - return listContainmentsOfType(QString(), category, parentApp); -} - - -KPluginInfo::List Containment::listContainmentsOfType(const QString &type, - const QString &category, - const QString &parentApp) -{ - QString constraint; - - if (parentApp.isEmpty()) { - constraint.append("(not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '')"); - } else { - constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'"); - } - - if (!type.isEmpty()) { - if (!constraint.isEmpty()) { - constraint.append(" and "); - } - - constraint.append("'").append(type).append("' ~in [X-Plasma-ContainmentCategories]"); - } - - if (!category.isEmpty()) { - if (!constraint.isEmpty()) { - constraint.append(" and "); - } - - constraint.append("[X-KDE-PluginInfo-Category] == '").append(category).append("'"); - if (category == "Miscellaneous") { - constraint.append(" or (not exist [X-KDE-PluginInfo-Category] or [X-KDE-PluginInfo-Category] == '')"); - } - } - - KService::List offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint); - //kDebug() << "constraint was" << constraint << "which got us" << offers.count() << "matches"; - return KPluginInfo::fromServices(offers); -} - -KPluginInfo::List Containment::listContainmentsForMimeType(const QString &mimeType) -{ - const QString constraint = QString("'%1' in [X-Plasma-DropMimeTypes]").arg(mimeType); - //kDebug() << mimeType << constraint; - const KService::List offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint); - return KPluginInfo::fromServices(offers); -} - -QStringList Containment::listContainmentTypes() -{ - KPluginInfo::List containmentInfos = listContainments(); - QSet types; - - foreach (const KPluginInfo &containmentInfo, containmentInfos) { - QStringList theseTypes = containmentInfo.service()->property("X-Plasma-ContainmentCategories").toStringList(); - foreach (const QString &type, theseTypes) { - types.insert(type); - } - } - - return types.toList(); -} - void Containment::enableAction(const QString &name, bool enable) { QAction *action = this->action(name); diff --git a/src/plasma/containment.h b/src/plasma/containment.h index 36b043484..893045be9 100644 --- a/src/plasma/containment.h +++ b/src/plasma/containment.h @@ -127,60 +127,6 @@ class PLASMA_EXPORT Containment : public Applet */ Corona *corona() const; - /** - * Returns a list of all known containments. - * - * @param category Only containments matching this category will be returned. - * Useful in conjunction with knownCategories. - * If "Miscellaneous" is passed in, then applets without a - * Categories= entry are also returned. - * If an empty string is passed in, all applets are - * returned. - * @param parentApp the application to filter applets on. Uses the - * X-KDE-ParentApp entry (if any) in the plugin info. - * The default value of QString() will result in a - * list containing only applets not specifically - * registered to an application. - * @return list of applets - **/ - static KPluginInfo::List listContainments(const QString &category = QString(), - const QString &parentApp = QString()); - - /** - * Returns a list of all known Containments that match the parameters. - * - * @param type Only Containments with this string in X-Plasma-ContainmentCategories - * in their .desktop files will be returned. Common values are panel and - * desktop - * @param category Only applets matchin this category will be returned. - * Useful in conjunction with knownCategories. - * If "Miscellaneous" is passed in, then applets without a - * Categories= entry are also returned. - * If an empty string is passed in, all applets are - * returned. - * @param parentApp the application to filter applets on. Uses the - * X-KDE-ParentApp entry (if any) in the plugin info. - * The default value of QString() will result in a - * list containing only applets not specifically - * registered to an application. - * @return list of applets - **/ - static KPluginInfo::List listContainmentsOfType(const QString &type, - const QString &category = QString(), - const QString &parentApp = QString()); - - /** - * @return a list of all known types of Containments on this system - */ - static QStringList listContainmentTypes(); - - /** - * Returns a list of all known applets associated with a certain MimeType - * - * @return list of applets - **/ - static KPluginInfo::List listContainmentsForMimeType(const QString &mimeType); - /** * Adds an applet to this Containment * diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index cc0a29c84..d4e9d8a5e 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -576,6 +576,72 @@ QString PluginLoader::appletCategory(const QString& appletName) return offers.first()->property("X-KDE-PluginInfo-Category").toString(); } +KPluginInfo::List PluginLoader::listContainments(const QString &category, + const QString &parentApp) +{ + return listContainmentsOfType(QString(), category, parentApp); +} + + +KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type, + const QString &category, + const QString &parentApp) +{ + QString constraint; + + if (parentApp.isEmpty()) { + constraint.append("(not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '')"); + } else { + constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'"); + } + + if (!type.isEmpty()) { + if (!constraint.isEmpty()) { + constraint.append(" and "); + } + + constraint.append("'").append(type).append("' ~in [X-Plasma-ContainmentCategories]"); + } + + if (!category.isEmpty()) { + if (!constraint.isEmpty()) { + constraint.append(" and "); + } + + constraint.append("[X-KDE-PluginInfo-Category] == '").append(category).append("'"); + if (category == "Miscellaneous") { + constraint.append(" or (not exist [X-KDE-PluginInfo-Category] or [X-KDE-PluginInfo-Category] == '')"); + } + } + + KService::List offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint); + //kDebug() << "constraint was" << constraint << "which got us" << offers.count() << "matches"; + return KPluginInfo::fromServices(offers); +} + +KPluginInfo::List PluginLoader::listContainmentsForMimeType(const QString &mimeType) +{ + const QString constraint = QString("'%1' in [X-Plasma-DropMimeTypes]").arg(mimeType); + //kDebug() << mimeType << constraint; + const KService::List offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint); + return KPluginInfo::fromServices(offers); +} + +QStringList PluginLoader::listContainmentTypes() +{ + KPluginInfo::List containmentInfos = listContainments(); + QSet types; + + foreach (const KPluginInfo &containmentInfo, containmentInfos) { + QStringList theseTypes = containmentInfo.service()->property("X-Plasma-ContainmentCategories").toStringList(); + foreach (const QString &type, theseTypes) { + types.insert(type); + } + } + + return types.toList(); +} + KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp) { diff --git a/src/plasma/pluginloader.h b/src/plasma/pluginloader.h index 7b1e07e36..e17867c8d 100644 --- a/src/plasma/pluginloader.h +++ b/src/plasma/pluginloader.h @@ -185,6 +185,60 @@ public: */ QString appletCategory(const QString &appletName); + /** + * Returns a list of all known containments. + * + * @param category Only containments matching this category will be returned. + * Useful in conjunction with knownCategories. + * If "Miscellaneous" is passed in, then applets without a + * Categories= entry are also returned. + * If an empty string is passed in, all applets are + * returned. + * @param parentApp the application to filter applets on. Uses the + * X-KDE-ParentApp entry (if any) in the plugin info. + * The default value of QString() will result in a + * list containing only applets not specifically + * registered to an application. + * @return list of applets + **/ + static KPluginInfo::List listContainments(const QString &category = QString(), + const QString &parentApp = QString()); + + /** + * Returns a list of all known Containments that match the parameters. + * + * @param type Only Containments with this string in X-Plasma-ContainmentCategories + * in their .desktop files will be returned. Common values are panel and + * desktop + * @param category Only applets matchin this category will be returned. + * Useful in conjunction with knownCategories. + * If "Miscellaneous" is passed in, then applets without a + * Categories= entry are also returned. + * If an empty string is passed in, all applets are + * returned. + * @param parentApp the application to filter applets on. Uses the + * X-KDE-ParentApp entry (if any) in the plugin info. + * The default value of QString() will result in a + * list containing only applets not specifically + * registered to an application. + * @return list of applets + **/ + static KPluginInfo::List listContainmentsOfType(const QString &type, + const QString &category = QString(), + const QString &parentApp = QString()); + + /** + * @return a list of all known types of Containments on this system + */ + static QStringList listContainmentTypes(); + + /** + * Returns a list of all known applets associated with a certain MimeType + * + * @return list of applets + **/ + static KPluginInfo::List listContainmentsForMimeType(const QString &mimeType); + /** * Returns a list of all known DataEngines. *