Dark Overview UI style (for N900)
[pywienerlinien] / pyWienerLinien.py
1 #!/usr/bin/env python
2
3 import sys
4 import os.path
5 import webbrowser
6 from PySide.QtCore import SIGNAL
7 from PySide.QtGui import QApplication, QMainWindow
8 from Ui_Qt import Ui_MainWindow
9 from wlSearch import Search
10 from history import History
11 import settings
12
13
14 class WienerLinienQt(QMainWindow, Ui_MainWindow):
15     types = ('stop', 'address', 'poi')
16
17     def __init__(self):
18         QMainWindow.__init__(self)
19         # _s is used to keep a reference to the Search object, so it does
20         # not get destroyed when it falls out of scope (the QML view is
21         # destroyed as soon as the Search object is destroyed!)
22         self._s = None
23         self.setupUi(self)
24         self.connect(self.btnSearch, SIGNAL("clicked()"), self.search)
25
26         self.history = History(settings.hist_file)
27         self.editOrigin.addItems(self.history)
28         self.editDestination.addItems(self.history)
29
30     def search(self):
31         origin = self.editOrigin.currentText()
32         destination = self.editDestination.currentText()
33
34         self.history.insert(0, origin)
35         self.history.insert(0, destination)
36
37         if not origin in self.history:
38             self.editOrigin.insertItems(0, origin)
39             self.editDestination.insertItems(0, origin)
40
41         if not destination in self.history:
42             self.editOrigin.insertItems(0, destination)
43             self.editDestination.insertItems(0, destination)
44
45         if not origin and destination:
46             self.btnSearch.setText("Search - Missing input")
47         else:
48             self._s = Search(origin, destination, \
49                        origin_type=self.types[self.comboOrigin.currentIndex()], \
50                        destination_type=self.types[self.comboDestination.currentIndex()])
51             self._s.open_qml()
52             return True
53
54
55 if __name__ == "__main__":
56     app = QApplication(sys.argv)
57     w = WienerLinienQt()
58     w.show()
59     sys.exit(app.exec_())