on xenial help sign in
make the list selectable
commit060b5edf6a3263b0f72fb4b6802e401b6131c1b1 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateMon 22 Jun 2015, 22:13 (11 years ago) parent347a086
2 files changed+25−5
plugins/Wizard/timezonemodel.cpp+2−2 qml/Wizard/Pages/45-timezone.qml+23−3
plugins/Wizard/timezonemodel.cpp+2−2
@@ -61,13 +61,13 @@ QVariant TimeZoneModel::data(const QModelIndex &index, int role) const
6161
6262 switch (role) {
6363 case IdRole:
64− return tz.id();
64+ return QString(tz.id()); // to let QML compare it effortlessly with a QString
6565 case Abbreviation:
6666 return tz.abbreviation(QDateTime::currentDateTime());
6767 case Country:
6868 return QLocale::countryToString(tz.country());
6969 case City: {
70− const QString cityName = QString::fromUtf8(tzid.split('/').last());
70+ const QString cityName = QString::fromUtf8(tzid.split('/').last().replace("_", " "));
7171 return cityName;
7272 }
7373 case Comment:
qml/Wizard/Pages/45-timezone.qml+23−3
@@ -45,24 +45,44 @@ LocalComponents.Page {
4545 id: tz
4646 objectName: "tz"
4747 property QtObject tzData: null
48+ readonly property bool currentTz: !!tzData ? selectedTimeZone === tzData.id : false
4849
4950 Label {
5051 id: cityLabel
5152 text: !!tzData ? tzData.city : ""
5253 anchors.left: parent.left
5354 anchors.top: parent.top
55+ font.bold: tz.currentTz ? true : false
5456 }
5557 Label {
5658 id: timeLabel
5759 text: !!tzData ? tzData.time : ""
5860 anchors.right: parent.right
5961 anchors.top: parent.top
62+ font.bold: tz.currentTz ? true : false
6063 }
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+
6172 Label {
6273 id: abbrevLabel
6374 text: !!tzData ? tzData.abbreviation : ""
6475 anchors.right: parent.right
6576 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+ }
6686 }
6787 }
6888 }
@@ -100,10 +120,9 @@ LocalComponents.Page {
100120 anchors.right: parent.right
101121
102122 Repeater {
103− id: mainMenu
104−
123+ id: tzList
105124 model: tzFilterModel
106−
125+ property int selectedIndex
107126 delegate: Loader {
108127 id: loader
109128 anchors.left: !!parent ? parent.left : undefined
@@ -125,6 +144,7 @@ LocalComponents.Page {
125144 id: forwardButton
126145 LocalComponents.StackButton {
127146 text: i18n.tr("Next")
147+ enabled: selectedTimeZone != ""
128148 onClicked: pageStack.next()
129149 }
130150 }