| 355 | } |
| 356 | |
| 357 | void RepoStatusModel::updateState(const ProjectItem& pItem, const VcsStatusInfo& status) |
| 358 | { |
| 359 | Q_ASSERT(pItem.project); |
| 360 | |
| 361 | /* To make the code cleaner, we remove the item from the |
| 362 | * model first before adding it again to the correct areas */ |
| 363 | removeUrl(status.url(), pItem.project); |
| 364 | |
| 365 | QString path = ICore::self()->projectController()->prettyFileName(status.url(), IProjectController::FormatPlain); |
| 366 | int pos = path.indexOf(QLatin1Char(':')); |
| 367 | if (pos > -1) |
| 368 | path = path.mid(pos + 1); |
| 369 | QMimeType mime = status.url().isLocalFile() |
| 370 | ? QMimeDatabase().mimeTypeForFile(status.url().toLocalFile(), QMimeDatabase::MatchExtension) |
| 371 | : QMimeDatabase().mimeTypeForUrl(status.url()); |
| 372 | QIcon icon = QIcon::fromTheme(mime.iconName()); |
| 373 | |
| 374 | QStandardItem* item = nullptr; |
| 375 | GitPlugin::ExtendedState state = (GitPlugin::ExtendedState)status.extendedState(); |
| 376 | QString stateStr = extendedStateToStr(state); |
| 377 | |
| 378 | if (showInIndex(state)) { |
| 379 | item = new QStandardItem(icon, path); |
| 380 | item->setData(Index, AreaRole); |
| 381 | item->setData(status.url(), UrlRole); |
| 382 | item->setToolTip(status.url().path() + i18n(" (staged)")); |
| 383 | pItem.index->appendRow(item); |
| 384 | } |
| 385 | |
| 386 | if (showInWorkTree(state)) { |
| 387 | item = new QStandardItem(icon, path); |
| 388 | item->setData(WorkTree, AreaRole); |
| 389 | item->setData(status.url(), UrlRole); |
| 390 | item->setToolTip(status.url().path() + i18n(" (unstaged)")); |
| 391 | pItem.worktree->appendRow(item); |
| 392 | } |
| 393 | |
| 394 | if (showInConflicts(state)) { |
| 395 | item = new QStandardItem(icon, path); |
| 396 | item->setData(Conflicts, AreaRole); |
| 397 | item->setData(status.url(), UrlRole); |
| 398 | item->setToolTip(status.url().path() + i18n(" (conflicts)")); |
| 399 | pItem.conflicts->appendRow(item); |
| 400 | } |
| 401 | |
| 402 | if (showInUntracked(state)) { |
| 403 | item = new QStandardItem(icon, path); |
| 404 | item->setData(Untracked, AreaRole); |
| 405 | item->setData(status.url(), UrlRole); |
| 406 | item->setToolTip(status.url().path() + i18n(" (untracked)")); |
| 407 | pItem.untracked->appendRow(item); |
| 408 | } |
| 409 | |
| 410 | if (item) { |
| 411 | item->setData(state, StatusRole); |
| 412 | item->setData(stateStr, ReadableStatusRole); |
| 413 | item->setData(pItem.project->data(ProjectUrlRole), ProjectUrlRole); |
| 414 | } |
nothing calls this directly
no test coverage detected