on xenial help sign in
make the list selectable
060b5edLukáš Tinkl
plugins/Wizard/timezonemodel.cpp+2−2
@@ -61,13 +61,13 @@ QVariant TimeZoneModel::data(const QModelIndex &index, int role) const
61
61
62 switch (role) {
62 switch (role) {
63 case IdRole:
63 case IdRole:
64− return tz.id();
64+ return QString(tz.id()); // to let QML compare it effortlessly with a QString
65 case Abbreviation:
65 case Abbreviation:
66 return tz.abbreviation(QDateTime::currentDateTime());
66 return tz.abbreviation(QDateTime::currentDateTime());
67 case Country:
67 case Country:
68 return QLocale::countryToString(tz.country());
68 return QLocale::countryToString(tz.country());
69 case City: {
69 case City: {
70− const QString cityName = QString::fromUtf8(tzid.split('/').last());
70+ const QString cityName = QString::fromUtf8(tzid.split('/').last().replace("_", " "));
71 return cityName;
71 return cityName;
72 }
72 }
73 case Comment:
73 case Comment:
qml/Wizard/Pages/45-timezone.qml+23−3
@@ -45,24 +45,44 @@ LocalComponents.Page {
45 id: tz
45 id: tz
46 objectName: "tz"
46 objectName: "tz"
47 property QtObject tzData: null
47 property QtObject tzData: null
48+ readonly property bool currentTz: !!tzData ? selectedTimeZone === tzData.id : false
48
49
49 Label {
50 Label {
50 id: cityLabel
51 id: cityLabel
51 text: !!tzData ? tzData.city : ""
52 text: !!tzData ? tzData.city : ""
52 anchors.left: parent.left
53 anchors.left: parent.left
53 anchors.top: parent.top
54 anchors.top: parent.top
55+ font.bold: tz.currentTz ? true : false
54 }
56 }
55 Label {
57 Label {
56 id: timeLabel
58 id: timeLabel
57 text: !!tzData ? tzData.time : ""
59 text: !!tzData ? tzData.time : ""
58 anchors.right: parent.right
60 anchors.right: parent.right
59 anchors.top: parent.top
61 anchors.top: parent.top
62+ font.bold: tz.currentTz ? true : false
60 }
63 }
64+ Label {
65+ id: countryLabel
66+ text: !!tzData ? tzData.country : ""
67+ anchors.left: parent.left
68+ anchors.top: cityLabel.bottom
69+ fontSize: "x-small"
70+ }
71+
61 Label {
72 Label {
62 id: abbrevLabel
73 id: abbrevLabel
63 text: !!tzData ? tzData.abbreviation : ""
74 text: !!tzData ? tzData.abbreviation : ""
64 anchors.right: parent.right
75 anchors.right: parent.right
65 anchors.top: timeLabel.bottom
76 anchors.top: timeLabel.bottom
77+ fontSize: "x-small"
78+ }
79+
80+ MouseArea {
81+ anchors.fill: parent
82+ onClicked: {
83+ tzModel.selectedZoneId = tzData.id
84+ print("Selected tz: " + selectedTimeZone)
85+ }
66 }
86 }
67 }
87 }
68 }
88 }
@@ -100,10 +120,9 @@ LocalComponents.Page {
100 anchors.right: parent.right
120 anchors.right: parent.right
101
121
102 Repeater {
122 Repeater {
103− id: mainMenu
123+ id: tzList
104−
105 model: tzFilterModel
124 model: tzFilterModel
106−
125+ property int selectedIndex
107 delegate: Loader {
126 delegate: Loader {
108 id: loader
127 id: loader
109 anchors.left: !!parent ? parent.left : undefined
128 anchors.left: !!parent ? parent.left : undefined
@@ -125,6 +144,7 @@ LocalComponents.Page {
125 id: forwardButton
144 id: forwardButton
126 LocalComponents.StackButton {
145 LocalComponents.StackButton {
127 text: i18n.tr("Next")
146 text: i18n.tr("Next")
147+ enabled: selectedTimeZone != ""
128 onClicked: pageStack.next()
148 onClicked: pageStack.next()
129 }
149 }
130 }
150 }