aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/modelviews
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-09-20 15:58:05 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-22 00:23:56 +0200
commit7ecce2cc0e33bc6b1aa052163f9d6c1365b93b27 (patch)
tree19a241c55900325c117aefb1ef4f88f83505a1cf /examples/declarative/modelviews
parentb4001eacd6472a3515a0eb7d80e845bd733d5bcd (diff)
Additional ListView section header placement options
Add a section.labelPositioning property which can be a combination of: - ViewSection.InlineLabels - section labels are shown inline between the item delegates separating sections (default). - ViewSection.CurrentLabelAtStart - the current section label sticks to the start of the view as it is moved. - ViewSection.NextLabelAtEnd - the next section label (beyond all visible sections) sticks to the end of the view as it is moved. Task-number: QTBUG-12880 Change-Id: I4601828337412bd3a83769c9b8df3f6d4d7474b8 Reviewed-on: http://codereview.qt-project.org/5192 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'examples/declarative/modelviews')
-rw-r--r--examples/declarative/modelviews/listview/content/ToggleButton.qml18
-rw-r--r--examples/declarative/modelviews/listview/sections.qml54
2 files changed, 65 insertions, 7 deletions
diff --git a/examples/declarative/modelviews/listview/content/ToggleButton.qml b/examples/declarative/modelviews/listview/content/ToggleButton.qml
new file mode 100644
index 0000000000..2d8221e915
--- /dev/null
+++ b/examples/declarative/modelviews/listview/content/ToggleButton.qml
@@ -0,0 +1,18 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ property alias label: text.text
+ property bool active: false
+ signal toggled
+ width: 149
+ height: 30
+ radius: 3
+ color: active ? "green" : "lightgray"
+ border.width: 1
+ Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { active = !active; root.toggled() }
+ }
+}
diff --git a/examples/declarative/modelviews/listview/sections.qml b/examples/declarative/modelviews/listview/sections.qml
index 09e58be5d6..4496567377 100644
--- a/examples/declarative/modelviews/listview/sections.qml
+++ b/examples/declarative/modelviews/listview/sections.qml
@@ -42,22 +42,33 @@
// the ListView.section attached property.
import QtQuick 2.0
+import "content"
-//! [0]
Rectangle {
id: container
- width: 200
- height: 250
+ width: 300
+ height: 360
ListModel {
id: animalsModel
+ ListElement { name: "Ant"; size: "Tiny" }
+ ListElement { name: "Flea"; size: "Tiny" }
ListElement { name: "Parrot"; size: "Small" }
ListElement { name: "Guinea pig"; size: "Small" }
+ ListElement { name: "Rat"; size: "Small" }
+ ListElement { name: "Butterfly"; size: "Small" }
ListElement { name: "Dog"; size: "Medium" }
ListElement { name: "Cat"; size: "Medium" }
- ListElement { name: "Elephant"; size: "Large" }
+ ListElement { name: "Pony"; size: "Medium" }
+ ListElement { name: "Koala"; size: "Medium" }
+ ListElement { name: "Horse"; size: "Large" }
+ ListElement { name: "Tiger"; size: "Large" }
+ ListElement { name: "Giraffe"; size: "Large" }
+ ListElement { name: "Elephant"; size: "Huge" }
+ ListElement { name: "Whale"; size: "Huge" }
}
+//! [0]
// The delegate for each section header
Component {
id: sectionHeading
@@ -69,19 +80,48 @@ Rectangle {
Text {
text: section
font.bold: true
+ font.pixelSize: 20
}
}
}
ListView {
- anchors.fill: parent
+ id: view
+ anchors.top: parent.top
+ anchors.bottom: buttonBar.top
+ width: parent.width
model: animalsModel
- delegate: Text { text: name }
+ delegate: Text { text: name; font.pixelSize: 18 }
section.property: "size"
section.criteria: ViewSection.FullString
section.delegate: sectionHeading
}
-}
//! [0]
+ Row {
+ id: buttonBar
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 1
+ spacing: 1
+ ToggleButton {
+ label: "CurrentLabelAtStart"
+ onToggled: {
+ if (active)
+ view.section.labelPositioning |= ViewSection.CurrentLabelAtStart
+ else
+ view.section.labelPositioning &= ~ViewSection.CurrentLabelAtStart
+ }
+ }
+ ToggleButton {
+ label: "NextLabelAtEnd"
+ onToggled: {
+ if (active)
+ view.section.labelPositioning |= ViewSection.NextLabelAtEnd
+ else
+ view.section.labelPositioning &= ~ViewSection.NextLabelAtEnd
+ }
+ }
+ }
+}
+