aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libqmenumodel/src/qmenumodel.cpp23
-rw-r--r--libqmenumodel/src/qmenumodel.h1
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;