QAbstractItemModel: don't inherit QHash just to add elements

Now that we can depend on C++11, use _WITH_ARGS and std::initializer_list.

Saves ~400B in text size on optimized AMD64 GCC 9.1 Linux LTO builds.

Change-Id: I37fce1c63a5f74f6dfc059febf0152ac93c8be7f
Reviewed-by: David Faure <david.faure@kdab.com>
bb10
Marc Mutz 2019-07-13 20:33:49 +02:00
parent c5d6b263c2
commit aeaf5d87ed
1 changed files with 9 additions and 14 deletions

View File

@ -532,21 +532,16 @@ void QAbstractItemModelPrivate::invalidatePersistentIndex(const QModelIndex &ind
}
}
namespace {
struct DefaultRoleNames : public QHash<int, QByteArray>
using DefaultRoleNames = QHash<int, QByteArray>;
Q_GLOBAL_STATIC_WITH_ARGS(DefaultRoleNames, qDefaultRoleNames, (
{
DefaultRoleNames() {
(*this)[Qt::DisplayRole] = "display";
(*this)[Qt::DecorationRole] = "decoration";
(*this)[Qt::EditRole] = "edit";
(*this)[Qt::ToolTipRole] = "toolTip";
(*this)[Qt::StatusTipRole] = "statusTip";
(*this)[Qt::WhatsThisRole] = "whatsThis";
}
};
}
Q_GLOBAL_STATIC(DefaultRoleNames, qDefaultRoleNames)
{ Qt::DisplayRole, "display" },
{ Qt::DecorationRole, "decoration" },
{ Qt::EditRole, "edit" },
{ Qt::ToolTipRole, "toolTip" },
{ Qt::StatusTipRole, "statusTip" },
{ Qt::WhatsThisRole, "whatsThis" },
}))
const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames()
{