Implement Station map lookup
[quandoparte] / application / resources / harmattan / qml / StationListPage.qml
index feff382..ee0d51a 100644 (file)
@@ -1,6 +1,6 @@
 import QtQuick 1.0
 import QtMobility.location 1.1
-import com.nokia.meego 1.0
+import com.nokia.meego 1.1
 import net.cirulla.quandoparte 1.0
 import "uiconstants.js" as UiConstants
 import "StationListPage.js" as Private
@@ -10,8 +10,14 @@ Page {
     id: stationListPage
     tools: ToolBarLayout {
         id: toolBar
-        ToolIcon { iconId: "icon-m-toolbar-search"; onClicked: searchField.open = !searchField.open; }
-        ToolIcon { iconId: "icon-m-toolbar-view-menu"; onClicked: menu.open() }
+        ToolIcon {
+            iconId: "icon-m-toolbar-search" + (theme.inverted ? "-white": "")
+            onClicked: searchField.open = !searchField.open
+        }
+        ToolIcon {
+            iconId: "icon-m-toolbar-view-menu" + (theme.inverted ? "-white": "")
+            onClicked: menu.open()
+        }
     }
     Menu {
         id: menu
@@ -25,6 +31,7 @@ Page {
                         right: parent.right
                         rightMargin: UiConstants.DefaultMargin
                     }
+                    checked: settings.autoUpdate
                     onCheckedChanged: settings.autoUpdate = checked
                 }
             }
@@ -37,7 +44,11 @@ Page {
                         right: parent.right
                         rightMargin: UiConstants.DefaultMargin
                     }
-                    onCheckedChanged: settings.useDarkTheme = checked
+                    checked: settings.darkThemePreferred
+                    onCheckedChanged: {
+                        settings.darkThemePreferred = checked
+                        theme.inverted = checked
+                    }
                 }
             }
             MenuItem {
@@ -72,6 +83,11 @@ Page {
         property: "sortingMode"
         value: header.selectedIndex
     }
+    Binding {
+        target: stationListView
+        property: "section.property"
+        value: header.selectedIndex === 0 ? "name" : ""
+    }
     Item {
         id: mainView
         anchors {
@@ -94,6 +110,42 @@ Page {
                 bottom: parent.bottom
             }
             model:  stationListProxyModel
+            section {
+                //property: "name"
+                criteria: ViewSection.FirstCharacter
+                delegate: Item {
+                    width: parent.width
+                    height: UiConstants.SectionItemHeightSmall
+                    anchors {
+                        margins: UiConstants.DefaultMargin
+                    }
+                    Image {
+                        anchors {
+                            left: parent.left
+                            right: sectionLabel.left
+                            verticalCenter: parent.verticalCenter
+                            margins: UiConstants.DefaultMargin
+                        }
+                        source: "image://theme/meegotouch-separator-" + (theme.inverted ? "inverted-" : "") + "background-horizontal"
+                    }
+                    Label {
+                        id: sectionLabel
+                        anchors {
+                            right: sectionRightMargin.left
+                            verticalCenter: parent.verticalCenter
+                        }
+                        text: section
+                    }
+                    Item {
+                        id: sectionRightMargin
+                        anchors {
+                            right: parent.right
+                        }
+                        width: UiConstants.DefaultMargin
+                        height: UiConstants.DefaultMargin
+                    }
+                }
+            }
             delegate: Item {
                 id: listItem
                 height: UiConstants.ListItemHeightSmall
@@ -103,7 +155,7 @@ Page {
                     anchors.fill: parent
                     // Fill page borders
                     visible: mouseArea.pressed
-                    source: "image://theme/meegotouch-list-fullwidth-background-pressed"
+                    source: "image://theme/meegotouch-list-fullwidth-" + (theme.inverted ? "inverted-" : "") + "background-pressed"
                 }
                 Row {
                     anchors.fill: parent
@@ -126,7 +178,7 @@ Page {
                         left: parent.left
                         right: parent.right
                     }
-                    source: "image://theme/meegotouch-separator-background-horizontal"
+                    //source: "image://theme/meegotouch-separator-" + (theme.inverted ? "inverted-" : "") + "background-horizontal"
                 }
                 MouseArea {
                     id: mouseArea
@@ -134,6 +186,16 @@ Page {
                     onClicked: {
                         Private.loadStation(model.name, model.code)
                     }
+                    onPressAndHold: contextMenu.open()
+                }
+                ContextMenu {
+                    id: contextMenu
+                    MenuLayout {
+                        MenuItem {
+                            text: qsTr("Show on the map")
+                            onClicked: Qt.openUrlExternally("geo:" + model.longitude + "," + model.latitude)
+                        }
+                    }
                 }
             }
         }