don't show categories with no visible items in them

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=738621
This commit is contained in:
Aaron J. Seigo 2007-11-19 09:46:52 +00:00
parent 07e9e1d3e3
commit 71b89ebb5f
2 changed files with 9 additions and 3 deletions

View File

@ -1022,7 +1022,7 @@ KPluginInfo::List Applet::knownAppletsForMimetype(const QString &mimetype)
return KPluginInfo::fromServices(offers); return KPluginInfo::fromServices(offers);
} }
QStringList Applet::knownCategories(const QString &parentApp) QStringList Applet::knownCategories(const QString &parentApp, bool visibleOnly)
{ {
QString constraint = "exist [X-KDE-PluginInfo-Category]"; QString constraint = "exist [X-KDE-PluginInfo-Category]";
@ -1034,8 +1034,13 @@ QStringList Applet::knownCategories(const QString &parentApp)
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
QStringList categories; QStringList categories;
foreach (KService::Ptr applet, offers) { foreach (const KService::Ptr applet, offers) {
QString appletCategory = applet->property("X-KDE-PluginInfo-Category").toString(); QString appletCategory = applet->property("X-KDE-PluginInfo-Category").toString();
if (visibleOnly && applet->property("NoDisplay").toBool()) {
// we don't want to show the hidden category
continue;
}
//kDebug() << " and we have " << appletCategory; //kDebug() << " and we have " << appletCategory;
if (appletCategory.isEmpty()) { if (appletCategory.isEmpty()) {
if (!categories.contains(i18n("Miscellaneous"))) { if (!categories.contains(i18n("Miscellaneous"))) {

View File

@ -270,8 +270,9 @@ class PLASMA_EXPORT Applet : public Widget
* list containing only applets not specifically * list containing only applets not specifically
* registered to an application. * registered to an application.
* @return list of categories * @return list of categories
* @param visibleOnly true if it should only return applets that are marked as visible
*/ */
static QStringList knownCategories(const QString &parentApp = QString()); static QStringList knownCategories(const QString &parentApp = QString(), bool visibleOnly = true);
/** /**
* @return true if this plasmoid provides a GUI configuration * @return true if this plasmoid provides a GUI configuration