Changeset View
Changeset View
Standalone View
Standalone View
src/resultmodel.cpp
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | 131 | if (resourcePosition.iterator->linkStatus() == ResultSet::Result::NotLinked) { | |||
---|---|---|---|---|---|
132 | return; | 132 | return; | ||
133 | } | 133 | } | ||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | // Lets make a list of linked items - we can only reorder them, | 136 | // Lets make a list of linked items - we can only reorder them, | ||
137 | // not others | 137 | // not others | ||
138 | QStringList linkedItems; | 138 | QStringList linkedItems; | ||
139 | 139 | | |||
140 | foreach (const ResultSet::Result &item, m_items) { | 140 | for (const ResultSet::Result &item : qAsConst(m_items)) { | ||
141 | if (item.linkStatus() == ResultSet::Result::NotLinked) break; | 141 | if (item.linkStatus() == ResultSet::Result::NotLinked) break; | ||
142 | linkedItems << item.resource(); | 142 | linkedItems << item.resource(); | ||
143 | } | 143 | } | ||
144 | 144 | | |||
145 | // We have two options: | 145 | // We have two options: | ||
146 | // - we are planning to add an item to the desired position, | 146 | // - we are planning to add an item to the desired position, | ||
147 | // but the item is not yet in the model | 147 | // but the item is not yet in the model | ||
148 | // - we want to move an existing item | 148 | // - we want to move an existing item | ||
▲ Show 20 Lines • Show All 887 Lines • ▼ Show 20 Line(s) | |||||
1036 | { | 1036 | { | ||
1037 | return parent.isValid() ? false | 1037 | return parent.isValid() ? false | ||
1038 | : d->cache.size() >= d->query.limit() ? false | 1038 | : d->cache.size() >= d->query.limit() ? false | ||
1039 | : d->hasMore; | 1039 | : d->hasMore; | ||
1040 | } | 1040 | } | ||
1041 | 1041 | | |||
1042 | void ResultModel::forgetResource(const QString &resource) | 1042 | void ResultModel::forgetResource(const QString &resource) | ||
1043 | { | 1043 | { | ||
1044 | foreach (const QString &activity, d->query.activities()) { | 1044 | const auto lstActivities = d->query.activities(); | ||
1045 | foreach (const QString &agent, d->query.agents()) { | 1045 | for (const QString &activity : lstActivities) { | ||
1046 | const auto lstAgents = d->query.agents(); | ||||
1047 | for (const QString &agent : lstAgents) { | ||||
1046 | Stats::forgetResource( | 1048 | Stats::forgetResource( | ||
1047 | activity, | 1049 | activity, | ||
1048 | agent == CURRENT_AGENT_TAG ? | 1050 | agent == CURRENT_AGENT_TAG ? | ||
1049 | QCoreApplication::applicationName() : agent, | 1051 | QCoreApplication::applicationName() : agent, | ||
1050 | resource); | 1052 | resource); | ||
1051 | } | 1053 | } | ||
1052 | } | 1054 | } | ||
1053 | } | 1055 | } | ||
1054 | 1056 | | |||
1055 | void ResultModel::forgetResource(int row) | 1057 | void ResultModel::forgetResource(int row) | ||
1056 | { | 1058 | { | ||
1057 | if (row >= d->cache.size()) return; | 1059 | if (row >= d->cache.size()) return; | ||
1058 | 1060 | const auto lstActivities = d->query.activities(); | |||
1059 | foreach (const QString &activity, d->query.activities()) { | 1061 | for (const QString &activity : lstActivities) { | ||
1060 | foreach (const QString &agent, d->query.agents()) { | 1062 | const auto lstAgents = d->query.agents(); | ||
1063 | for (const QString &agent : lstAgents) { | ||||
1061 | Stats::forgetResource( | 1064 | Stats::forgetResource( | ||
1062 | activity, | 1065 | activity, | ||
1063 | agent == CURRENT_AGENT_TAG ? | 1066 | agent == CURRENT_AGENT_TAG ? | ||
1064 | QCoreApplication::applicationName() : agent, | 1067 | QCoreApplication::applicationName() : agent, | ||
1065 | d->cache[row].resource()); | 1068 | d->cache[row].resource()); | ||
1066 | } | 1069 | } | ||
1067 | } | 1070 | } | ||
1068 | } | 1071 | } | ||
Show All 35 Lines |