| 178 | } |
| 179 | |
| 180 | void ProjectBuildSetModel::removeItemsWithCache( const QList<int>& itemIndices ) |
| 181 | { |
| 182 | /* |
| 183 | * Removes the items with given indices from both the build set and the ordering cache. |
| 184 | * List is given since removing many items together is more efficient than by one. |
| 185 | * |
| 186 | * Indices in the list shall be sorted. |
| 187 | */ |
| 188 | |
| 189 | Q_D(ProjectBuildSetModel); |
| 190 | |
| 191 | QList<int> itemIndicesCopy = itemIndices; |
| 192 | |
| 193 | beginRemoveRows( QModelIndex(), itemIndices.first(), itemIndices.last() ); |
| 194 | for (QList<QStringList>::iterator cacheIterator = d->orderingCache.end() - 1; |
| 195 | cacheIterator >= d->orderingCache.begin() && !itemIndicesCopy.isEmpty();) { |
| 196 | |
| 197 | int index = itemIndicesCopy.back(); |
| 198 | Q_ASSERT( index >= 0 && index < d->items.size() ); |
| 199 | if (*cacheIterator == d->items.at(index).itemPath()) { |
| 200 | cacheIterator = d->orderingCache.erase(cacheIterator); |
| 201 | d->items.removeAt(index); |
| 202 | itemIndicesCopy.removeLast(); |
| 203 | } |
| 204 | --cacheIterator; |
| 205 | |
| 206 | } // for |
| 207 | endRemoveRows(); |
| 208 | |
| 209 | Q_ASSERT( itemIndicesCopy.isEmpty() ); |
| 210 | } |
| 211 | |
| 212 | void ProjectBuildSetModel::insertItemWithCache( const BuildItem& item ) |
| 213 | { |