Changeset View
Changeset View
Standalone View
Standalone View
components/shellprivate/widgetexplorer/plasmaappletitemmodel.cpp
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | 126 | { | |||
---|---|---|---|---|---|
128 | setData(count, PlasmaAppletItemModel::RunningRole); | 128 | setData(count, PlasmaAppletItemModel::RunningRole); | ||
129 | emitDataChanged(); | 129 | emitDataChanged(); | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | bool PlasmaAppletItem::matches(const QString &pattern) const | 132 | bool PlasmaAppletItem::matches(const QString &pattern) const | ||
133 | { | 133 | { | ||
134 | if (m_info.service()) { | 134 | if (m_info.service()) { | ||
135 | const QStringList keywords = m_info.property(QStringLiteral("Keywords")).toStringList(); | 135 | const QStringList keywords = m_info.property(QStringLiteral("Keywords")).toStringList(); | ||
136 | foreach (const QString &keyword, keywords) { | 136 | for (const QString &keyword : keywords) { | ||
137 | if (keyword.startsWith(pattern, Qt::CaseInsensitive)) { | 137 | if (keyword.startsWith(pattern, Qt::CaseInsensitive)) { | ||
138 | return true; | 138 | return true; | ||
139 | } | 139 | } | ||
140 | } | 140 | } | ||
141 | } | 141 | } | ||
142 | 142 | | |||
143 | return AbstractItem::matches(pattern); | 143 | return AbstractItem::matches(pattern); | ||
144 | } | 144 | } | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 254 | { | |||
259 | clear(); | 259 | clear(); | ||
260 | //qDebug() << "populating model, our application is" << m_application; | 260 | //qDebug() << "populating model, our application is" << m_application; | ||
261 | 261 | | |||
262 | //qDebug() << "number of applets is" | 262 | //qDebug() << "number of applets is" | ||
263 | // << Plasma::Applet::listAppletInfo(QString(), m_application).count(); | 263 | // << Plasma::Applet::listAppletInfo(QString(), m_application).count(); | ||
264 | 264 | | |||
265 | QString constraint; | 265 | QString constraint; | ||
266 | bool first = true; | 266 | bool first = true; | ||
267 | foreach (const QString prov, m_provides) { | 267 | for (const QString prov : qAsConst(m_provides)) { | ||
268 | if (!first) { | 268 | if (!first) { | ||
269 | constraint += QLatin1String(" or "); | 269 | constraint += QLatin1String(" or "); | ||
270 | } | 270 | } | ||
271 | 271 | | |||
272 | first = false; | 272 | first = false; | ||
273 | constraint += "'" + prov + "' in [X-Plasma-Provides]"; | 273 | constraint += "'" + prov + "' in [X-Plasma-Provides]"; | ||
274 | } | 274 | } | ||
275 | 275 | | |||
276 | KPluginInfo::List list = KPluginInfo::fromMetaData(KPackage::PackageLoader::self()->listPackages(QStringLiteral("Plasma/Applet"), QStringLiteral("plasma/plasmoids")).toVector()); | 276 | KPluginInfo::List list = KPluginInfo::fromMetaData(KPackage::PackageLoader::self()->listPackages(QStringLiteral("Plasma/Applet"), QStringLiteral("plasma/plasmoids")).toVector()); | ||
277 | 277 | | |||
278 | KPluginTrader::applyConstraints(list, constraint); | 278 | KPluginTrader::applyConstraints(list, constraint); | ||
279 | 279 | | |||
280 | for (auto info : list) { | 280 | for (auto info : list) { | ||
281 | //qDebug() << info.pluginName() << "NoDisplay" << info.property("NoDisplay").toBool(); | 281 | //qDebug() << info.pluginName() << "NoDisplay" << info.property("NoDisplay").toBool(); | ||
282 | if (!info.isValid() || info.property(QStringLiteral("NoDisplay")).toBool() || info.category() == QLatin1String("Containments")) { | 282 | if (!info.isValid() || info.property(QStringLiteral("NoDisplay")).toBool() || info.category() == QLatin1String("Containments")) { | ||
283 | // we don't want to show the hidden category | 283 | // we don't want to show the hidden category | ||
284 | continue; | 284 | continue; | ||
285 | } | 285 | } | ||
286 | 286 | | |||
287 | bool inFormFactor = true; | 287 | bool inFormFactor = true; | ||
288 | 288 | | |||
289 | foreach (const QString &formFactor, KDeclarative::KDeclarative::runtimePlatform()) { | 289 | const auto runtimePlatform = KDeclarative::KDeclarative::runtimePlatform(); | ||
290 | for (const QString &formFactor : runtimePlatform) { | ||||
290 | if (!info.formFactors().isEmpty() && | 291 | if (!info.formFactors().isEmpty() && | ||
291 | !info.formFactors().contains(formFactor)) { | 292 | !info.formFactors().contains(formFactor)) { | ||
292 | inFormFactor = false; | 293 | inFormFactor = false; | ||
293 | } | 294 | } | ||
294 | } | 295 | } | ||
295 | if (!inFormFactor) { | 296 | if (!inFormFactor) { | ||
296 | continue; | 297 | continue; | ||
297 | } | 298 | } | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 356 | { | |||
365 | } | 366 | } | ||
366 | 367 | | |||
367 | QMimeData *data = new QMimeData(); | 368 | QMimeData *data = new QMimeData(); | ||
368 | 369 | | |||
369 | QString format = types.at(0); | 370 | QString format = types.at(0); | ||
370 | 371 | | |||
371 | QByteArray appletNames; | 372 | QByteArray appletNames; | ||
372 | int lastRow = -1; | 373 | int lastRow = -1; | ||
373 | foreach (const QModelIndex &index, indexes) { | 374 | for (const QModelIndex &index : indexes) { | ||
374 | if (index.row() == lastRow) { | 375 | if (index.row() == lastRow) { | ||
375 | continue; | 376 | continue; | ||
376 | } | 377 | } | ||
377 | 378 | | |||
378 | lastRow = index.row(); | 379 | lastRow = index.row(); | ||
379 | PlasmaAppletItem *selectedItem = (PlasmaAppletItem *) itemFromIndex(index); | 380 | PlasmaAppletItem *selectedItem = (PlasmaAppletItem *) itemFromIndex(index); | ||
380 | appletNames += '\n' + selectedItem->pluginName().toUtf8(); | 381 | appletNames += '\n' + selectedItem->pluginName().toUtf8(); | ||
381 | //qDebug() << selectedItem->pluginName() << index.column() << index.row(); | 382 | //qDebug() << selectedItem->pluginName() << index.column() << index.row(); | ||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |