Changeset View
Changeset View
Standalone View
Standalone View
components/shellprivate/widgetexplorer/plasmaappletitemmodel.cpp
Show All 25 Lines | |||||
26 | #include <kservicetypetrader.h> | 26 | #include <kservicetypetrader.h> | ||
27 | #include <ksycoca.h> | 27 | #include <ksycoca.h> | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> | ||
29 | #include "config-workspace.h" | 29 | #include "config-workspace.h" | ||
30 | #include <KPluginTrader> | 30 | #include <KPluginTrader> | ||
31 | #include <KPackage/PackageLoader> | 31 | #include <KPackage/PackageLoader> | ||
32 | #include <KDeclarative/KDeclarative> | 32 | #include <KDeclarative/KDeclarative> | ||
33 | 33 | | |||
34 | PlasmaAppletItem::PlasmaAppletItem(PlasmaAppletItemModel *model, | 34 | PlasmaAppletItem::PlasmaAppletItem(const KPluginInfo& info): | ||
35 | const KPluginInfo& info) | 35 | AbstractItem(), | ||
36 | : QObject(model), | | |||
37 | m_model(model), | | |||
38 | m_info(info), | 36 | m_info(info), | ||
39 | m_runningCount(0), | 37 | m_runningCount(0), | ||
40 | m_local(false) | 38 | m_local(false) | ||
41 | { | 39 | { | ||
42 | const QString api(m_info.property(QStringLiteral("X-Plasma-API")).toString()); | 40 | const QString api(m_info.property(QStringLiteral("X-Plasma-API")).toString()); | ||
43 | if (!api.isEmpty()) { | 41 | if (!api.isEmpty()) { | ||
44 | const QString _f = PLASMA_RELATIVE_DATA_INSTALL_DIR "/plasmoids/" + info.pluginName() + '/'; | 42 | const QString _f = PLASMA_RELATIVE_DATA_INSTALL_DIR "/plasmoids/" + info.pluginName() + '/'; | ||
45 | QFileInfo dir(QStandardPaths::locate(QStandardPaths::QStandardPaths::GenericDataLocation, | 43 | QFileInfo dir(QStandardPaths::locate(QStandardPaths::QStandardPaths::GenericDataLocation, | ||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | |||||
174 | 172 | | |||
175 | QStringList PlasmaAppletItem::mimeTypes() const | 173 | QStringList PlasmaAppletItem::mimeTypes() const | ||
176 | { | 174 | { | ||
177 | QStringList types; | 175 | QStringList types; | ||
178 | types << QStringLiteral("text/x-plasmoidservicename"); | 176 | types << QStringLiteral("text/x-plasmoidservicename"); | ||
179 | return types; | 177 | return types; | ||
180 | } | 178 | } | ||
181 | 179 | | |||
182 | PlasmaAppletItemModel* PlasmaAppletItem::appletItemModel() | | |||
183 | { | | |||
184 | return m_model; | | |||
185 | } | | |||
186 | | ||||
187 | QVariant PlasmaAppletItem::data(int role) const | 180 | QVariant PlasmaAppletItem::data(int role) const | ||
188 | { | 181 | { | ||
189 | switch (role) { | 182 | switch (role) { | ||
190 | case PlasmaAppletItemModel::ScreenshotRole: | 183 | case PlasmaAppletItemModel::ScreenshotRole: | ||
191 | //null = not yet done, empty = tried and failed | 184 | //null = not yet done, empty = tried and failed | ||
192 | if (m_screenshot.isNull()) { | 185 | if (m_screenshot.isNull()) { | ||
193 | KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Applet")); | 186 | KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Applet")); | ||
194 | pkg.setDefaultPackageRoot(QStringLiteral("plasma/plasmoids")); | 187 | pkg.setDefaultPackageRoot(QStringLiteral("plasma/plasmoids")); | ||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 279 | for (auto info : list) { | |||
300 | } | 293 | } | ||
301 | if (!inFormFactor) { | 294 | if (!inFormFactor) { | ||
302 | continue; | 295 | continue; | ||
303 | } | 296 | } | ||
304 | 297 | | |||
305 | //qDebug() << info.pluginName() << " is the name of the plugin at" << info.entryPath(); | 298 | //qDebug() << info.pluginName() << " is the name of the plugin at" << info.entryPath(); | ||
306 | //qDebug() << info.name() << info.property("X-Plasma-Thumbnail"); | 299 | //qDebug() << info.name() << info.property("X-Plasma-Thumbnail"); | ||
307 | 300 | | |||
308 | appendRow(new PlasmaAppletItem(this, info)); | 301 | appendRow(new PlasmaAppletItem(info)); | ||
309 | } | 302 | } | ||
310 | 303 | | |||
311 | emit modelPopulated(); | 304 | emit modelPopulated(); | ||
312 | } | 305 | } | ||
313 | 306 | | |||
314 | void PlasmaAppletItemModel::setRunningApplets(const QHash<QString, int> &apps) | 307 | void PlasmaAppletItemModel::setRunningApplets(const QHash<QString, int> &apps) | ||
315 | { | 308 | { | ||
316 | //foreach item, find that string and set the count | 309 | //foreach item, find that string and set the count | ||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |