From 71b89ebb5f03698acca0c86b2cd9402a3856c8a9 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 19 Nov 2007 09:46:52 +0000 Subject: [PATCH] don't show categories with no visible items in them svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=738621 --- applet.cpp | 9 +++++++-- applet.h | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/applet.cpp b/applet.cpp index 67c7020c7..e4bbef8d4 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1022,7 +1022,7 @@ KPluginInfo::List Applet::knownAppletsForMimetype(const QString &mimetype) 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]"; @@ -1034,8 +1034,13 @@ QStringList Applet::knownCategories(const QString &parentApp) KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); QStringList categories; - foreach (KService::Ptr applet, offers) { + foreach (const KService::Ptr applet, offers) { 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; if (appletCategory.isEmpty()) { if (!categories.contains(i18n("Miscellaneous"))) { diff --git a/applet.h b/applet.h index 71ff8f35d..74bced14e 100644 --- a/applet.h +++ b/applet.h @@ -270,8 +270,9 @@ class PLASMA_EXPORT Applet : public Widget * list containing only applets not specifically * registered to an application. * @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