forked from qt-creator/qt-creator
Core: Use icon based on document's full path
This makes a difference when one wants to e.g. mark non existing files.
Fixes: QTCREATORBUG-29999
Change-Id: Id7c2a53fa91fb9638e9a08a746614a3f04da400f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
(cherry picked from commit 13f5367611
)
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -69,6 +69,8 @@ public:
|
||||
static QList<IEditor *> editorsForDocuments(const QList<IDocument *> &entries);
|
||||
static QList<IEditor *> editorsForOpenedDocuments();
|
||||
|
||||
static const int FilePathRole = Qt::UserRole + 23;
|
||||
|
||||
private:
|
||||
DocumentModel();
|
||||
};
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user