From 13f5367611af2084eca5202428f1e0cacec9f0bf Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 16 Oct 2023 15:07:08 +0200 Subject: [PATCH] Core: Use icon based on document's full path This makes a difference when one wants to e.g. mark non existing files. Change-Id: Id7c2a53fa91fb9638e9a08a746614a3f04da400f Reviewed-by: Eike Ziller --- src/plugins/coreplugin/editormanager/documentmodel.cpp | 2 ++ src/plugins/coreplugin/editormanager/documentmodel.h | 2 ++ src/plugins/coreplugin/editormanager/openeditorsview.cpp | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp index e8183401bf6..d7eb164dd2e 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.cpp +++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp @@ -307,6 +307,8 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const return QVariant(); case Qt::ToolTipRole: return entry->filePath().isEmpty() ? entry->displayName() : entry->filePath().toUserOutput(); + case DocumentModel::FilePathRole: + return entry->filePath().toVariant(); default: break; } diff --git a/src/plugins/coreplugin/editormanager/documentmodel.h b/src/plugins/coreplugin/editormanager/documentmodel.h index 6c7d0f0be32..3ac2a52c202 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.h +++ b/src/plugins/coreplugin/editormanager/documentmodel.h @@ -69,6 +69,8 @@ public: static QList editorsForDocuments(const QList &entries); static QList editorsForOpenedDocuments(); + static const int FilePathRole = Qt::UserRole + 23; + private: DocumentModel(); }; diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index ebf2d751ec9..34e58565a94 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -17,6 +17,8 @@ #include #include +using namespace Utils; + namespace Core::Internal { class ProxyModel : public QAbstractProxyModel @@ -253,8 +255,8 @@ QVariant ProxyModel::data(const QModelIndex &index, int role) const const QVariant sourceDecoration = QAbstractProxyModel::data(index, role); if (sourceDecoration.isValid()) return sourceDecoration; - const QString fileName = QAbstractProxyModel::data(index, Qt::DisplayRole).toString(); - return Utils::FileIconProvider::icon(Utils::FilePath::fromString(fileName)); + const QVariant filePath = QAbstractProxyModel::data(index, DocumentModel::FilePathRole); + return FileIconProvider::icon(FilePath::fromVariant(filePath)); } return QAbstractProxyModel::data(index, role);