Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/runnermodel.cpp
Show First 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | |||||
162 | 162 | | |||
163 | QStringList RunnerModel::runners() const | 163 | QStringList RunnerModel::runners() const | ||
164 | { | 164 | { | ||
165 | return m_runners; | 165 | return m_runners; | ||
166 | } | 166 | } | ||
167 | 167 | | |||
168 | void RunnerModel::setRunners(const QStringList &runners) | 168 | void RunnerModel::setRunners(const QStringList &runners) | ||
169 | { | 169 | { | ||
170 | if (m_runners.toSet() != runners.toSet()) { | 170 | QStringList newRunners = runners; | ||
171 | m_runners = runners; | 171 | newRunners.removeDuplicates(); | ||
172 | newRunners.sort(); | ||||
173 | | ||||
174 | QStringList currRunners = m_runners; | ||||
175 | currRunners.removeDuplicates(); | ||||
176 | currRunners.sort(); | ||||
177 | | ||||
178 | if (currRunners != newRunners) { | ||||
179 | m_runners = newRunners; | ||||
anthonyfieroni: Here should be `m_runners = runners` to be exactly same as previous. I don't see much benefit… | |||||
IIUC, the original code used toSet() to remove duplicates from both "m_runners" and "runners", because QSet doesn't allow duplicate items. ahmadsamir: IIUC, the original code used toSet() to remove duplicates from both "m_runners" and "runners"… | |||||
But toSet() returns new container m_runners and runners are unmodified. anthonyfieroni: But toSet() returns new container m_runners and runners are unmodified. | |||||
I don't mind reverting that bit, but it seems wasteful to me to throw newRunners away, it is sorted and has no duplicates.... ahmadsamir: I don't mind reverting that bit, but it seems wasteful to me to throw newRunners away, it is… | |||||
172 | 180 | | |||
173 | if (m_runnerManager) { | 181 | if (m_runnerManager) { | ||
174 | m_runnerManager->setAllowedRunners(runners); | 182 | m_runnerManager->setAllowedRunners(runners); | ||
175 | } | 183 | } | ||
176 | 184 | | |||
177 | emit runnersChanged(); | 185 | emit runnersChanged(); | ||
178 | } | 186 | } | ||
179 | } | 187 | } | ||
▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines |
Here should be m_runners = runners to be exactly same as previous. I don't see much benefit of having duplicate items.