From 98dc036587accfd2562cb628dfc7d061117e46ed Mon Sep 17 00:00:00 2001 From: Michael Spencer Date: Wed, 28 Jan 2015 20:40:41 -0600 Subject: [PATCH] Add List Item demo, working on a Simple Menu list item --- demo/ListItemsDemo.qml | 37 +++++++++++++++++ demo/main.qml | 2 +- modules/Material/ListItems/SimpleMenu.qml | 48 +++++++++++++++++++++++ modules/Material/ListItems/qmldir | 1 + 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 demo/ListItemsDemo.qml create mode 100644 modules/Material/ListItems/SimpleMenu.qml diff --git a/demo/ListItemsDemo.qml b/demo/ListItemsDemo.qml new file mode 100644 index 00000000..5edf238a --- /dev/null +++ b/demo/ListItemsDemo.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 +import Material 0.1 +import Material.ListItems 0.1 as ListItem +import Material.Extras 0.1 + +Item { + View { + anchors { + fill: parent + margins: units.dp(32) + } + + elevation: 1 + + Column { + anchors.fill: parent + + ListItem.Header { + text: "Section header" + } + + ListItem.Standard { + text: "Standard list item" + } + + ListItem.Subtitled { + text: "Subtitled list item" + subText: "With some subtext!" + } + + ListItem.SimpleMenu { + text: "Subtitled list item" + model: ["A", "B", "C"] + } + } + } +} diff --git a/demo/main.qml b/demo/main.qml index 05ebe82c..faa47770 100644 --- a/demo/main.qml +++ b/demo/main.qml @@ -11,7 +11,7 @@ ApplicationWindow { initialPage: page - property var components: ["Button", "Switch", "Radio Button", "Slider", "Progress Bar", "Icon", "TextField", "Page Stack"] + property var components: ["Button", "Switch", "Radio Button", "Slider", "Progress Bar", "Icon", "TextField", "Page Stack", "List Items"] property string selectedComponent: components[0] Page { diff --git a/modules/Material/ListItems/SimpleMenu.qml b/modules/Material/ListItems/SimpleMenu.qml new file mode 100644 index 00000000..ef4cf521 --- /dev/null +++ b/modules/Material/ListItems/SimpleMenu.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 +import Material 0.1 + +Subtitled { + id: listItem + + property alias model: listView.model + property alias selectedIndex: listView.currentIndex + + subText: listView.currentItem.text + + onTriggered: menu.open(listItem, units.dp(16), 0) + + Dropdown { + id: menu + + anchor: Item.TopLeft + + width: Math.max(units.dp(56 * 2), Math.min(listItem.width - 2 * x, listView.contentWidth)) + height: Math.min(10 * units.dp(48) + units.dp(16), listView.contentHeight + units.dp(16)) + + ListView { + id: listView + + anchors { + left: parent.left + right: parent.right + top: parent.top + topMargin: units.dp(8) + } + + interactive: false + height: contentHeight + + delegate: Standard { + id: delegateItem + + text: modelData + + onTriggered: { + listView.currentIndex = index + menu.close() + } + } + } + } +} + diff --git a/modules/Material/ListItems/qmldir b/modules/Material/ListItems/qmldir index 0cabda18..14a51811 100644 --- a/modules/Material/ListItems/qmldir +++ b/modules/Material/ListItems/qmldir @@ -1,5 +1,6 @@ module Material.ListItems BaseListItem 0.1 BaseListItem.qml Header 0.1 Header.qml +SimpleMenu 0.1 SimpleMenu.qml Standard 0.1 Standard.qml Subtitled 0.1 Subtitled.qml