on xenial help sign in
add count and progress overlay information to real model too.

Approved by PS Jenkins bot, Michał Sawicz.

commit127a1d7d3307e29b5e96ce3868f66fee51046b26 authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 23 Aug 2013, 10:25 (13 years ago) parente04bddbd7f22ac
2 files changed+32
plugins/Unity/Launcher/launchermodel.cpp+28 plugins/Unity/Launcher/launchermodel.h+4
plugins/Unity/Launcher/launchermodel.cpp+28
@@ -25,6 +25,9 @@ LauncherModel::LauncherModel(QObject *parent):
2525 LauncherModelInterface(parent),
2626 m_backend(new LauncherBackend(this))
2727{
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+
2831 Q_FOREACH (const QString &entry, m_backend->storedApplications()) {
2932 LauncherItem *item = new LauncherItem(entry,
3033 m_backend->desktopFile(entry),
@@ -67,6 +70,10 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
6770 return item->icon();
6871 case RolePinned:
6972 return item->pinned();
73+ case RoleCount:
74+ return item->count();
75+ case RoleProgress:
76+ return item->progress();
7077 }
7178
7279 return QVariant();
@@ -204,3 +211,24 @@ int LauncherModel::findApplication(const QString &appId)
204211 }
205212 return -1;
206213}
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:
5454 void storeAppList();
5555 int findApplication(const QString &appId);
5656
57+private Q_SLOTS:
58+ void progressChanged(const QString &appId, int progress);
59+ void countChanged(const QString &appId, int count);
60+
5761private:
5862 QList<LauncherItem*> m_list;
5963 LauncherBackend *m_backend;