@@ -82,9 +82,14 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
82 return item->progress();
82 return item->progress();
83 case RoleFocused:
83 case RoleFocused:
84 return item->focused();
84 return item->focused();
86+ return item->running();
88+ qWarning() << Q_FUNC_INFO << "missing role, implement me";
87− return QVariant();
92+ return LauncherModelInterface::data(index, role);
90unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
95unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
@@ -134,7 +139,7 @@ void LauncherModel::pin(const QString &appId, int index)
134 if (index == -1 || index == currentIndex) {
139 if (index == -1 || index == currentIndex) {
135 m_list.at(currentIndex)->setPinned(true);
140 m_list.at(currentIndex)->setPinned(true);
136 QModelIndex modelIndex = this->index(currentIndex);
141 QModelIndex modelIndex = this->index(currentIndex);
137− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
142+ Q_EMIT dataChanged(modelIndex, modelIndex, {RolePinned});
139 move(currentIndex, index);
144 move(currentIndex, index);
140 // move() will store the list to the backend itself, so just exit at this point.
145 // move() will store the list to the backend itself, so just exit at this point.
@@ -147,7 +152,7 @@ void LauncherModel::pin(const QString &appId, int index)
148 DesktopFileHandler desktopFile(appId);
153 DesktopFileHandler desktopFile(appId);
149 if (!desktopFile.isValid()) {
154 if (!desktopFile.isValid()) {
150− qWarning() << "Can't pin this application, there is no .destkop file available.";
155+ qWarning() << "Can't pin this application, there is no .desktop file available.";
@@ -172,7 +177,7 @@ void LauncherModel::requestRemove(const QString &appId)
173void LauncherModel::quickListActionInvoked(const QString &appId, int actionIndex)
178void LauncherModel::quickListActionInvoked(const QString &appId, int actionIndex)
175− int index = findApplication(appId);
180+ const int index = findApplication(appId);
176 if (index < 0) {
181 if (index < 0) {
@@ -273,6 +278,7 @@ bool LauncherModel::onlyPinned() const
274void LauncherModel::setOnlyPinned(bool onlyPinned) {
279void LauncherModel::setOnlyPinned(bool onlyPinned) {
275 Q_UNUSED(onlyPinned);
280 Q_UNUSED(onlyPinned);
281+ // FIXME implement showing only pinned apps
276 qWarning() << "This launcher implementation does not support showing only pinned apps";
282 qWarning() << "This launcher implementation does not support showing only pinned apps";
@@ -299,7 +305,7 @@ void LauncherModel::unpin(const QString &appId)
299 if (m_list.at(index)->pinned()) {
305 if (m_list.at(index)->pinned()) {
300 m_list.at(index)->setPinned(false);
306 m_list.at(index)->setPinned(false);
301 QModelIndex modelIndex = this->index(index);
307 QModelIndex modelIndex = this->index(index);
302− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
308+ Q_EMIT dataChanged(modelIndex, modelIndex, {RolePinned});
305 beginRemoveRows(QModelIndex(), index, index);
311 beginRemoveRows(QModelIndex(), index, index);
@@ -325,7 +331,7 @@ void LauncherModel::progressChanged(const QString &appId, int progress)
325 if (idx >= 0) {
331 if (idx >= 0) {
326 LauncherItem *item = m_list.at(idx);
332 LauncherItem *item = m_list.at(idx);
327 item->setProgress(progress);
333 item->setProgress(progress);
328− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleProgress);
334+ Q_EMIT dataChanged(index(idx), index(idx), {RoleProgress});
@@ -335,7 +341,7 @@ void LauncherModel::countChanged(const QString &appId, int count)
335 if (idx >= 0) {
341 if (idx >= 0) {
336 LauncherItem *item = m_list.at(idx);
342 LauncherItem *item = m_list.at(idx);
337 item->setCount(count);
343 item->setCount(count);
338− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleCount);
344+ Q_EMIT dataChanged(index(idx), index(idx), {RoleCount});
339 m_asAdapter->syncItems(m_list);
345 m_asAdapter->syncItems(m_list);
@@ -346,7 +352,7 @@ void LauncherModel::countVisibleChanged(const QString &appId, int countVisible)
346 if (idx >= 0) {
352 if (idx >= 0) {
347 LauncherItem *item = m_list.at(idx);
353 LauncherItem *item = m_list.at(idx);
348 item->setCountVisible(countVisible);
354 item->setCountVisible(countVisible);
349− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleCountVisible);
355+ Q_EMIT dataChanged(index(idx), index(idx), {RoleCountVisible});
351 // If countVisible goes to false, and the item is neither pinned nor recent we can drop it
357 // If countVisible goes to false, and the item is neither pinned nor recent we can drop it
352 if (!countVisible && !item->pinned() && !item->recent()) {
358 if (!countVisible && !item->pinned() && !item->recent()) {
@@ -388,7 +394,7 @@ void LauncherModel::refresh()
388 item->setName(desktopFile.displayName());
394 item->setName(desktopFile.displayName());
389 item->setIcon(desktopFile.icon());
395 item->setIcon(desktopFile.icon());
390 item->setPinned(item->pinned()); // update pinned text if needed
396 item->setPinned(item->pinned()); // update pinned text if needed
391− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleName << RoleIcon);
397+ Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleIcon});
@@ -475,12 +481,13 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
475 if (!item->recent()) {
481 if (!item->recent()) {
476 item->setRecent(true);
482 item->setRecent(true);
477 m_asAdapter->syncItems(m_list);
483 m_asAdapter->syncItems(m_list);
478− Q_EMIT dataChanged(index(itemIndex), index(itemIndex), QVector<int>() << RoleRecent);
484+ Q_EMIT dataChanged(index(itemIndex), index(itemIndex), {RoleRecent});
480− // Shall we paint some running/recent app highlight? If yes, do it here.
486+ // TODO Shall we paint some running/recent app highlight? If yes, do it here.
482 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
488 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
483 item->setRecent(true);
489 item->setRecent(true);
490+ item->setRunning(true);
484 item->setFocused(app->focused());
491 item->setFocused(app->focused());
486 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
493 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
@@ -502,7 +509,15 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
513+ qWarning() << Q_FUNC_INFO << "appIndex not found";
505− if (appIndex > -1 && !m_list.at(appIndex)->pinned()) {
517+ LauncherItem * item = m_list.at(appIndex);
518+ item->setRunning(false);
520+ if (!item->pinned()) {
506 beginRemoveRows(QModelIndex(), appIndex, appIndex);
521 beginRemoveRows(QModelIndex(), appIndex, appIndex);
507 m_list.takeAt(appIndex)->deleteLater();
522 m_list.takeAt(appIndex)->deleteLater();
508 endRemoveRows();
523 endRemoveRows();
@@ -517,10 +532,10 @@ void LauncherModel::focusedAppIdChanged()
517 LauncherItem *item = m_list.at(i);
532 LauncherItem *item = m_list.at(i);
518 if (!item->focused() && item->appId() == appId) {
533 if (!item->focused() && item->appId() == appId) {
519 item->setFocused(true);
534 item->setFocused(true);
520− Q_EMIT dataChanged(index(i), index(i), QVector<int>() << RoleFocused);
535+ Q_EMIT dataChanged(index(i), index(i), {RoleFocused});
521 } else if (item->focused() && item->appId() != appId) {
536 } else if (item->focused() && item->appId() != appId) {
522 item->setFocused(false);
537 item->setFocused(false);
523− Q_EMIT dataChanged(index(i), index(i), QVector<int>() << RoleFocused);
538+ Q_EMIT dataChanged(index(i), index(i), {RoleFocused});