6 from PySide.QtCore import SIGNAL, QTranslator, QObject, Qt
7 from PySide.QtGui import QApplication, QMainWindow
8 from Ui_Qt import Ui_MainWindow
9 from wlSearch import Search
10 from history import History
14 class WienerLinienQt(QMainWindow, Ui_MainWindow):
15 types = ('stop', 'address', 'poi')
18 QMainWindow.__init__(self)
19 # quick&dirty workaround for non-maemo systems
21 self.setAttribute(Qt.WA_Maemo5StackedWindow)
24 # _s is used to keep a reference to the Search object, so it does
25 # not get destroyed when it falls out of scope (the QML view is
26 # destroyed as soon as the Search object is destroyed!)
29 self.connect(self.btnSearch, SIGNAL("clicked()"), self.search)
30 self.connect(self.actionToggle, SIGNAL("activated()"), self.toggle)
32 self.history = History(settings.hist_file)
33 self.editOrigin.addItems(self.history)
34 self.editDestination.addItems(self.history)
36 self.editOrigin.clearEditText()
37 self.editDestination.clearEditText()
40 origin = self.editOrigin.currentText()
41 destination = self.editDestination.currentText()
43 if not (origin and destination):
44 self.btnSearch.setText(self.btnSearch.tr("Search - Missing input"))
47 self.history.insert(0, origin)
48 self.history.insert(0, destination)
50 if not origin in self.history:
51 self.editOrigin.insertItems(0, origin)
52 self.editDestination.insertItems(0, origin)
54 if not destination in self.history:
55 self.editOrigin.insertItems(0, destination)
56 self.editDestination.insertItems(0, destination)
58 self._s = Search(origin, destination, \
59 origin_type=self.types[self.comboOrigin.currentIndex()], \
60 destination_type=self.types[self.comboDestination.currentIndex()], \
66 eo = self.editOrigin.currentText()
67 ed = self.editDestination.currentText()
68 self.editOrigin.setEditText(ed)
69 self.editDestination.setEditText(eo)
71 co = self.comboOrigin.currentIndex()
72 cd = self.comboDestination.currentIndex()
73 self.comboOrigin.setCurrentIndex(cd)
74 self.comboDestination.setCurrentIndex(co)
76 if __name__ == "__main__":
77 app = QApplication(sys.argv)
79 t.load('', directory='lang', suffix='po')
80 app.installTranslator(t)