@@ -99,18 +99,6 @@ QVariant LauncherModel::data(const QModelIndex &index, int role) const
99 return QVariant();
99 return QVariant();
102−void LauncherModel::setAlerting(const QString &appId, bool alerting) {
103− int index = findApplication(appId);
105− QModelIndex modelIndex = this->index(index);
106− LauncherItem *item = m_list.at(index);
107− if (!item->focused()) {
108− item->setAlerting(alerting);
109− Q_EMIT dataChanged(modelIndex, modelIndex, {RoleAlerting});
114unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
102unity::shell::launcher::LauncherItemInterface *LauncherModel::get(int index) const
116 if (index < 0 || index >= m_list.count()) {
104 if (index < 0 || index >= m_list.count()) {
@@ -361,11 +349,13 @@ void LauncherModel::countChanged(const QString &appId, int count)
361 if (idx >= 0) {
349 if (idx >= 0) {
362 LauncherItem *item = m_list.at(idx);
350 LauncherItem *item = m_list.at(idx);
363 item->setCount(count);
351 item->setCount(count);
352+ QVector<int> changedRoles = {RoleCount};
364− if (item->countVisible()) {
353+ if (item->countVisible() && !item->alerting() && !item->focused()) {
354+ changedRoles << RoleAlerting;
365− setAlerting(item->appId(), true);
355+ item->setAlerting(true);
367 m_asAdapter->syncItems(m_list);
357 m_asAdapter->syncItems(m_list);
368− Q_EMIT dataChanged(index(idx), index(idx), {RoleCount});
358+ Q_EMIT dataChanged(index(idx), index(idx), changedRoles);
@@ -375,10 +365,12 @@ void LauncherModel::countVisibleChanged(const QString &appId, bool countVisible)
375 if (idx >= 0) {
365 if (idx >= 0) {
376 LauncherItem *item = m_list.at(idx);
366 LauncherItem *item = m_list.at(idx);
377 item->setCountVisible(countVisible);
367 item->setCountVisible(countVisible);
368+ QVector<int> changedRoles = {RoleCount};
378− if (countVisible) {
369+ if (countVisible && !item->alerting() && !item->focused()) {
370+ changedRoles << RoleAlerting;
379− setAlerting(item->appId(), true);
371+ item->setAlerting(true);
381− Q_EMIT dataChanged(index(idx), index(idx), {RoleCountVisible});
373+ Q_EMIT dataChanged(index(idx), index(idx), changedRoles);
383 // If countVisible goes to false, and the item is neither pinned nor recent we can drop it
375 // If countVisible goes to false, and the item is neither pinned nor recent we can drop it
384 if (!countVisible && !item->pinned() && !item->recent()) {
376 if (!countVisible && !item->pinned() && !item->recent()) {
@@ -501,8 +493,10 @@ void LauncherModel::alert(const QString &appId)
501 int idx = findApplication(appId);
493 int idx = findApplication(appId);
502 if (idx >= 0) {
494 if (idx >= 0) {
503 LauncherItem *item = m_list.at(idx);
495 LauncherItem *item = m_list.at(idx);
496+ if (!item->focused() && !item->alerting()) {
504− setAlerting(item->appId(), true);
497+ item->setAlerting(true);
505− Q_EMIT dataChanged(index(idx), index(idx), {RoleAlerting});
498+ Q_EMIT dataChanged(index(idx), index(idx), {RoleAlerting});
@@ -585,16 +579,21 @@ void LauncherModel::applicationRemoved(const QModelIndex &parent, int row)
585 disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
579 disconnect(app, &ApplicationInfoInterface::surfaceCountChanged, this, &LauncherModel::applicationSurfaceCountChanged);
587 LauncherItem * item = m_list.at(appIndex);
581 LauncherItem * item = m_list.at(appIndex);
588− item->setRunning(false);
590 if (!item->pinned()) {
583 if (!item->pinned()) {
591 beginRemoveRows(QModelIndex(), appIndex, appIndex);
584 beginRemoveRows(QModelIndex(), appIndex, appIndex);
592 m_list.takeAt(appIndex)->deleteLater();
585 m_list.takeAt(appIndex)->deleteLater();
593 endRemoveRows();
586 endRemoveRows();
594 m_asAdapter->syncItems(m_list);
587 m_asAdapter->syncItems(m_list);
589+ QVector<int> changedRoles = {RoleRunning};
590+ item->setRunning(false);
591+ if (item->focused()) {
592+ changedRoles << RoleFocused;
593+ item->setFocused(false);
595− Q_EMIT dataChanged(index(appIndex), index(appIndex), {RolePinned});
595+ Q_EMIT dataChanged(index(appIndex), index(appIndex), changedRoles);
597− Q_EMIT dataChanged(index(appIndex), index(appIndex), {RoleRunning});
600void LauncherModel::focusedAppIdChanged()
599void LauncherModel::focusedAppIdChanged()
@@ -603,8 +602,14 @@ void LauncherModel::focusedAppIdChanged()
603 for (int i = 0; i < m_list.count(); ++i) {
602 for (int i = 0; i < m_list.count(); ++i) {
604 LauncherItem *item = m_list.at(i);
603 LauncherItem *item = m_list.at(i);
605 if (!item->focused() && item->appId() == appId) {
604 if (!item->focused() && item->appId() == appId) {
605+ QVector<int> changedRoles;
606+ changedRoles << RoleFocused;
606 item->setFocused(true);
607 item->setFocused(true);
607− Q_EMIT dataChanged(index(i), index(i), {RoleFocused});
608+ if (item->alerting()) {
609+ changedRoles << RoleAlerting;
610+ item->setAlerting(false);
612+ Q_EMIT dataChanged(index(i), index(i), changedRoles);
608 } else if (item->focused() && item->appId() != appId) {
613 } else if (item->focused() && item->appId() != appId) {
609 item->setFocused(false);
614 item->setFocused(false);
610 Q_EMIT dataChanged(index(i), index(i), {RoleFocused});
615 Q_EMIT dataChanged(index(i), index(i), {RoleFocused});