aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-07-26 16:29:32 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-07-26 16:29:32 +0200
commit16b480d00dd5c1fba5252e728cfc71aaa5cc916f (patch)
treef97f1b0b29a8105f426974f74454fbf24728c5cb /libqmenumodel/src
parentd57caa61f787c4bd7cb0823eadbbc5d84f542f0a (diff)
downloadqmenumodel-16b480d00dd5c1fba5252e728cfc71aaa5cc916f.tar.gz
qmenumodel-16b480d00dd5c1fba5252e728cfc71aaa5cc916f.tar.bz2
qmenumodel-16b480d00dd5c1fba5252e728cfc71aaa5cc916f.zip
unitymenumodel: add get()
Diffstat (limited to 'libqmenumodel/src')
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp12
-rw-r--r--libqmenumodel/src/unitymenumodel.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index 114c985..d40c813 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -61,6 +61,7 @@ public:
guint nameWatchId;
QVariantMap actions;
QByteArray menuObjectPath;
+ QHash<QByteArray, int> roles;
static void nameAppeared(GDBusConnection *connection, const gchar *name, const gchar *owner, gpointer user_data);
static void nameVanished(GDBusConnection *connection, const gchar *name, gpointer user_data);
@@ -542,3 +543,14 @@ bool UnityMenuModel::loadExtendedAttributes(int position, const QVariantMap &sch
g_object_set_qdata_full (G_OBJECT (item), unity_menu_item_extended_attributes_quark (),
extendedAttrs, freeExtendedAttrs);
}
+
+QVariant UnityMenuModel::get(int row, const QByteArray &role)
+{
+ if (priv->roles.isEmpty()) {
+ QHash<int, QByteArray> names = roleNames();
+ Q_FOREACH (int role, names.keys())
+ priv->roles.insert(names[role], role);
+ }
+
+ return this->data(this->index(row, 0), priv->roles[role]);
+}
diff --git a/libqmenumodel/src/unitymenumodel.h b/libqmenumodel/src/unitymenumodel.h
index 9151217..396eea3 100644
--- a/libqmenumodel/src/unitymenumodel.h
+++ b/libqmenumodel/src/unitymenumodel.h
@@ -50,6 +50,7 @@ public:
Q_INVOKABLE QObject * submenu(int position);
Q_INVOKABLE bool loadExtendedAttributes(int position, const QVariantMap &schema);
+ Q_INVOKABLE QVariant get(int row, const QByteArray &role);
Q_SIGNALS:
void busNameChanged(const QByteArray &name);