extract statioenSheet to own qml file
authorFlorian Schweikert <kelvan@logic.at>
Mon, 17 Oct 2011 17:07:51 +0000 (19:07 +0200)
committerFlorian Schweikert <kelvan@logic.at>
Mon, 17 Oct 2011 17:07:51 +0000 (19:07 +0200)
renamed StationListItem to SheetListItem

qml/MainPage.qml
qml/SheetListItem.qml [new file with mode: 0644]
qml/StationListItem.qml [deleted file]
qml/StationSheet.qml [new file with mode: 0644]

index 9b80ee4..3c3a035 100644 (file)
@@ -12,17 +12,6 @@ Page {
         realtimeResult.refresh()
     }
 
-    /*Image {
-        id: logo
-        source: 'logo.png'
-
-        anchors {
-            topMargin: 25
-            top: parent.top
-            horizontalCenter: parent.horizontalCenter
-        }
-    }*/
-
     SelectionDialog {
         id: lineSelector
         titleText: 'Select line'
@@ -116,145 +105,8 @@ Page {
         }
     }
 
-    Sheet {
+    StationSheet {
         id: stationSheet
-        property string currentLine: ''
-        property string currentDirection: ''
-        property string currentStation: ''
-
-        acceptButtonText: 'Select'
-        rejectButtonText: 'Cancel'
-
-        function loadData(lineName) {
-            stationSheet.currentLine = lineName
-
-            directionChooser.direction1 = ''
-            directionChooser.direction2 = ''
-
-            directionChooserBusyIndicator.running = true
-            itip.load_directions(stationSheet.currentLine)
-
-            firstDirection.clicked()
-            directionChooser.checkedButton = firstDirection
-        }
-
-        Connections {
-            target: itip
-
-            onDirectionsLoaded: {
-                directionChooserBusyIndicator.running = false
-
-                directionChooser.direction1 = itip.get_direction(0)
-                directionChooser.direction2 = itip.get_direction(1)
-
-                firstDirection.clicked()
-                directionChooser.checkedButton = firstDirection
-            }
-        }
-
-        content: Item {
-            anchors.fill: parent
-
-            ButtonColumn {
-                id: directionChooser
-                property string direction1
-                property string direction2
-
-                visible: !directionChooserBusyIndicator.running
-
-                function chosen(idx) {
-                    console.log('direction chosen: '+ idx)
-
-                    stationSelectorListView.selectedIndex = -1
-
-                    if (idx == 1) {
-                        stationSheet.currentDirection = directionChooser.direction1
-                    } else {
-                        stationSheet.currentDirection = directionChooser.direction2
-                    }
-
-                    directionChooserModel.clear()
-                    var stations = itip.get_stations(stationSheet.currentLine, stationSheet.currentDirection)
-
-                    for (var s in stations) {
-                        directionChooserModel.append({'station': stations[s]})
-                    }
-                }
-
-                anchors {
-                    margins: 10
-                    top: parent.top
-                    left: parent.left
-                    right: parent.right
-                }
-
-                Button {
-                    id: firstDirection
-                    text: 'Richtung ' + directionChooser.direction1
-                    onClicked: directionChooser.chosen(1)
-                }
-
-                Button {
-                    id: secondDirection
-                    text: 'Richtung ' + directionChooser.direction2
-                    onClicked: directionChooser.chosen(2)
-                }
-            }
-
-            ListView {
-                id: stationSelectorListView
-                visible: !directionChooserBusyIndicator.running
-
-                property int selectedIndex: -1
-                onSelectedIndexChanged: {
-                    console.log('current index: ' + selectedIndex)
-                    if (selectedIndex != -1) {
-                        stationSheet.currentStation = directionChooserModel.get(selectedIndex).station
-                    } else {
-                        stationSheet.currentStation = ''
-                    }
-                }
-
-                anchors {
-                    margins: 10
-                    top: directionChooser.bottom
-                    left: parent.left
-                    right: parent.right
-                    bottom: parent.bottom
-                }
-
-                clip: true
-
-                model: ListModel {
-                    id: directionChooserModel
-                }
-
-                delegate: StationListItem { selector: stationSelectorListView }
-            }
-
-            ScrollDecorator {
-                flickableItem: stationSelectorListView
-            }
-
-            BusyIndicator {
-                id: directionChooserBusyIndicator
-                anchors.centerIn: parent
-                visible: running
-                platformStyle: BusyIndicatorStyle { size: 'large' }
-            }
-        }
-
-        onAccepted: {
-            gstation.text = stationSheet.currentStation
-
-            realtimeResult.gline = stationSheet.currentLine
-            realtimeResult.gstation = stationSheet.currentStation
-            realtimeResult.gdirection = stationSheet.currentDirection
-
-            realtimeResult.sourceUrl = itip.get_directions_url(stationSheet.currentLine, stationSheet.currentDirection, stationSheet.currentStation)
-            console.log('url to get: ' + realtimeResult.sourceUrl)
-
-        }
     }
 
     Button {
diff --git a/qml/SheetListItem.qml b/qml/SheetListItem.qml
new file mode 100644 (file)
index 0000000..212a03d
--- /dev/null
@@ -0,0 +1,60 @@
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import com.nokia.extras 1.0
+
+import "UIConstants.js" as UIConstants
+import "ExtrasConstants.js" as ExtrasConstants
+
+Item {
+    property Item selector
+
+    width: parent.width
+    height: 60
+
+    BorderImage {
+        anchors.fill: parent
+        visible: mouseArea.pressed
+        source: theme.inverted ? 'image://theme/meegotouch-list-inverted-background-pressed-vertical-center': 'image://theme/meegotouch-list-background-pressed-vertical-center'
+    }
+
+    BorderImage {
+        anchors.fill: parent
+        visible: selector.selectedIndex == index
+        source: theme.inverted ? 'image://theme/meegotouch-list-inverted-background-selected-vertical-center': 'image://theme/meegotouch-list-background-selected-vertical-center'
+    }
+
+    Item {
+        anchors.fill: parent
+        anchors.margins: UIConstants.DEFAULT_MARGIN
+
+        Text {
+            anchors {
+                verticalCenter: parent.center
+                left: parent.left
+                leftMargin: 10
+                right: parent.right
+            }
+
+            elide: Text.ElideRight
+
+            text: station
+            font.pixelSize: UIConstants.FONT_DEFAULT
+            font.family: ExtrasConstants.FONT_FAMILY
+
+            color: {
+                if (theme.inverted) {
+                    (selector.selectedIndex == index) ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
+                } else {
+                    (selector.selectedIndex != index) ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
+                }
+            }
+        }
+    }
+
+    MouseArea {
+        id: mouseArea
+        anchors.fill: parent
+        onClicked: selector.selectedIndex = index
+    }
+}
+
diff --git a/qml/StationListItem.qml b/qml/StationListItem.qml
deleted file mode 100644 (file)
index c09c3e9..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-
-import QtQuick 1.1
-import com.nokia.meego 1.0
-import com.nokia.extras 1.0
-
-import "UIConstants.js" as UIConstants
-import "ExtrasConstants.js" as ExtrasConstants
-
-Item {
-    property Item selector
-
-    width: parent.width
-    height: 60
-
-    BorderImage {
-        anchors.fill: parent
-        visible: mouseArea.pressed
-        source: theme.inverted ? 'image://theme/meegotouch-list-inverted-background-pressed-vertical-center': 'image://theme/meegotouch-list-background-pressed-vertical-center'
-    }
-
-    BorderImage {
-        anchors.fill: parent
-        visible: selector.selectedIndex == index
-        source: theme.inverted ? 'image://theme/meegotouch-list-inverted-background-selected-vertical-center': 'image://theme/meegotouch-list-background-selected-vertical-center'
-    }
-
-    Item {
-        anchors.fill: parent
-        anchors.margins: UIConstants.DEFAULT_MARGIN
-
-        Text {
-            anchors {
-                verticalCenter: parent.center
-                left: parent.left
-                leftMargin: 10
-                right: parent.right
-            }
-
-            elide: Text.ElideRight
-
-            text: station
-            font.pixelSize: UIConstants.FONT_DEFAULT
-            font.family: ExtrasConstants.FONT_FAMILY
-
-            color: {
-                if (theme.inverted) {
-                    (selector.selectedIndex == index) ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
-                } else {
-                    (selector.selectedIndex != index) ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
-                }
-            }
-        }
-    }
-
-    MouseArea {
-        id: mouseArea
-        anchors.fill: parent
-        onClicked: selector.selectedIndex = index
-    }
-}
-
diff --git a/qml/StationSheet.qml b/qml/StationSheet.qml
new file mode 100644 (file)
index 0000000..19b93f1
--- /dev/null
@@ -0,0 +1,145 @@
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import "UIConstants.js" as UIConstants
+import "ExtrasConstants.js" as ExtrasConstants
+
+Sheet {
+    id: stationSheet
+    property string currentLine: ''
+    property string currentDirection: ''
+    property string currentStation: ''
+
+    acceptButtonText: 'Select'
+    rejectButtonText: 'Cancel'
+
+    function loadData(lineName) {
+        stationSheet.currentLine = lineName
+
+        directionChooser.direction1 = ''
+        directionChooser.direction2 = ''
+
+        directionChooserBusyIndicator.running = true
+        itip.load_directions(stationSheet.currentLine)
+
+        firstDirection.clicked()
+        directionChooser.checkedButton = firstDirection
+    }
+
+    Connections {
+        target: itip
+
+        onDirectionsLoaded: {
+            directionChooserBusyIndicator.running = false
+
+            directionChooser.direction1 = itip.get_direction(0)
+            directionChooser.direction2 = itip.get_direction(1)
+
+            firstDirection.clicked()
+            directionChooser.checkedButton = firstDirection
+        }
+    }
+
+    content: Item {
+        anchors.fill: parent
+
+        ButtonColumn {
+            id: directionChooser
+            property string direction1
+            property string direction2
+
+            visible: !directionChooserBusyIndicator.running
+
+            function chosen(idx) {
+                console.log('direction chosen: '+ idx)
+
+                stationSelectorListView.selectedIndex = -1
+
+                if (idx == 1) {
+                    stationSheet.currentDirection = directionChooser.direction1
+                } else {
+                    stationSheet.currentDirection = directionChooser.direction2
+                }
+
+                directionChooserModel.clear()
+                var stations = itip.get_stations(stationSheet.currentLine, stationSheet.currentDirection)
+
+                for (var s in stations) {
+                    directionChooserModel.append({'station': stations[s]})
+                }
+            }
+
+            anchors {
+                margins: 10
+                top: parent.top
+                left: parent.left
+                right: parent.right
+            }
+
+            Button {
+                id: firstDirection
+                text: 'Richtung ' + directionChooser.direction1
+                onClicked: directionChooser.chosen(1)
+            }
+
+            Button {
+                id: secondDirection
+                text: 'Richtung ' + directionChooser.direction2
+                onClicked: directionChooser.chosen(2)
+            }
+        }
+
+        ListView {
+            id: stationSelectorListView
+            visible: !directionChooserBusyIndicator.running
+
+            property int selectedIndex: -1
+            onSelectedIndexChanged: {
+                console.log('current index: ' + selectedIndex)
+                if (selectedIndex != -1) {
+                    stationSheet.currentStation = directionChooserModel.get(selectedIndex).station
+                } else {
+                    stationSheet.currentStation = ''
+                }
+            }
+
+            anchors {
+                margins: 10
+                top: directionChooser.bottom
+                left: parent.left
+                right: parent.right
+                bottom: parent.bottom
+            }
+
+            clip: true
+
+            model: ListModel {
+                id: directionChooserModel
+            }
+
+            delegate: SheetListItem { selector: stationSelectorListView }
+        }
+
+        ScrollDecorator {
+            flickableItem: stationSelectorListView
+        }
+
+        BusyIndicator {
+            id: directionChooserBusyIndicator
+            anchors.centerIn: parent
+            visible: running
+            platformStyle: BusyIndicatorStyle { size: 'large' }
+        }
+    }
+
+    onAccepted: {
+        gstation.text = stationSheet.currentStation
+
+        realtimeResult.gline = stationSheet.currentLine
+        realtimeResult.gstation = stationSheet.currentStation
+        realtimeResult.gdirection = stationSheet.currentDirection
+
+        realtimeResult.sourceUrl = itip.get_directions_url(stationSheet.currentLine, stationSheet.currentDirection, stationSheet.currentStation)
+        console.log('url to get: ' + realtimeResult.sourceUrl)
+
+    }
+}