on xenial help sign in
add count and progress overlay information to real model too.
127a1d7Michael Zanetti
plugins/Unity/Launcher/launchermodel.cpp+28
@@ -25,6 +25,9 @@ LauncherModel::LauncherModel(QObject *parent):
25 LauncherModelInterface(parent),
25 LauncherModelInterface(parent),
26 m_backend(new LauncherBackend(this))
26 m_backend(new LauncherBackend(this))
27{
27{
28+ connect(m_backend, SIGNAL(countChanged(QString,int)), SLOT(countChanged(QString,int)));
29+ connect(m_backend, SIGNAL(progressChanged(QString,int)), SLOT(progressChanged(QString,int)));
30+
28 Q_FOREACH (const QString &entry, m_backend->storedApplications()) {
31 Q_FOREACH (const QString &entry, m_backend->storedApplications()) {
29 LauncherItem *item = new LauncherItem(entry,
32 LauncherItem *item = new LauncherItem(entry,
30 m_backend->desktopFile(entry),
33 m_backend->desktopFile(entry),
@@ -67,6 +70,10 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
67 return item->icon();
70 return item->icon();
68 case RolePinned:
71 case RolePinned:
69 return item->pinned();
72 return item->pinned();
73+ case RoleCount:
74+ return item->count();
75+ case RoleProgress:
76+ return item->progress();
70 }
77 }
71
78
72 return QVariant();
79 return QVariant();
@@ -204,3 +211,24 @@ int LauncherModel::findApplication(const QString &appId)
204 }
211 }
205 return -1;
212 return -1;
206}
213}
214+
215+void LauncherModel::progressChanged(const QString &appId, int progress)
216+{
217+ int idx = findApplication(appId);
218+ if (idx >= 0) {
219+ LauncherItem *item = m_list.at(idx);
220+ item->setProgress(progress);
221+ Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleProgress);
222+ }
223+}
224+
225+
226+void LauncherModel::countChanged(const QString &appId, int count)
227+{
228+ int idx = findApplication(appId);
229+ if (idx >= 0) {
230+ LauncherItem *item = m_list.at(idx);
231+ item->setCount(count);
232+ Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleCount);
233+ }
234+}
plugins/Unity/Launcher/launchermodel.h+4
@@ -54,6 +54,10 @@ private:
54 void storeAppList();
54 void storeAppList();
55 int findApplication(const QString &appId);
55 int findApplication(const QString &appId);
56
56
57+private Q_SLOTS:
58+ void progressChanged(const QString &appId, int progress);
59+ void countChanged(const QString &appId, int count);
60+
57private:
61private:
58 QList<LauncherItem*> m_list;
62 QList<LauncherItem*> m_list;
59 LauncherBackend *m_backend;
63 LauncherBackend *m_backend;