| 98 | }; |
| 99 | |
| 100 | static void createFileTree(QStandardItem *parent, const QString &basePath, const QList<GitUtils::StatusItem> &files) |
| 101 | { |
| 102 | QDir dir(basePath); |
| 103 | const QString dirPath = dir.path() + u'/'; |
| 104 | QHash<QString, QStandardItem *> dir2Item; |
| 105 | dir2Item[QString()] = parent; |
| 106 | for (const auto &file : std::as_const(files)) { |
| 107 | const QString filePath = QString::fromUtf8(file.file); |
| 108 | /** |
| 109 | * cheap file name computation |
| 110 | * we do this A LOT, QFileInfo is very expensive just for this operation |
| 111 | */ |
| 112 | const int slashIndex = filePath.lastIndexOf(u'/'); |
| 113 | const QString fileName = (slashIndex < 0) ? filePath : filePath.mid(slashIndex + 1); |
| 114 | const QString filePathName = (slashIndex < 0) ? QString() : filePath.left(slashIndex); |
| 115 | const QString fullFilePath = dirPath + filePath; |
| 116 | |
| 117 | /** |
| 118 | * construct the item with right directory prefix |
| 119 | * already hang in directories in tree |
| 120 | */ |
| 121 | auto *fileItem = new KateProjectItem(KateProjectItem::File, fileName, fullFilePath); |
| 122 | fileItem->setData(file.statusChar, Qt::UserRole + 1); |
| 123 | fileItem->setData(file.linesAdded, Qt::UserRole + 2); |
| 124 | fileItem->setData(file.linesRemoved, Qt::UserRole + 3); |
| 125 | |
| 126 | // put in our item to the right directory parent |
| 127 | KateProjectWorker::directoryParent(dir, dir2Item, filePathName)->appendRow(fileItem); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | CompareBranchesView::CompareBranchesView(QWidget *parent, const QString &gitPath, QString fromB, const QString &toBr, const QList<GitUtils::StatusItem> &items) |
| 132 | : QWidget(parent) |
no test coverage detected