diff options
-rw-r--r-- | src/corelib/kernel/qabstractitemmodel.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index cd17076..01440e4 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -467,19 +467,25 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel() return qEmptyModel(); } +namespace { + struct DefaultRoleNames : public QHash<int, QByteArray> + { + 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, q_defaultRoleNames); + const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames() { - static QHash<int,QByteArray> roleNames; - if (roleNames.isEmpty()) { - roleNames[Qt::DisplayRole] = "display"; - roleNames[Qt::DecorationRole] = "decoration"; - roleNames[Qt::EditRole] = "edit"; - roleNames[Qt::ToolTipRole] = "toolTip"; - roleNames[Qt::StatusTipRole] = "statusTip"; - roleNames[Qt::WhatsThisRole] = "whatsThis"; - } - - return roleNames; + return *q_defaultRoleNames(); } /*! |