Sailfish port mostly done, bumped version to 6.0
[quandoparte] / application / resources / sailfish / qml / pages / StationListPage.js
1 var view = undefined
2 var about = undefined
3
4 function showAboutPage()
5 {
6     var component = Qt.createComponent("AboutPage.qml")
7     if (component.status === Component.Ready) {
8         about = component.createObject(stationListPage)
9         pageStack.push(about)
10     } else
11         console.log('Cannot load component: ' + component.errorString());
12 }
13
14 function loadStation(name, code)
15 {
16     var component = Qt.createComponent("StationPage.qml");
17     if (component.status === Component.Ready) {
18         view = component.createObject(stationListPage)
19         stationListPage.stationView = view
20         pageStack.push(view)
21
22         /*
23             XXX Ugliness ahead! Changing the name triggers the station
24             schedule to be fetched. So any extra data (the code specifically)
25             must be set before changing the name.
26          */
27         if (code !== undefined) view.code = code
28         view.name = name
29     }
30     else
31         console.log('Cannot load component: ' + component.errorString());
32 }
33
34 function highlightSearch(s, color)
35 {
36     // TODO compile RegExp on change, or find a way to cleanly use
37     // stationListProxyModel.filterRegExp
38     if (searchPattern.length) {
39         var r = new RegExp(searchPattern, 'i')
40         var match = r.exec(s)
41         console.log('s is ' + s);
42         if (match) {
43                 return s.replace(r, '<font color="' + color + '">' +
44                                 match + '</font>')
45         } else {
46                 return s
47         }
48     } else {
49         return s
50     }
51 }
52