forked from qt-creator/qt-creator
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: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/command.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
|
#include <utils/fsengine/fileiconprovider.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -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
|
QModelIndex ProxyModel::sibling(int row, int column, const QModelIndex &idx) const
|
||||||
{
|
{
|
||||||
return QAbstractItemModel::sibling(row, column, idx);
|
return QAbstractItemModel::sibling(row, column, idx);
|
||||||
|
@@ -50,6 +50,8 @@ public:
|
|||||||
|
|
||||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||||
|
|
||||||
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
|
||||||
// QAbstractProxyModel::sibling is broken in Qt 5
|
// QAbstractProxyModel::sibling is broken in Qt 5
|
||||||
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
|
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
|
||||||
// QAbstractProxyModel::supportedDragActions delegation is missing in Qt 5
|
// QAbstractProxyModel::supportedDragActions delegation is missing in Qt 5
|
||||||
|
Reference in New Issue
Block a user