diff options
author | Olivier Tilloy <olivier.tilloy@canonical.com> | 2012-11-19 16:06:21 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier.tilloy@canonical.com> | 2012-11-19 16:06:21 +0100 |
commit | 5d33dd54e1e0169b5df846957fb122e64997c8b1 (patch) | |
tree | 630f55a2d54556c3eef9c6149afd317fe3e9ff9e /libqmenumodel | |
parent | 1430572a4d1833c7b22733abd4899ba2e1cfaad5 (diff) | |
download | qmenumodel-5d33dd54e1e0169b5df846957fb122e64997c8b1.tar.gz qmenumodel-5d33dd54e1e0169b5df846957fb122e64997c8b1.tar.bz2 qmenumodel-5d33dd54e1e0169b5df846957fb122e64997c8b1.zip |
Reimplement roleNames() instead of using setRoleNames(…).
In Qt5, setRoleNames(…) is marked deprecated.
Diffstat (limited to 'libqmenumodel')
-rw-r--r-- | libqmenumodel/src/qmenumodel.cpp | 23 | ||||
-rw-r--r-- | libqmenumodel/src/qmenumodel.h | 1 |
2 files changed, 15 insertions, 9 deletions
diff --git a/libqmenumodel/src/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp index f0c2274..c59522d 100644 --- a/libqmenumodel/src/qmenumodel.cpp +++ b/libqmenumodel/src/qmenumodel.cpp @@ -41,15 +41,6 @@ QMenuModel::QMenuModel(GMenuModel *other, QObject *parent) m_menuModel(0), m_signalChangedId(0) { - static QHash<int, QByteArray> rolesNames; - if (rolesNames.empty()) { - rolesNames[Action] = "action"; - rolesNames[Label] = "label"; - rolesNames[LinkSection] = "linkSection"; - rolesNames[LinkSubMenu] = "linkSubMenu"; - rolesNames[Extra] = "extra"; - } - setRoleNames(rolesNames); setMenuModel(other); } @@ -102,6 +93,20 @@ void QMenuModel::clearModel() } /*! \internal */ +QHash<int, QByteArray> QMenuModel::roleNames() const +{ + static QHash<int, QByteArray> roles; + if (roles.isEmpty()) { + roles[Action] = "action"; + roles[Label] = "label"; + roles[LinkSection] = "linkSection"; + roles[LinkSubMenu] = "linkSubMenu"; + roles[Extra] = "extra"; + } + return roles; +} + +/*! \internal */ QVariant QMenuModel::data(const QModelIndex &index, int role) const { QVariant attribute; diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h index 22c30df..beec7ba 100644 --- a/libqmenumodel/src/qmenumodel.h +++ b/libqmenumodel/src/qmenumodel.h @@ -43,6 +43,7 @@ public: ~QMenuModel(); /* QAbstractItemModel */ + QHash<int, QByteArray> roleNames() const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QModelIndex parent (const QModelIndex &index) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; |