aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-06-04 21:05:40 -0400
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-06-04 21:05:40 -0400
commit00885c1ddd04819c44d6a0ca2c7f2af8a1298a97 (patch)
tree049e560e1c7086d0cbf045a647b47e8c588e813c
parent2a01b1cba8af5891bac632683286951e2c3f95f0 (diff)
downloadqmenumodel-00885c1ddd04819c44d6a0ca2c7f2af8a1298a97.tar.gz
qmenumodel-00885c1ddd04819c44d6a0ca2c7f2af8a1298a97.tar.bz2
qmenumodel-00885c1ddd04819c44d6a0ca2c7f2af8a1298a97.zip
unitymenumodel: expose isSeparator
-rw-r--r--examples/unityqmlmenumodel.qml37
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp4
-rw-r--r--libqmenumodel/src/unitymenumodel.h3
3 files changed, 33 insertions, 11 deletions
diff --git a/examples/unityqmlmenumodel.qml b/examples/unityqmlmenumodel.qml
index 257866d..d38d6e5 100644
--- a/examples/unityqmlmenumodel.qml
+++ b/examples/unityqmlmenumodel.qml
@@ -18,16 +18,33 @@ Item {
anchors.margins: 10
spacing: 3
model: menu
- delegate: Rectangle {
- width: parent.width
- height: 40
- color: "#ddd"
- Text {
- anchors.fill: parent
- anchors.margins: 5
- verticalAlignment: Text.AlignVCenter
- color: sensitive ? "black" : "#aaa";
- text: label
+
+ delegate: Loader {
+ sourceComponent: isSeparator ? separator : menuitem;
+
+ Component {
+ id: separator
+ Rectangle {
+ width: parent.width
+ height: 4
+ color: "blue"
+ }
+ }
+
+ Component {
+ id: menuitem
+ Rectangle {
+ width: parent.width
+ height: 40
+ color: "#ddd"
+ Text {
+ anchors.fill: parent
+ anchors.margins: 5
+ verticalAlignment: Text.AlignVCenter
+ color: sensitive ? "black" : "#aaa";
+ text: label
+ }
+ }
}
}
}
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index 926d2f1..336b72a 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -119,6 +119,9 @@ QVariant UnityMenuModelPrivate::data(int position, int role)
case UnityMenuModel::SensitiveRole:
return gtk_menu_tracker_item_get_sensitive (item);
+ case UnityMenuModel::IsSeparatorRole:
+ return gtk_menu_tracker_item_get_is_separator (item);
+
default:
return QVariant();
}
@@ -275,6 +278,7 @@ QHash<int, QByteArray> UnityMenuModel::roleNames() const
names[LabelRole] = "label";
names[ActionRole] = "action";
names[SensitiveRole] = "sensitive";
+ names[IsSeparatorRole] = "isSeparator";
return names;
}
diff --git a/libqmenumodel/src/unitymenumodel.h b/libqmenumodel/src/unitymenumodel.h
index 12a5891..75af13a 100644
--- a/libqmenumodel/src/unitymenumodel.h
+++ b/libqmenumodel/src/unitymenumodel.h
@@ -29,7 +29,8 @@ public:
enum MenuRoles {
ActionRole = Qt::DisplayRole + 1,
LabelRole,
- SensitiveRole
+ SensitiveRole,
+ IsSeparatorRole
};
public: