Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/tasksmodel.cpp
Show First 20 Lines • Show All 791 Lines • ▼ Show 20 Line(s) | 791 | { | |||
---|---|---|---|---|---|
792 | // Collects the number of window tasks on each activity. | 792 | // Collects the number of window tasks on each activity. | ||
793 | 793 | | |||
794 | activityTaskCounts.clear(); | 794 | activityTaskCounts.clear(); | ||
795 | 795 | | |||
796 | if (!windowTasksModel || !activityInfo) { | 796 | if (!windowTasksModel || !activityInfo) { | ||
797 | return; | 797 | return; | ||
798 | } | 798 | } | ||
799 | 799 | | |||
800 | foreach(const QString &activity, activityInfo->runningActivities()) { | 800 | const auto ras = activityInfo->runningActivities(); | ||
801 | for (const QString &activity : activityInfo->runningActivities()) { | ||||
801 | activityTaskCounts.insert(activity, 0); | 802 | activityTaskCounts.insert(activity, 0); | ||
802 | } | 803 | } | ||
803 | 804 | | |||
804 | for (int i = 0; i < windowTasksModel->rowCount(); ++i) { | 805 | for (int i = 0; i < windowTasksModel->rowCount(); ++i) { | ||
805 | const QModelIndex &windowIndex = windowTasksModel->index(i, 0); | 806 | const QModelIndex &windowIndex = windowTasksModel->index(i, 0); | ||
806 | const QStringList &activities = windowIndex.data(AbstractTasksModel::Activities).toStringList(); | 807 | const QStringList &activities = windowIndex.data(AbstractTasksModel::Activities).toStringList(); | ||
807 | 808 | | |||
808 | if (activities.isEmpty()) { | 809 | if (activities.isEmpty()) { | ||
809 | QMutableHashIterator<QString, int> i(activityTaskCounts); | 810 | QMutableHashIterator<QString, int> i(activityTaskCounts); | ||
810 | 811 | | |||
811 | while (i.hasNext()) { | 812 | while (i.hasNext()) { | ||
812 | i.next(); | 813 | i.next(); | ||
813 | i.setValue(i.value() + 1); | 814 | i.setValue(i.value() + 1); | ||
814 | } | 815 | } | ||
815 | } else { | 816 | } else { | ||
816 | foreach(const QString &activity, activities) { | 817 | for (const QString &activity : activities) { | ||
817 | ++activityTaskCounts[activity]; | 818 | ++activityTaskCounts[activity]; | ||
818 | } | 819 | } | ||
819 | } | 820 | } | ||
820 | } | 821 | } | ||
821 | } | 822 | } | ||
822 | 823 | | |||
823 | void TasksModel::Private::forceResort() | 824 | void TasksModel::Private::forceResort() | ||
824 | { | 825 | { | ||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Line(s) | 931 | case SortActivity: { | |||
933 | // up of the task counts for each acvtivity a task is assigned to, and | 934 | // up of the task counts for each acvtivity a task is assigned to, and | ||
934 | // otherwise fall through to alphabetical sorting. | 935 | // otherwise fall through to alphabetical sorting. | ||
935 | int leftScore = -1; | 936 | int leftScore = -1; | ||
936 | int rightScore = -1; | 937 | int rightScore = -1; | ||
937 | 938 | | |||
938 | const QStringList &leftActivities = left.data(AbstractTasksModel::Activities).toStringList(); | 939 | const QStringList &leftActivities = left.data(AbstractTasksModel::Activities).toStringList(); | ||
939 | 940 | | |||
940 | if (!leftActivities.isEmpty()) { | 941 | if (!leftActivities.isEmpty()) { | ||
941 | foreach(const QString& activity, leftActivities) { | 942 | for (const QString& activity : leftActivities) { | ||
942 | leftScore += activityTaskCounts[activity]; | 943 | leftScore += activityTaskCounts[activity]; | ||
943 | } | 944 | } | ||
944 | } | 945 | } | ||
945 | 946 | | |||
946 | const QStringList &rightActivities = right.data(AbstractTasksModel::Activities).toStringList(); | 947 | const QStringList &rightActivities = right.data(AbstractTasksModel::Activities).toStringList(); | ||
947 | 948 | | |||
948 | if (!rightActivities.isEmpty()) { | 949 | if (!rightActivities.isEmpty()) { | ||
949 | foreach(const QString& activity, rightActivities) { | 950 | for (const QString& activity : rightActivities) { | ||
950 | rightScore += activityTaskCounts[activity]; | 951 | rightScore += activityTaskCounts[activity]; | ||
951 | } | 952 | } | ||
952 | } | 953 | } | ||
953 | 954 | | |||
954 | if (leftScore == -1 || rightScore == -1) { | 955 | if (leftScore == -1 || rightScore == -1) { | ||
955 | const int sumScore = std::accumulate(activityTaskCounts.constBegin(), activityTaskCounts.constEnd(), 0); | 956 | const int sumScore = std::accumulate(activityTaskCounts.constBegin(), activityTaskCounts.constEnd(), 0); | ||
956 | 957 | | |||
957 | if (leftScore == -1) { | 958 | if (leftScore == -1) { | ||
▲ Show 20 Lines • Show All 798 Lines • ▼ Show 20 Line(s) | 1754 | { | |||
1756 | 1757 | | |||
1757 | if (!d->launcherTasksModel || !d->launcherSortingDirty) { | 1758 | if (!d->launcherTasksModel || !d->launcherSortingDirty) { | ||
1758 | return; | 1759 | return; | ||
1759 | } | 1760 | } | ||
1760 | 1761 | | |||
1761 | QMap<int, QString> sortedShownLaunchers; | 1762 | QMap<int, QString> sortedShownLaunchers; | ||
1762 | QStringList sortedHiddenLaunchers; | 1763 | QStringList sortedHiddenLaunchers; | ||
1763 | 1764 | | |||
1764 | foreach(const QString &launcherUrlStr, launcherList()) { | 1765 | const auto launchers = launcherList(); | ||
1766 | for (const QString &launcherUrlStr : launchers) { | ||||
1765 | int row = -1; | 1767 | int row = -1; | ||
1766 | QStringList activities; | 1768 | QStringList activities; | ||
1767 | QUrl launcherUrl; | 1769 | QUrl launcherUrl; | ||
1768 | 1770 | | |||
1769 | std::tie(launcherUrl, activities) = deserializeLauncher(launcherUrlStr); | 1771 | std::tie(launcherUrl, activities) = deserializeLauncher(launcherUrlStr); | ||
1770 | 1772 | | |||
1771 | for (int i = 0; i < rowCount(); ++i) { | 1773 | for (int i = 0; i < rowCount(); ++i) { | ||
1772 | const QUrl &rowLauncherUrl = index(i, 0).data(AbstractTasksModel::LauncherUrlWithoutIcon).toUrl(); | 1774 | const QUrl &rowLauncherUrl = index(i, 0).data(AbstractTasksModel::LauncherUrlWithoutIcon).toUrl(); | ||
▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines |