Commit 3dfd7cbc authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

kns: Show subcategories for things that have one

Summary: Show subcategories for KNS resources that have more than 1 Category inside. At the moment it just is Wallpapers.

Reviewers: #discover_software_store, leinir

Reviewed By: leinir

Subscribers: leinir, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D19826
parent ffc6023c
......@@ -144,11 +144,19 @@ KNSBackend::KNSBackend(QObject* parent, const QString& iconName, const QString &
m_displayName[0] = m_displayName[0].toUpper();
}
const QStringList cats = group.readEntry<QStringList>("Categories", QStringList{});
QVector<Category*> categories;
if (cats.count() > 1) {
QHash<QString, QVector<Category*> > subCategories;
m_categories += cats;
for(const auto &cat: cats)
categories << new Category(cat, {}, { {CategoryFilter, cat } }, backendName, {}, {}, true);
}
static const QString knsrcApplications = QLatin1String("storekdeapps.knsrc");
if(knsrcApplications == fileName) {
m_hasApplications = true;
auto actualCategory = new Category(m_displayName, QStringLiteral("plasma"), filters, backendName, {}, QUrl(), false);
auto actualCategory = new Category(m_displayName, QStringLiteral("plasma"), filters, backendName, categories, QUrl(), false);
auto applicationCategory = new Category(i18n("Applications"), QStringLiteral("plasma"), filters, backendName, { actualCategory }, QUrl(), false);
m_categories.append(applicationCategory->name());
m_rootCategories = { applicationCategory };
......@@ -178,7 +186,7 @@ KNSBackend::KNSBackend(QObject* parent, const QString& iconName, const QString &
QStringLiteral("emoticons.knsrc"), QStringLiteral("plymouth.knsrc"),
QStringLiteral("sddmtheme.knsrc"), QStringLiteral("wallpaperplugin.knsrc")
};
auto actualCategory = new Category(m_displayName, QStringLiteral("plasma"), filters, backendName, {}, QUrl(), true);
auto actualCategory = new Category(m_displayName, QStringLiteral("plasma"), filters, backendName, categories, QUrl(), true);
const auto topLevelName = knsrcPlasma.contains(fileName)? i18n("Plasma Addons") : i18n("Application Addons");
auto addonsCategory = new Category(topLevelName, QStringLiteral("plasma"), filters, backendName, {actualCategory}, QUrl(), true);
......@@ -238,7 +246,7 @@ KNSResource* KNSBackend::resourceForEntry(const KNSCore::EntryInternal& entry)
{
KNSResource* r = static_cast<KNSResource*>(m_resourcesByName.value(entry.uniqueId()));
if (!r) {
r = new KNSResource(entry, m_categories, this);
r = new KNSResource(entry, m_categories + QStringList{entry.category()}, this);
m_resourcesByName.insert(entry.uniqueId(), r);
} else {
r->setEntry(entry);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment