on xenial help sign in
use ListView
c904ef8Lukáš Tinkl
qml/Wizard/Pages/50-timezone.qml+35−62
@@ -48,28 +48,24 @@ LocalComponents.Page {
48 ListItem {
48 ListItem {
49 id: tz
49 id: tz
50 objectName: "tz"
50 objectName: "tz"
51− property QtObject tzData: null
52− readonly property bool currentTz: !!tzData ? selectedTimeZone === tzData.id : false
51+ readonly property bool currentTz: !!id ? selectedTimeZone === id : false
53−
52+
54− Label {
53+ Column {
54+ anchors.verticalCenter: parent.verticalCenter
55+ Label {
55− id: cityLabel
56+ id: cityLabel
56− text: !!tzData ? tzData.city : ""
57+ text: !!city ? 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
58+ font.weight: tz.currentTz ? Font.Normal : Font.Light
61− fontSize: "medium"
59+ fontSize: "medium"
62− color: "#525252"
60+ color: "#525252"
63− }
61+ }
64− Label {
62+ Label {
65− id: timeLabel
63+ id: timeLabel
66− text: !!tzData ? tzData.time + " " + tzData.abbreviation : ""
64+ text: !!time ? time + " " + 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
65+ font.weight: tz.currentTz ? Font.Normal : Font.Light
71− fontSize: "small"
66+ fontSize: "small"
72− color: "#525252"
67+ color: "#525252"
68+ }
73 }
69 }
74 Image {
70 Image {
75 anchors {
71 anchors {
@@ -84,18 +80,12 @@ LocalComponents.Page {
84 }
80 }
85
81
86 onClicked: {
82 onClicked: {
87− tzModel.selectedZoneId = tzData.id
83+ tzModel.selectedZoneId = id
88 print("Selected tz: " + selectedTimeZone)
84 print("Selected tz: " + selectedTimeZone)
89 }
85 }
90 }
86 }
91 }
87 }
92
88
93− ActivityIndicator {
94− id: busyIndicator
95− anchors.centerIn: parent
96− running: true
97− }
98−
99 Column {
89 Column {
100 id: column
90 id: column
101 anchors.fill: content
91 anchors.fill: content
@@ -109,41 +99,24 @@ LocalComponents.Page {
109 color: UbuntuColors.lightGrey
99 color: UbuntuColors.lightGrey
110 }
100 }
111
101
112− Flickable {
102+ ListView {
113− anchors.left: parent.left
103+ id: tzList;
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
121
104
122− Column {
105+ boundsBehavior: Flickable.StopAtBounds;
123− anchors.left: parent.left
106+ clip: true;
124− anchors.right: parent.right
107+ currentIndex: -1
125−
108+ snapMode: ListView.SnapToItem
126− Repeater {
109+
127− id: tzList
110+ anchors {
128− model: tzFilterModel
111+ left: parent.left;
129− delegate: Loader {
112+ right: parent.right;
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− }
146 }
113 }
114+
115+ height: column.height - searchField.height - column.spacing - topMargin
116+
117+ model: tzFilterModel
118+
119+ delegate: tzComponent
147 }
120 }
148 }
121 }
149
122