on xenial help sign in
use ListView
commitc904ef82d3be528a5809b1bbd7a0bb63569db04d authorLukáš Tinkl <lukas.tinkl@canonical.com> dateThu 16 Jul 2015, 01:07 (11 years ago) parent4752bd8
1 file changed+35−62
qml/Wizard/Pages/50-timezone.qml+35−62
qml/Wizard/Pages/50-timezone.qml+35−62
@@ -48,28 +48,24 @@ LocalComponents.Page {
4848 ListItem {
4949 id: tz
5050 objectName: "tz"
51− property QtObject tzData: null
52− readonly property bool currentTz: !!tzData ? selectedTimeZone === tzData.id : false
53−
54− Label {
55− id: cityLabel
56− text: !!tzData ? tzData.city : ""
57− anchors.left: parent.left
58− anchors.top: parent.top
59− anchors.topMargin: units.gu(3)
60− font.weight: tz.currentTz ? Font.Normal : Font.Light
61− fontSize: "medium"
62− color: "#525252"
63− }
64− Label {
65− id: timeLabel
66− text: !!tzData ? tzData.time + " " + tzData.abbreviation : ""
67− anchors.left: parent.left
68− anchors.bottom: parent.bottom
69− anchors.bottomMargin: units.gu(3)
70− font.weight: tz.currentTz ? Font.Normal : Font.Light
71− fontSize: "small"
72− color: "#525252"
51+ readonly property bool currentTz: !!id ? selectedTimeZone === id : false
52+
53+ Column {
54+ anchors.verticalCenter: parent.verticalCenter
55+ Label {
56+ id: cityLabel
57+ text: !!city ? city : ""
58+ font.weight: tz.currentTz ? Font.Normal : Font.Light
59+ fontSize: "medium"
60+ color: "#525252"
61+ }
62+ Label {
63+ id: timeLabel
64+ text: !!time ? time + " " + abbreviation : ""
65+ font.weight: tz.currentTz ? Font.Normal : Font.Light
66+ fontSize: "small"
67+ color: "#525252"
68+ }
7369 }
7470 Image {
7571 anchors {
@@ -84,18 +80,12 @@ LocalComponents.Page {
8480 }
8581
8682 onClicked: {
87− tzModel.selectedZoneId = tzData.id
83+ tzModel.selectedZoneId = id
8884 print("Selected tz: " + selectedTimeZone)
8985 }
9086 }
9187 }
9288
93− ActivityIndicator {
94− id: busyIndicator
95− anchors.centerIn: parent
96− running: true
97− }
98−
9989 Column {
10090 id: column
10191 anchors.fill: content
@@ -109,41 +99,24 @@ LocalComponents.Page {
10999 color: UbuntuColors.lightGrey
110100 }
111101
112− Flickable {
113− anchors.left: parent.left
114− anchors.right: parent.right
115− height: column.height - searchField.height - column.spacing - topMargin
116− contentHeight: contentItem.childrenRect.height
117− clip: true
118− flickDeceleration: 1500 * units.gridUnit / 8
119− maximumFlickVelocity: 2500 * units.gridUnit / 8
120− boundsBehavior: (contentHeight > height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
102+ ListView {
103+ id: tzList;
121104
122− Column {
123− anchors.left: parent.left
124− anchors.right: parent.right
125−
126− Repeater {
127− id: tzList
128− model: tzFilterModel
129− delegate: Loader {
130− id: loader
131− anchors.left: !!parent ? parent.left : undefined
132− anchors.right: !!parent ? parent.right : undefined
133− height: units.gu(11)
134− asynchronous: true
135− sourceComponent: tzComponent
136−
137− onLoaded: {
138− item.tzData = Qt.binding(function() { return model; });
139− busyIndicator.running = false
140− }
141− }
142− onCountChanged: {
143− print("Displaying " + tzList.count + " items")
144− }
145− }
105+ boundsBehavior: Flickable.StopAtBounds;
106+ clip: true;
107+ currentIndex: -1
108+ snapMode: ListView.SnapToItem
109+
110+ anchors {
111+ left: parent.left;
112+ right: parent.right;
146113 }
114+
115+ height: column.height - searchField.height - column.spacing - topMargin
116+
117+ model: tzFilterModel
118+
119+ delegate: tzComponent
147120 }
148121 }
149122