| 228 | } |
| 229 | |
| 230 | void TaskModel::clearTasks(const QString &categoryId) |
| 231 | { |
| 232 | typedef QHash<QString, CategoryData>::ConstIterator IdCategoryConstIt; |
| 233 | |
| 234 | if (categoryId.isEmpty()) { |
| 235 | if (allTasks.count() == 0) |
| 236 | return; |
| 237 | beginRemoveRows(QModelIndex(), 0, allTasks.count() - 1); |
| 238 | allTasks.clear(); |
| 239 | const IdCategoryConstIt cend = categories.constEnd(); |
| 240 | for (IdCategoryConstIt it = categories.constBegin(); it != cend; ++it) |
| 241 | categories[it.key()].clear(); |
| 242 | endRemoveRows(); |
| 243 | } else { |
| 244 | int index = 0; |
| 245 | int start = 0; |
| 246 | CategoryData &global = categories[Core::Id()]; |
| 247 | CategoryData &cat = categories[categoryId]; |
| 248 | |
| 249 | while (index < allTasks.count()) { |
| 250 | while (index < allTasks.count() && allTasks.at(index).category != categoryId) { |
| 251 | ++start; |
| 252 | ++index; |
| 253 | } |
| 254 | if (index == allTasks.count()) |
| 255 | break; |
| 256 | while (index < allTasks.count() && allTasks.at(index).category == categoryId) |
| 257 | ++index; |
| 258 | |
| 259 | // Index is now on the first non category |
| 260 | beginRemoveRows(QModelIndex(), start, index - 1); |
| 261 | |
| 262 | for (int i = start; i < index; ++i) { |
| 263 | global.removeTask(allTasks.at(i)); |
| 264 | cat.removeTask(allTasks.at(i)); |
| 265 | } |
| 266 | |
| 267 | allTasks.erase(allTasks.begin() + start, allTasks.begin() + index); |
| 268 | |
| 269 | endRemoveRows(); |
| 270 | index = start; |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | int TaskModel::getSizeOfLineNumber(const QFont &font) |
| 276 | { |
nothing calls this directly
no test coverage detected