From b1a42929a57590c05dc455082a10b05b9563d649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Wed, 27 Mar 2013 00:23:47 +0100 Subject: [PATCH] Make listing categories and filtering work --- src/shell/widgetexplorer/widgetexplorer.cpp | 18 ++++++++++++- .../widgetexplorer/widgetexplorerview.cpp | 27 ++++++------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/shell/widgetexplorer/widgetexplorer.cpp b/src/shell/widgetexplorer/widgetexplorer.cpp index 9a5e9c81f..dd40076c1 100644 --- a/src/shell/widgetexplorer/widgetexplorer.cpp +++ b/src/shell/widgetexplorer/widgetexplorer.cpp @@ -114,12 +114,28 @@ void WidgetExplorerPrivate::initFilters() QMap categories; QSet existingCategories = itemModel.categories(); //foreach (const QString &category, Plasma::Applet::listCategories(application)) { + QStringList cats; + KService::List services = KServiceTypeTrader::self()->query("Plasma/Applet", QString()); + + foreach (const KSharedPtr service, services) { + KPluginInfo info(service); + if (info.property("NoDisplay").toBool() || info.category() == i18n("Containments") || + info.category().isEmpty()) { + // we don't want to show the hidden category + continue; + } + const QString c = info.category(); + if (-1 == cats.indexOf(c)) { + cats << c; + } + } qWarning() << "TODO: port listCategories()"; - foreach (const QString &category, QStringList("FIXME")) { + foreach (const QString &category, cats) { const QString lowerCaseCat = category.toLower(); if (existingCategories.contains(lowerCaseCat)) { const QString trans = i18n(category.toLocal8Bit()); categories.insert(trans.toLower(), qMakePair(trans, lowerCaseCat)); + qDebug() << "Categories: << " << lowerCaseCat; } } diff --git a/src/shell/widgetexplorer/widgetexplorerview.cpp b/src/shell/widgetexplorer/widgetexplorerview.cpp index 5fd6a48c3..6c64e772c 100644 --- a/src/shell/widgetexplorer/widgetexplorerview.cpp +++ b/src/shell/widgetexplorer/widgetexplorerview.cpp @@ -55,21 +55,21 @@ WidgetExplorerView::~WidgetExplorerView() void WidgetExplorerView::init() { - setTitle(i18n("Add Widgets")); - setColor(Qt::transparent); + qDebug() << "Loading WidgetExplorer: " << m_qmlPath; m_widgetExplorer = new WidgetExplorer(this); m_widgetExplorer->populateWidgetList(); - rootContext()->setContextProperty("widgetExplorer", m_widgetExplorer); - connect(m_widgetExplorer, &WidgetExplorer::closeClicked, this, &QQuickView::close); + m_widgetExplorer->setContainment(m_containment); -// QString expqml = package().filePath("widgetexplorer"); - qDebug() << "Script to load for WidgetExplorer: " << m_qmlPath; + rootContext()->setContextProperty("widgetExplorer", m_widgetExplorer); + setTitle(i18n("Add Widgets")); + setColor(Qt::transparent); + setResizeMode(QQuickView::SizeRootObjectToView); setSource(QUrl::fromLocalFile(m_qmlPath)); + + connect(m_widgetExplorer, &WidgetExplorer::closeClicked, this, &QQuickView::close); connect(this, &QQuickView::statusChanged, this, &WidgetExplorerView::widgetExplorerStatusChanged); connect(this, &QQuickView::visibleChanged, this, &WidgetExplorerView::widgetExplorerClosed); - setResizeMode(QQuickView::SizeRootObjectToView); - m_widgetExplorer->setContainment(m_containment); } @@ -77,17 +77,6 @@ void WidgetExplorerView::setContainment(Plasma::Containment* c) { m_containment = c; m_widgetExplorer->setContainment(c); - -// QObject *graphicObject = m_containment->property("graphicObject").value(); -// -// if (graphicObject) { -// qDebug() << "using as graphic containment" << graphicObject << m_containment; -// -// rootObject()->setProperty("parent", QVariant::fromValue(graphicObject)); -// //rootObject()->setProperty("containment", QVariant::fromValue(graphicObject)); -// } else { -// qWarning() << "Containment graphic object not valid"; -// } }