Make listing categories and filtering work
This commit is contained in:
parent
498dcb30b6
commit
b1a42929a5
@ -114,12 +114,28 @@ void WidgetExplorerPrivate::initFilters()
|
|||||||
QMap<QString, catPair > categories;
|
QMap<QString, catPair > categories;
|
||||||
QSet<QString> existingCategories = itemModel.categories();
|
QSet<QString> existingCategories = itemModel.categories();
|
||||||
//foreach (const QString &category, Plasma::Applet::listCategories(application)) {
|
//foreach (const QString &category, Plasma::Applet::listCategories(application)) {
|
||||||
|
QStringList cats;
|
||||||
|
KService::List services = KServiceTypeTrader::self()->query("Plasma/Applet", QString());
|
||||||
|
|
||||||
|
foreach (const KSharedPtr<KService> 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()";
|
qWarning() << "TODO: port listCategories()";
|
||||||
foreach (const QString &category, QStringList("FIXME")) {
|
foreach (const QString &category, cats) {
|
||||||
const QString lowerCaseCat = category.toLower();
|
const QString lowerCaseCat = category.toLower();
|
||||||
if (existingCategories.contains(lowerCaseCat)) {
|
if (existingCategories.contains(lowerCaseCat)) {
|
||||||
const QString trans = i18n(category.toLocal8Bit());
|
const QString trans = i18n(category.toLocal8Bit());
|
||||||
categories.insert(trans.toLower(), qMakePair(trans, lowerCaseCat));
|
categories.insert(trans.toLower(), qMakePair(trans, lowerCaseCat));
|
||||||
|
qDebug() << "Categories: << " << lowerCaseCat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,21 +55,21 @@ WidgetExplorerView::~WidgetExplorerView()
|
|||||||
|
|
||||||
void WidgetExplorerView::init()
|
void WidgetExplorerView::init()
|
||||||
{
|
{
|
||||||
setTitle(i18n("Add Widgets"));
|
qDebug() << "Loading WidgetExplorer: " << m_qmlPath;
|
||||||
setColor(Qt::transparent);
|
|
||||||
|
|
||||||
m_widgetExplorer = new WidgetExplorer(this);
|
m_widgetExplorer = new WidgetExplorer(this);
|
||||||
m_widgetExplorer->populateWidgetList();
|
m_widgetExplorer->populateWidgetList();
|
||||||
rootContext()->setContextProperty("widgetExplorer", m_widgetExplorer);
|
m_widgetExplorer->setContainment(m_containment);
|
||||||
connect(m_widgetExplorer, &WidgetExplorer::closeClicked, this, &QQuickView::close);
|
|
||||||
|
|
||||||
// QString expqml = package().filePath("widgetexplorer");
|
rootContext()->setContextProperty("widgetExplorer", m_widgetExplorer);
|
||||||
qDebug() << "Script to load for WidgetExplorer: " << m_qmlPath;
|
setTitle(i18n("Add Widgets"));
|
||||||
|
setColor(Qt::transparent);
|
||||||
|
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||||
setSource(QUrl::fromLocalFile(m_qmlPath));
|
setSource(QUrl::fromLocalFile(m_qmlPath));
|
||||||
|
|
||||||
|
connect(m_widgetExplorer, &WidgetExplorer::closeClicked, this, &QQuickView::close);
|
||||||
connect(this, &QQuickView::statusChanged, this, &WidgetExplorerView::widgetExplorerStatusChanged);
|
connect(this, &QQuickView::statusChanged, this, &WidgetExplorerView::widgetExplorerStatusChanged);
|
||||||
connect(this, &QQuickView::visibleChanged, this, &WidgetExplorerView::widgetExplorerClosed);
|
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_containment = c;
|
||||||
m_widgetExplorer->setContainment(c);
|
m_widgetExplorer->setContainment(c);
|
||||||
|
|
||||||
// QObject *graphicObject = m_containment->property("graphicObject").value<QObject *>();
|
|
||||||
//
|
|
||||||
// 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";
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user