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. Change-Id: Id7c2a53fa91fb9638e9a08a746614a3f04da400f Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -307,6 +307,8 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
return entry->filePath().isEmpty() ? entry->displayName() : entry->filePath().toUserOutput();
|
return entry->filePath().isEmpty() ? entry->displayName() : entry->filePath().toUserOutput();
|
||||||
|
case DocumentModel::FilePathRole:
|
||||||
|
return entry->filePath().toVariant();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -69,6 +69,8 @@ public:
|
|||||||
static QList<IEditor *> editorsForDocuments(const QList<IDocument *> &entries);
|
static QList<IEditor *> editorsForDocuments(const QList<IDocument *> &entries);
|
||||||
static QList<IEditor *> editorsForOpenedDocuments();
|
static QList<IEditor *> editorsForOpenedDocuments();
|
||||||
|
|
||||||
|
static const int FilePathRole = Qt::UserRole + 23;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DocumentModel();
|
DocumentModel();
|
||||||
};
|
};
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core::Internal {
|
namespace Core::Internal {
|
||||||
|
|
||||||
class ProxyModel : public QAbstractProxyModel
|
class ProxyModel : public QAbstractProxyModel
|
||||||
@@ -253,8 +255,8 @@ QVariant ProxyModel::data(const QModelIndex &index, int role) const
|
|||||||
const QVariant sourceDecoration = QAbstractProxyModel::data(index, role);
|
const QVariant sourceDecoration = QAbstractProxyModel::data(index, role);
|
||||||
if (sourceDecoration.isValid())
|
if (sourceDecoration.isValid())
|
||||||
return sourceDecoration;
|
return sourceDecoration;
|
||||||
const QString fileName = QAbstractProxyModel::data(index, Qt::DisplayRole).toString();
|
const QVariant filePath = QAbstractProxyModel::data(index, DocumentModel::FilePathRole);
|
||||||
return Utils::FileIconProvider::icon(Utils::FilePath::fromString(fileName));
|
return FileIconProvider::icon(FilePath::fromVariant(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
return QAbstractProxyModel::data(index, role);
|
return QAbstractProxyModel::data(index, role);
|
||||||
|
Reference in New Issue
Block a user