Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/launchertasksmodel.cpp
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Line(s) | 164 | if (url.isValid()) { | |||
---|---|---|---|---|---|
170 | 170 | | |||
171 | if (!dupe) { | 171 | if (!dupe) { | ||
172 | urls.append(url); | 172 | urls.append(url); | ||
173 | } | 173 | } | ||
174 | } | 174 | } | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | if (d->launchers != urls) { | 177 | if (d->launchers != urls) { | ||
178 | // Common case optimization: If the list changed but its size | ||||
179 | // did not (e.g. due to reordering by a user of this model), | ||||
180 | // just clear the caches and announce new data instead of | ||||
181 | // resetting. | ||||
182 | if (d->launchers.count() == urls.count()) { | ||||
183 | d->launchers.clear(); | ||||
184 | d->appDataCache.clear(); | ||||
185 | | ||||
186 | d->launchers = urls; | ||||
187 | | ||||
188 | emit dataChanged(index(0, 0), index(d->launchers.count() - 1, 0)); | ||||
189 | } else { | ||||
178 | beginResetModel(); | 190 | beginResetModel(); | ||
179 | 191 | | |||
180 | d->launchers.clear(); | 192 | d->launchers.clear(); | ||
181 | d->appDataCache.clear(); | 193 | d->appDataCache.clear(); | ||
182 | 194 | | |||
183 | d->launchers = urls; | 195 | d->launchers = urls; | ||
184 | 196 | | |||
185 | endResetModel(); | 197 | endResetModel(); | ||
198 | } | ||||
186 | 199 | | |||
187 | emit launcherListChanged(); | 200 | emit launcherListChanged(); | ||
188 | } | 201 | } | ||
189 | } | 202 | } | ||
190 | 203 | | |||
191 | bool LauncherTasksModel::requestAddLauncher(const QUrl &_url) | 204 | bool LauncherTasksModel::requestAddLauncher(const QUrl &_url) | ||
192 | { | 205 | { | ||
193 | // isValid() for the passed-in URL might return true if it was | 206 | // isValid() for the passed-in URL might return true if it was | ||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |