aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-09-12 16:28:34 -0300
committerRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-09-12 16:28:34 -0300
commitd2e99cfb78dfcdad000faf9c1c7d4e5a40d53f95 (patch)
treee177d5cffa1cd97a82c294449f9eb676577b0dbf /src
parent48e027ef11b7b09c20a6362e1768f909ea250815 (diff)
downloadqmenumodel-d2e99cfb78dfcdad000faf9c1c7d4e5a40d53f95.tar.gz
qmenumodel-d2e99cfb78dfcdad000faf9c1c7d4e5a40d53f95.tar.bz2
qmenumodel-d2e99cfb78dfcdad000faf9c1c7d4e5a40d53f95.zip
Parse extra properties name to remove 'x-' and replace '-' to '_'.
Diffstat (limited to 'src')
-rw-r--r--src/common/qmenumodel.cpp13
-rw-r--r--src/common/qmenumodel.h1
2 files changed, 13 insertions, 1 deletions
diff --git a/src/common/qmenumodel.cpp b/src/common/qmenumodel.cpp
index ffb3fb6..af29ded 100644
--- a/src/common/qmenumodel.cpp
+++ b/src/common/qmenumodel.cpp
@@ -179,6 +179,16 @@ QVariant QMenuModel::getLink(const QModelIndex &index,
}
/*! \internal */
+QString QMenuModel::parseExtraPropertyName(const QString &name) const
+{
+ QString newName(name);
+ if (name.startsWith("x-")) {
+ newName = name.right(name.length() - 2);
+ }
+ return newName.replace("-", "_");
+}
+
+/*! \internal */
QVariant QMenuModel::getExtraProperties(const QModelIndex &index) const
{
GMenuAttributeIter *iter = g_menu_model_iterate_item_attributes(m_menuModel, index.row());
@@ -191,7 +201,8 @@ QVariant QMenuModel::getExtraProperties(const QModelIndex &index) const
GVariant *value = NULL;
while (g_menu_attribute_iter_get_next (iter, &attrName, &value)) {
if (strncmp("x-", attrName, 2) == 0) {
- extra->setProperty(attrName, Converter::parseGVariant(value));
+
+ extra->setProperty(parseExtraPropertyName(attrName).toLatin1(), Converter::parseGVariant(value));
}
}
diff --git a/src/common/qmenumodel.h b/src/common/qmenumodel.h
index e102f72..ba5696d 100644
--- a/src/common/qmenumodel.h
+++ b/src/common/qmenumodel.h
@@ -56,6 +56,7 @@ private:
QVariant getStringAttribute(const QModelIndex &index, const QString &attribute) const;
QVariant getLink(const QModelIndex &index, const QString &linkName) const;
QVariant getExtraProperties(const QModelIndex &index) const;
+ QString parseExtraPropertyName(const QString &name) const;
static void onItemsChanged(GMenuModel *model, gint position, gint removed, gint added, gpointer data);
};