make it possible to exclude categories from the appletbrowser

svn path=/trunk/KDE/kdelibs/; revision=925892
This commit is contained in:
Chani Armitage 2009-02-14 13:28:25 +00:00
parent fc49f3c20e
commit 499fd451b4

View File

@ -1650,11 +1650,16 @@ KPluginInfo::List Applet::listAppletInfo(const QString &category,
} else {
constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
}
//note: constraint guaranteed non-empty from here down
if (!category.isEmpty()) {
if (!constraint.isEmpty()) {
constraint.append(" and ");
if (category.isEmpty()) { //use all but the excluded categories
KConfigGroup group(KGlobal::config(), "General");
QStringList excluded = group.readEntry("ExcludeCategories", QStringList());
foreach (const QString &category, excluded) {
constraint.append(" and [X-KDE-PluginInfo-Category] != '").append(category).append("'");
}
} else { //specific category (this could be an excluded one - is that bad?)
constraint.append(" and ");
constraint.append("[X-KDE-PluginInfo-Category] == '").append(category).append("'");
if (category == "Miscellaneous") {
@ -1686,6 +1691,12 @@ QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly)
constraint.append(" and [X-KDE-ParentApp] == '").append(parentApp).append("'");
}
KConfigGroup group(KGlobal::config(), "General");
QStringList excluded = group.readEntry("ExcludeCategories", QStringList());
foreach (const QString &category, excluded) {
constraint.append(" and [X-KDE-PluginInfo-Category] != '").append(category).append("'");
}
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
QStringList categories;
foreach (const KService::Ptr &applet, offers) {