Page {
tools: commonTools
- Image {
- id: logo
- source: 'logo.png'
+ property bool canRefresh: realtimeResult.sourceUrl != ''
- anchors {
- topMargin: 25
- top: parent.top
- horizontalCenter: parent.horizontalCenter
+ function refresh() {
+ realtimeResult.refresh()
+ }
+
+ SelectionDialog {
+ id: lineSelector
+ titleText: 'Select line'
+
+ model: ListModel {
+ id: lineSelectorModel
+
+ Component.onCompleted: {
+ var lines = itip.get_lines()
+
+ for (var idx in lines) {
+ lineSelectorModel.append({'name': lines[idx]})
+ }
+ }
+ }
+
+ // XXX It would be nice if we could make a delegate with
+ // icons (i.e. U1, U2, ... in the right colors), but we
+ // would have to "copy" the default delegate style
+
+ onAccepted: {
+ console.log('accepted: ' + selectedIndex)
+ gline.text = lineSelectorModel.get(selectedIndex).name
}
}
id: gline
anchors {
- top: logo.bottom
+ top: parent.top
left: parent.left
topMargin: 20
leftMargin: 10
rightMargin: 10
+ right: lineSearchButton.left
+ }
+
+ onTextChanged: {
+ // TODO: Check if text matches an item in lineSelectorModel and
+ // set selectedIndex in lineSelector to the right item
+ gstation.text = ''
+
+ if (lineSelector.selectedIndex == -1) {
+ return
+ }
+
+ // Disable selection in line selector if user changes the text
+ if (lineSelectorModel.get(lineSelector.selectedIndex).name != text) {
+ lineSelector.selectedIndex = -1
+ }
}
- width: parent.width - 20
MouseArea {
anchors.fill: parent
}
}
+ LineSheet {
+ id: lineSheet
+ }
+
+ Button {
+ id: lineSearchButton
+
+ anchors {
+ top: gline.top
+ bottom: gline.bottom
+ right: parent.right
+ rightMargin: 10
+ }
+
+ width: 60
+ iconSource: 'image://theme/icon-m-common-search'
+
+ onClicked: lineSelector.open()
+ }
+
TextField {
placeholderText: 'Station'
id: gstation
+
anchors {
top: gline.bottom
left: parent.left
- right: parent.right
+ right: stationPickerButton.left
topMargin: 10
leftMargin: 10
- rightMargin: 10
+ rightMargin: 10*stationPickerButton.opacity
}
}
- ResultRealtime { id: resu }
+ StationSheet {
+ id: stationSheet
+ }
Button {
- id: btnSearch
- text: 'Search'
+ id: stationPickerButton
+
anchors {
- top: gstation.bottom
- topMargin: 10
- horizontalCenter: parent.horizontalCenter
+ top: gstation.top
+ bottom: gstation.bottom
+ right: parent.right
+ rightMargin: 10
}
+
+ Behavior on opacity { PropertyAnimation { } }
+
+ opacity: gline.text != '' // XXX: Check if the line is valid
+
+ width: lineSearchButton.width * opacity
+ //iconSource: 'image://theme/icon-m-common-location-picker'
+ iconSource: 'image://theme/icon-m-toolbar-list'
+
onClicked: {
- resu.gline = gline.text
- resu.gstation = gstation.text
- pageStack.push(resu)
- itip.search(gline.text, gstation.text)
- resu.busy = false
+ stationSheet.open()
+ stationSheet.loadData(gline.text)
+ }
+ }
+
+ ResultRealtime {
+ id: realtimeResult
+
+ anchors {
+ margins: 10
+ top: gstation.bottom
+ left: parent.left
+ bottom: parent.bottom
+ right: parent.right
}
+
+ clip: true
+
+ gline: stationSheet.currentLine
+ gstation: stationSheet.currentStation
+ gdirection: stationSheet.currentDirection
+
+ sourceUrl: stationSheet.currentUrl
}
}