Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/backends/KNSBackend/KNSBackend.cpp
Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | 99 | { | |||
---|---|---|---|---|---|
139 | const QVector<QPair<FilterType, QString>> filters = { {CategoryFilter, fileName } }; | 139 | const QVector<QPair<FilterType, QString>> filters = { {CategoryFilter, fileName } }; | ||
140 | const QSet<QString> backendName = { name() }; | 140 | const QSet<QString> backendName = { name() }; | ||
141 | m_displayName = group.readEntry("Name", QString()); | 141 | m_displayName = group.readEntry("Name", QString()); | ||
142 | if (m_displayName.isEmpty()) { | 142 | if (m_displayName.isEmpty()) { | ||
143 | m_displayName = fileName.mid(0, fileName.indexOf(QLatin1Char('.'))); | 143 | m_displayName = fileName.mid(0, fileName.indexOf(QLatin1Char('.'))); | ||
144 | m_displayName[0] = m_displayName[0].toUpper(); | 144 | m_displayName[0] = m_displayName[0].toUpper(); | ||
145 | } | 145 | } | ||
146 | 146 | | |||
147 | const QStringList cats = group.readEntry<QStringList>("Categories", QStringList{}); | ||||
148 | QVector<Category*> categories; | ||||
149 | if (cats.count() > 1) { | ||||
150 | QHash<QString, QVector<Category*> > subCategories; | ||||
151 | m_categories += cats; | ||||
152 | for(const auto &cat: cats) | ||||
153 | categories << new Category(cat, {}, { {CategoryFilter, cat } }, backendName, {}, {}, true); | ||||
154 | } | ||||
147 | static const QString knsrcApplications = QLatin1String("storekdeapps.knsrc"); | 155 | static const QString knsrcApplications = QLatin1String("storekdeapps.knsrc"); | ||
148 | 156 | | |||
149 | if(knsrcApplications == fileName) { | 157 | if(knsrcApplications == fileName) { | ||
150 | m_hasApplications = true; | 158 | m_hasApplications = true; | ||
151 | auto actualCategory = new Category(m_displayName, QStringLiteral("plasma"), filters, backendName, {}, QUrl(), false); | 159 | auto actualCategory = new Category(m_displayName, QStringLiteral("plasma"), filters, backendName, categories, QUrl(), false); | ||
152 | auto applicationCategory = new Category(i18n("Applications"), QStringLiteral("plasma"), filters, backendName, { actualCategory }, QUrl(), false); | 160 | auto applicationCategory = new Category(i18n("Applications"), QStringLiteral("plasma"), filters, backendName, { actualCategory }, QUrl(), false); | ||
153 | m_categories.append(applicationCategory->name()); | 161 | m_categories.append(applicationCategory->name()); | ||
154 | m_rootCategories = { applicationCategory }; | 162 | m_rootCategories = { applicationCategory }; | ||
155 | // Make sure we filter out any apps which won't run on the current system architecture | 163 | // Make sure we filter out any apps which won't run on the current system architecture | ||
156 | QStringList tagFilter = m_engine->tagFilter(); | 164 | QStringList tagFilter = m_engine->tagFilter(); | ||
157 | if(QSysInfo::currentCpuArchitecture() == QLatin1String("arm")) { | 165 | if(QSysInfo::currentCpuArchitecture() == QLatin1String("arm")) { | ||
158 | tagFilter << QLatin1String("application##architecture=armhf"); | 166 | tagFilter << QLatin1String("application##architecture=armhf"); | ||
159 | } else if(QSysInfo::currentCpuArchitecture() == QLatin1String("arm64")) { | 167 | } else if(QSysInfo::currentCpuArchitecture() == QLatin1String("arm64")) { | ||
Show All 13 Lines | 179 | static const QSet<QString> knsrcPlasma = { | |||
173 | QStringLiteral("wallpaper.knsrc"), QStringLiteral("xcursor.knsrc"), | 181 | QStringLiteral("wallpaper.knsrc"), QStringLiteral("xcursor.knsrc"), | ||
174 | 182 | | |||
175 | QStringLiteral("cgcgtk3.knsrc"), QStringLiteral("cgcicon.knsrc"), QStringLiteral("cgctheme.knsrc"), //GTK integration | 183 | QStringLiteral("cgcgtk3.knsrc"), QStringLiteral("cgcicon.knsrc"), QStringLiteral("cgctheme.knsrc"), //GTK integration | ||
176 | QStringLiteral("kwinswitcher.knsrc"), QStringLiteral("kwineffect.knsrc"), QStringLiteral("kwinscripts.knsrc"), //KWin | 184 | QStringLiteral("kwinswitcher.knsrc"), QStringLiteral("kwineffect.knsrc"), QStringLiteral("kwinscripts.knsrc"), //KWin | ||
177 | QStringLiteral("comic.knsrc"), QStringLiteral("colorschemes.knsrc"), | 185 | QStringLiteral("comic.knsrc"), QStringLiteral("colorschemes.knsrc"), | ||
178 | QStringLiteral("emoticons.knsrc"), QStringLiteral("plymouth.knsrc"), | 186 | QStringLiteral("emoticons.knsrc"), QStringLiteral("plymouth.knsrc"), | ||
179 | QStringLiteral("sddmtheme.knsrc"), QStringLiteral("wallpaperplugin.knsrc") | 187 | QStringLiteral("sddmtheme.knsrc"), QStringLiteral("wallpaperplugin.knsrc") | ||
180 | }; | 188 | }; | ||
181 | auto actualCategory = new Category(m_displayName, QStringLiteral("plasma"), filters, backendName, {}, QUrl(), true); | 189 | auto actualCategory = new Category(m_displayName, QStringLiteral("plasma"), filters, backendName, categories, QUrl(), true); | ||
182 | 190 | | |||
183 | const auto topLevelName = knsrcPlasma.contains(fileName)? i18n("Plasma Addons") : i18n("Application Addons"); | 191 | const auto topLevelName = knsrcPlasma.contains(fileName)? i18n("Plasma Addons") : i18n("Application Addons"); | ||
184 | auto addonsCategory = new Category(topLevelName, QStringLiteral("plasma"), filters, backendName, {actualCategory}, QUrl(), true); | 192 | auto addonsCategory = new Category(topLevelName, QStringLiteral("plasma"), filters, backendName, {actualCategory}, QUrl(), true); | ||
185 | m_rootCategories = { addonsCategory }; | 193 | m_rootCategories = { addonsCategory }; | ||
186 | } | 194 | } | ||
leinir: Don't think we need this, already creating the categories as Category instances just below, and… | |||||
187 | } | 195 | } | ||
188 | 196 | | |||
189 | KNSBackend::~KNSBackend() | 197 | KNSBackend::~KNSBackend() | ||
190 | { | 198 | { | ||
191 | qDeleteAll(m_rootCategories); | 199 | qDeleteAll(m_rootCategories); | ||
192 | } | 200 | } | ||
193 | 201 | | |||
194 | void KNSBackend::markInvalid(const QString &message) | 202 | void KNSBackend::markInvalid(const QString &message) | ||
Show All 38 Lines | |||||
233 | { | 241 | { | ||
234 | return m_isValid; | 242 | return m_isValid; | ||
235 | } | 243 | } | ||
236 | 244 | | |||
237 | KNSResource* KNSBackend::resourceForEntry(const KNSCore::EntryInternal& entry) | 245 | KNSResource* KNSBackend::resourceForEntry(const KNSCore::EntryInternal& entry) | ||
238 | { | 246 | { | ||
239 | KNSResource* r = static_cast<KNSResource*>(m_resourcesByName.value(entry.uniqueId())); | 247 | KNSResource* r = static_cast<KNSResource*>(m_resourcesByName.value(entry.uniqueId())); | ||
240 | if (!r) { | 248 | if (!r) { | ||
241 | r = new KNSResource(entry, m_categories, this); | 249 | r = new KNSResource(entry, m_categories + QStringList{entry.category()}, this); | ||
242 | m_resourcesByName.insert(entry.uniqueId(), r); | 250 | m_resourcesByName.insert(entry.uniqueId(), r); | ||
243 | } else { | 251 | } else { | ||
244 | r->setEntry(entry); | 252 | r->setEntry(entry); | ||
245 | } | 253 | } | ||
246 | return r; | 254 | return r; | ||
247 | } | 255 | } | ||
248 | 256 | | |||
249 | void KNSBackend::receivedEntries(const KNSCore::EntryInternal::List& entries) | 257 | void KNSBackend::receivedEntries(const KNSCore::EntryInternal::List& entries) | ||
▲ Show 20 Lines • Show All 306 Lines • Show Last 20 Lines |
Don't think we need this, already creating the categories as Category instances just below, and we set the category on the Resource instance when we create that in ::resourceForEntry... With it we'd end up duplicating those categories in the list of categories for all resources, from what i can tell this line just isn't needed :)