diff options
-rw-r--r-- | examples/unityqmlmenumodel.qml | 37 | ||||
-rw-r--r-- | libqmenumodel/src/unitymenumodel.cpp | 4 | ||||
-rw-r--r-- | libqmenumodel/src/unitymenumodel.h | 3 |
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: |