Don't insert multiple names for the same role

It doesn't make a lot of sense to have two names for the
same role. Use 'fileIcon' exclusively for the Qt::Decoration/
FileIconRole.

Change-Id: Icaa46ba4aa61efc56ba007a14bab5e59ea26cd35
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Lars Knoll 2018-12-03 13:36:49 +01:00 committed by Mårten Nordheim
parent dbb54805f6
commit 2faccdf9a6
4 changed files with 9 additions and 8 deletions

View File

@ -2077,7 +2077,8 @@ void QFileSystemModelPrivate::init()
#endif // filesystemwatcher
q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection);
roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
roleNames.insert(QFileSystemModel::FileIconRole,
QByteArrayLiteral("fileIcon")); // == Qt::decoration
roleNames.insert(QFileSystemModel::FilePathRole, QByteArrayLiteral("filePath"));
roleNames.insert(QFileSystemModel::FileNameRole, QByteArrayLiteral("fileName"));
roleNames.insert(QFileSystemModel::FilePermissions, QByteArrayLiteral("filePermissions"));

View File

@ -1162,7 +1162,7 @@ void QDirModelPrivate::init()
root.parent = 0;
root.info = QFileInfo();
clear(&root);
roleNames.insertMulti(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
roleNames.insert(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
roleNames.insert(QDirModel::FilePathRole, QByteArrayLiteral("filePath"));
roleNames.insert(QDirModel::FileNameRole, QByteArrayLiteral("fileName"));
}

View File

@ -1048,7 +1048,7 @@ void tst_QFileSystemModel::roleNames_data()
{
QTest::addColumn<int>("role");
QTest::addColumn<QByteArray>("roleName");
QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("decoration");
QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("fileIcon");
QTest::newRow("display") << int(Qt::DisplayRole) << QByteArray("display");
QTest::newRow("fileIcon") << int(QFileSystemModel::FileIconRole) << QByteArray("fileIcon");
QTest::newRow("filePath") << int(QFileSystemModel::FilePathRole) << QByteArray("filePath");
@ -1065,8 +1065,8 @@ void tst_QFileSystemModel::roleNames()
QVERIFY(roles.contains(role));
QFETCH(QByteArray, roleName);
QList<QByteArray> values = roles.values(role);
QVERIFY(values.contains(roleName));
QCOMPARE(roles.values(role).count(), 1);
QCOMPARE(roles.value(role), roleName);
}
static inline QByteArray permissionRowName(bool readOnly, int permission)

View File

@ -697,7 +697,7 @@ void tst_QDirModel::roleNames_data()
{
QTest::addColumn<int>("role");
QTest::addColumn<QByteArray>("roleName");
QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("decoration");
QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("fileIcon");
QTest::newRow("display") << int(Qt::DisplayRole) << QByteArray("display");
QTest::newRow("fileIcon") << int(QDirModel::FileIconRole) << QByteArray("fileIcon");
QTest::newRow("filePath") << int(QDirModel::FilePathRole) << QByteArray("filePath");
@ -713,8 +713,8 @@ void tst_QDirModel::roleNames()
QVERIFY(roles.contains(role));
QFETCH(QByteArray, roleName);
QList<QByteArray> values = roles.values(role);
QVERIFY(values.contains(roleName));
QCOMPARE(roles.values(role).count(), 1);
QCOMPARE(roles.value(role), roleName);
}