Skip to content

Commit

Permalink
GenericItems.cpp: another fix for the display of files
Browse files Browse the repository at this point in the history
For some reason, the full path of file was dispplayed in the project
display. This is another fix for this. Weird, I think I already fixed
this by now.
  • Loading branch information
diegoiast committed Jan 28, 2025
1 parent d37f07f commit 345f506
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugins/ProjectManager/GenericItems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ QVariant DirectoryModel::data(const QModelIndex &index, int role) const {
QString DirectoryModel::displayForItem(size_t i) const {
auto fileName = fileList.at(i);
auto path = [fileName, this]() {
for (auto d : directoryList) {
if (QDir::toNativeSeparators(fileName).startsWith(d)) {
return d;
for (auto &d : directoryList) {
auto fixedFileName = QDir::toNativeSeparators(fileName);
auto fixedDirName = QDir::toNativeSeparators(d);
if (fixedFileName.startsWith(fixedDirName)) {
return fixedDirName;
}
}
return QString{};
Expand All @@ -64,7 +66,7 @@ QString DirectoryModel::displayForItem(size_t i) const {
if (!path.endsWith('/') && !path.endsWith('\\')) {
l++;
}
return QDir::toNativeSeparators(fileName.remove(0, l));
return fileName.remove(0, l);
}

QString DirectoryModel::fileNameForItem(size_t i) const {
Expand Down

0 comments on commit 345f506

Please sign in to comment.