@@ -27,20 +27,15 @@ using namespace unity::shell::application;
28LauncherModel::LauncherModel(QObject *parent):
28LauncherModel::LauncherModel(QObject *parent):
29 LauncherModelInterface(parent),
29 LauncherModelInterface(parent),
30+ m_greeterMode(qgetenv("XDG_SESSION_CLASS") == "greeter"),
30− m_backend(new LauncherBackend(this)),
31+ m_backend(new LauncherBackend(m_greeterMode, this)),
31 m_appManager(0)
32 m_appManager(0)
33 connect(m_backend, SIGNAL(countChanged(QString,int)), SLOT(countChanged(QString,int)));
34 connect(m_backend, SIGNAL(countChanged(QString,int)), SLOT(countChanged(QString,int)));
34 connect(m_backend, SIGNAL(progressChanged(QString,int)), SLOT(progressChanged(QString,int)));
35 connect(m_backend, SIGNAL(progressChanged(QString,int)), SLOT(progressChanged(QString,int)));
36+ connect(m_backend, SIGNAL(refreshApplications()), SLOT(refreshStoredApplications()));
36− Q_FOREACH (const QString &entry, m_backend->storedApplications()) {
38+ refreshStoredApplications();
37− LauncherItem *item = new LauncherItem(entry,
38− m_backend->displayName(entry),
39− m_backend->icon(entry),
41− item->setPinned(true);
46LauncherModel::~LauncherModel()
41LauncherModel::~LauncherModel()
@@ -139,7 +134,8 @@ void LauncherModel::pin(const QString &appId, int index)
139 beginInsertRows(QModelIndex(), index, index);
134 beginInsertRows(QModelIndex(), index, index);
140 LauncherItem *item = new LauncherItem(appId,
135 LauncherItem *item = new LauncherItem(appId,
141 m_backend->displayName(appId),
136 m_backend->displayName(appId),
142− m_backend->icon(appId));
137+ m_backend->icon(appId),
143 item->setPinned(true);
139 item->setPinned(true);
144 m_list.insert(index, item);
140 m_list.insert(index, item);
145 endInsertRows();
141 endInsertRows();
@@ -199,6 +195,40 @@ void LauncherModel::setUser(const QString &username)
199 m_backend->setUser(username);
195 m_backend->setUser(username);
198+void LauncherModel::refreshStoredApplications()
200+ // First remove any existing ones
201+ QList<int> storedAppIndices;
202+ for (int i = 0; i < m_list.count(); ++i) {
203+ if (!m_list.at(i)->recent()) {
204+ storedAppIndices << i;
208+ while (storedAppIndices.count() > 0) {
209+ beginRemoveRows(QModelIndex(), storedAppIndices.first() - run, storedAppIndices.first() - run);
210+ m_list.takeAt(storedAppIndices.first() - run)->deleteLater();
212+ storedAppIndices.takeFirst();
216+ // Now insert all stored apps at beginning of list
217+ QStringList storedApplications = m_backend->storedApplications();
218+ beginInsertRows(QModelIndex(), 0, storedApplications.size() - 1);
220+ Q_FOREACH (const QString &entry, storedApplications) {
221+ LauncherItem *item = new LauncherItem(entry,
222+ m_backend->displayName(entry),
223+ m_backend->icon(entry),
226+ item->setPinned(true);
227+ m_list.insert(run++, item);
202ApplicationManagerInterface *LauncherModel::applicationManager() const
232ApplicationManagerInterface *LauncherModel::applicationManager() const
204 return m_appManager;
234 return m_appManager;
@@ -302,7 +332,7 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
302 if (found) {
332 if (found) {
303 // Shall we paint some running/recent app highlight? If yes, do it here.
333 // Shall we paint some running/recent app highlight? If yes, do it here.
305− LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString());
335+ LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), !m_greeterMode);
306 item->setRecent(true);
336 item->setRecent(true);
307 item->setFocused(app->focused());
337 item->setFocused(app->focused());