summaryrefslogtreecommitdiffstats
path: root/src/controls/qtmenu.cpp
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2013-03-20 15:22:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-20 17:16:42 +0100
commitbdc872955933aaf93cdd434cc17cc29630600b88 (patch)
treea5c40c6bb82a30f7e1c31dde8ce3ec33ac61ee1a /src/controls/qtmenu.cpp
parent8d5e9969b54f80e646cc2b9fcc92e1f36da6d128 (diff)
Menu: Update API, auto-tests
Add 'type' property to QtMenuBase (not exposed to QML explicitly, but is the base class for all things menu). Useful to inspect menu items after creation, for instance. Also, Menu gets addSeparator() and addMenu() functions. Since the Iterator type has been merged to QML, tst_menu now uses it. Change-Id: I4a2f43ecce6671885e523d720e4e1315eca8616e Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls/qtmenu.cpp')
-rw-r--r--src/controls/qtmenu.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/controls/qtmenu.cpp b/src/controls/qtmenu.cpp
index 150efcee1..dbcbe1137 100644
--- a/src/controls/qtmenu.cpp
+++ b/src/controls/qtmenu.cpp
@@ -123,6 +123,38 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \qmlmethod MenuItem Menu::addItem(text)
+
+ Adds an item to the menu. Returns the newly created \l MenuItem.
+*/
+
+/*!
+ \qmlmethod MenuSeparator Menu::addSeparator()
+
+ Adds a separator to the menu. Returns the newly created \l MenuSeparator.
+*/
+
+/*!
+ \qmlmethod void Menu::insertItem(before, item)
+
+ Inserts the \c item at the index \c before in the current menu.
+ In this case, \c item can be either a \l MenuItem, a \l MenuSeparator,
+ or a \l Menu.
+
+ \sa removeItem()
+*/
+
+/*!
+ \qmlmethod void Menu::removeItem(item)
+
+ Removes the \c item from the menu.
+ In this case, \c item can be either a \l MenuItem, a \l MenuSeparator,
+ or a \l Menu.
+
+ \sa insertItem()
+*/
+
+/*!
\qmlproperty var Menu::model
*/
@@ -402,6 +434,13 @@ QtMenuItem *QtMenu::addItem(QString title)
return item;
}
+QtMenuSeparator *QtMenu::addSeparator()
+{
+ QtMenuSeparator *item = new QtMenuSeparator(this);
+ insertItem(m_itemsCount, item);
+ return item;
+}
+
void QtMenu::insertItem(int index, QtMenuBase *menuItem)
{
if (!menuItem)