Relayout StationListView Pulldown menu
[quandoparte] / application / resources / sailfish / qml / pages / StationListPage.qml
index 8ede923..a75c314 100644 (file)
@@ -18,20 +18,23 @@ Page {
         pressDelay: 0
         PullDownMenu {
             MenuItem {
-                text: qsTr("About Quando Parte")
-                onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
+                text: qsTr("Settings")
+                onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
             }
             MenuItem {
-                text: qsTr("Stations by Name")
-                onClicked: stationListProxyModel.sortingMode = StationListProxyModel.AlphaSorting
+                text: qsTr("Show Stations by Distance")
+                onClicked: stationListProxyModel.sortingMode = StationListProxyModel.DistanceSorting
+                enabled: (stationListProxyModel.sortingMode !== StationListProxyModel.DistanceSorting)
             }
             MenuItem {
-                text: qsTr("Stations by Distance")
-                onClicked: stationListProxyModel.sortingMode = StationListProxyModel.DistanceSorting
+                text: qsTr("Show Stations by Name")
+                onClicked: stationListProxyModel.sortingMode = StationListProxyModel.AlphaSorting
+                enabled: (stationListProxyModel.sortingMode !== StationListProxyModel.AlphaSorting)
             }
             MenuItem {
-                text: qsTr("Stations Recently Seen")
+                text: qsTr("Show Recent Stations")
                 onClicked: stationListProxyModel.sortingMode = StationListProxyModel.RecentUsageSorting
+                enabled: (stationListProxyModel.sortingMode !== StationListProxyModel.RecentUsageSorting)
             }
         }
         PageHeader {
@@ -39,10 +42,11 @@ Page {
             SearchField {
                 id: searchField
                 placeholderText: qsTr("Search station...")
-                inputMethodHints: Qt.ImhNoAutoUppercase
+                inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
                 onTextChanged: stationListPage.searchPattern = searchField.text
                 width: stationListPage.width
                 EnterKey.onClicked: searchField.focus = false
+                EnterKey.iconSource: "image://theme/icon-m-enter-close"
             }
         }
         SilicaListView {
@@ -53,8 +57,6 @@ Page {
             anchors.top: header.bottom
             anchors.bottom: parent.bottom
             model:  stationListProxyModel
-            objectName:
-                    searchField.focus = false
             delegate: ListItem {
                 id: listItem
                 contentHeight: Theme.itemSizeExtraSmall
@@ -79,10 +81,6 @@ Page {
                         right: parent.right
                     }
                 }
-                onClicked: {
-                    Private.loadStation(model.name, model.code)
-                }
-                //onPressAndHold: contextMenu.show(listItem)
                 menu: contextMenu
                 Component {
                     id: contextMenu
@@ -90,15 +88,8 @@ Page {
                         MenuItem {
                             text: model.favorite ? qsTr("Remove from Favorites") : qsTr("Add to Favorites")
                             onClicked: {
-                                console.log("Favorite Stations (before):" + settings.favoriteStations)
                                 model.favorite ^= true
-                                /*
-                                var index = settings.favoriteStations.indexOf(model.name)
-                                if (index === -1)
-                                    settings.favoriteStations.push(model.name)
-                                else settings.favoriteStations.splice(index, 1)
-                                */
-                                console.log("Favorite Stations (after):" + settings.favoriteStations)
+                                console.log("Favorite Stations:" + settings.favoriteStations)
                             }
                         }
                         MenuItem {
@@ -107,6 +98,8 @@ Page {
                         }
                     }
                 }
+                onPressed: searchField.focus = false
+                onClicked: Private.loadStation(model.name, model.code)
             }
             VerticalScrollDecorator {}
         }