From 373b9f8b310254c526ca12a003e066d085655e5d Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 11 Aug 2022 23:32:14 +0200 Subject: [PATCH] Core: Show document icons the "Open Documents" view Having the document icon looks more natural than having just the text of the document. Change-Id: I7cb6fda6b4241c0d124c18c3c74dc4a1e614b02d Reviewed-by: Reviewed-by: Alessandro Portale --- .../coreplugin/editormanager/openeditorsview.cpp | 11 +++++++++++ .../coreplugin/editormanager/openeditorsview.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index e4e4a81c081..e154a05bb4d 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -223,6 +224,16 @@ void ProxyModel::setSourceModel(QAbstractItemModel *sm) } } +QVariant ProxyModel::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DecorationRole && index.column() == 0) { + const QString fileName = QAbstractProxyModel::data(index, Qt::DisplayRole).toString(); + return Utils::FileIconProvider::icon(Utils::FilePath::fromString(fileName)); + } + + return QAbstractProxyModel::data(index, role); +} + QModelIndex ProxyModel::sibling(int row, int column, const QModelIndex &idx) const { return QAbstractItemModel::sibling(row, column, idx); diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.h b/src/plugins/coreplugin/editormanager/openeditorsview.h index 33b50c58c09..86acfa92e48 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.h +++ b/src/plugins/coreplugin/editormanager/openeditorsview.h @@ -50,6 +50,8 @@ public: void setSourceModel(QAbstractItemModel *sourceModel) override; + QVariant data(const QModelIndex &index, int role) const override; + // QAbstractProxyModel::sibling is broken in Qt 5 QModelIndex sibling(int row, int column, const QModelIndex &idx) const override; // QAbstractProxyModel::supportedDragActions delegation is missing in Qt 5