move in PluginLoader metadata-related methods
listContainments listContainmentsOfType listContainmentTypes listContainmentsForMimeType
This commit is contained in:
parent
2686bed090
commit
444d49709b
@ -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<QString> 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);
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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<QString> 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)
|
||||
{
|
||||
|
@ -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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user