Changeset View
Changeset View
Standalone View
Standalone View
components/shellprivate/widgetexplorer/widgetexplorer.cpp
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Line(s) | 147 | if (info.property(QStringLiteral("NoDisplay")).toBool() || info.category() == QLatin1String("Containments") || | |||
---|---|---|---|---|---|
150 | continue; | 150 | continue; | ||
151 | } | 151 | } | ||
152 | const QString c = info.category(); | 152 | const QString c = info.category(); | ||
153 | if (-1 == cats.indexOf(c)) { | 153 | if (-1 == cats.indexOf(c)) { | ||
154 | cats << c; | 154 | cats << c; | ||
155 | } | 155 | } | ||
156 | } | 156 | } | ||
157 | qWarning() << "TODO: port listCategories()"; | 157 | qWarning() << "TODO: port listCategories()"; | ||
158 | foreach (const QString &category, cats) { | 158 | for (const QString &category : qAsConst(cats)) { | ||
159 | const QString lowerCaseCat = category.toLower(); | 159 | const QString lowerCaseCat = category.toLower(); | ||
160 | if (existingCategories.contains(lowerCaseCat)) { | 160 | if (existingCategories.contains(lowerCaseCat)) { | ||
161 | const QString trans = i18nd("libplasma5", category.toLocal8Bit()); | 161 | const QString trans = i18nd("libplasma5", category.toLocal8Bit()); | ||
162 | categories.insert(trans.toLower(), qMakePair(trans, lowerCaseCat)); | 162 | categories.insert(trans.toLower(), qMakePair(trans, lowerCaseCat)); | ||
163 | } | 163 | } | ||
164 | } | 164 | } | ||
165 | 165 | | |||
166 | foreach (const catPair &category, categories) { | 166 | for (const catPair &category : qAsConst(categories)) { | ||
167 | filterModel.addFilter(category.first, | 167 | filterModel.addFilter(category.first, | ||
168 | KCategorizedItemsViewModels::Filter(QStringLiteral("category"), category.second)); | 168 | KCategorizedItemsViewModels::Filter(QStringLiteral("category"), category.second)); | ||
169 | } | 169 | } | ||
170 | 170 | | |||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | void WidgetExplorer::classBegin() | 173 | void WidgetExplorer::classBegin() | ||
174 | { | 174 | { | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 244 | { | |||
273 | itemModel.setRunningApplets(runningApplets); | 273 | itemModel.setRunningApplets(runningApplets); | ||
274 | } | 274 | } | ||
275 | 275 | | |||
276 | void WidgetExplorerPrivate::addContainment(Containment *containment) | 276 | void WidgetExplorerPrivate::addContainment(Containment *containment) | ||
277 | { | 277 | { | ||
278 | QObject::connect(containment, SIGNAL(appletAdded(Plasma::Applet*)), q, SLOT(appletAdded(Plasma::Applet*))); | 278 | QObject::connect(containment, SIGNAL(appletAdded(Plasma::Applet*)), q, SLOT(appletAdded(Plasma::Applet*))); | ||
279 | QObject::connect(containment, SIGNAL(appletRemoved(Plasma::Applet*)), q, SLOT(appletRemoved(Plasma::Applet*))); | 279 | QObject::connect(containment, SIGNAL(appletRemoved(Plasma::Applet*)), q, SLOT(appletRemoved(Plasma::Applet*))); | ||
280 | 280 | | |||
281 | foreach (Applet *applet, containment->applets()) { | 281 | const auto theApplets = containment->applets(); | ||
282 | for (Applet *applet : theApplets) { | ||||
282 | if (applet->pluginMetaData().isValid()) { | 283 | if (applet->pluginMetaData().isValid()) { | ||
283 | Containment *childContainment = applet->property("containment").value<Containment*>(); | 284 | Containment *childContainment = applet->property("containment").value<Containment*>(); | ||
284 | if (childContainment) { | 285 | if (childContainment) { | ||
285 | addContainment(childContainment); | 286 | addContainment(childContainment); | ||
286 | } | 287 | } | ||
287 | runningApplets[applet->pluginMetaData().pluginId()]++; | 288 | runningApplets[applet->pluginMetaData().pluginId()]++; | ||
288 | } else { | 289 | } else { | ||
289 | qDebug() << "Invalid plugin metadata. :("; | 290 | qDebug() << "Invalid plugin metadata. :("; | ||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 486 | if (item->data(PlasmaAppletItemModel::PluginNameRole).toString() == pluginName) { | |||
487 | break; | 488 | break; | ||
488 | } | 489 | } | ||
489 | } | 490 | } | ||
490 | 491 | | |||
491 | // now remove all instances of that applet | 492 | // now remove all instances of that applet | ||
492 | if (corona()) { | 493 | if (corona()) { | ||
493 | const auto &containments = corona()->containments(); | 494 | const auto &containments = corona()->containments(); | ||
494 | 495 | | |||
495 | foreach (Containment *c, containments) { | 496 | for (Containment *c : containments) { | ||
496 | const auto &applets = c->applets(); | 497 | const auto &applets = c->applets(); | ||
497 | 498 | | |||
498 | foreach (Applet *applet, applets) { | 499 | for (Applet *applet : applets) { | ||
499 | const auto &appletInfo = applet->pluginMetaData(); | 500 | const auto &appletInfo = applet->pluginMetaData(); | ||
500 | 501 | | |||
501 | if (appletInfo.isValid() && appletInfo.pluginId() == pluginName) { | 502 | if (appletInfo.isValid() && appletInfo.pluginId() == pluginName) { | ||
502 | applet->destroy(); | 503 | applet->destroy(); | ||
503 | } | 504 | } | ||
504 | } | 505 | } | ||
505 | } | 506 | } | ||
506 | } | 507 | } | ||
507 | } | 508 | } | ||
508 | 509 | | |||
509 | 510 | | |||
510 | #include "moc_widgetexplorer.cpp" | 511 | #include "moc_widgetexplorer.cpp" |