6 from PySide.QtCore import SIGNAL, QTranslator, QObject
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 # _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!)
24 self.connect(self.btnSearch, SIGNAL("clicked()"), self.search)
25 self.connect(self.actionToggle, SIGNAL("activated()"), self.toggle)
27 self.history = History(settings.hist_file)
28 self.editOrigin.addItems(self.history)
29 self.editDestination.addItems(self.history)
31 self.editOrigin.clearEditText()
32 self.editDestination.clearEditText()
35 origin = self.editOrigin.currentText()
36 destination = self.editDestination.currentText()
38 if not (origin and destination):
39 self.btnSearch.setText(self.btnSearch.tr("Search - Missing input"))
42 self.history.insert(0, origin)
43 self.history.insert(0, destination)
45 if not origin in self.history:
46 self.editOrigin.insertItems(0, origin)
47 self.editDestination.insertItems(0, origin)
49 if not destination in self.history:
50 self.editOrigin.insertItems(0, destination)
51 self.editDestination.insertItems(0, destination)
53 self._s = Search(origin, destination, \
54 origin_type=self.types[self.comboOrigin.currentIndex()], \
55 destination_type=self.types[self.comboDestination.currentIndex()])
60 eo = self.editOrigin.currentText()
61 ed = self.editDestination.currentText()
62 self.editOrigin.setEditText(ed)
63 self.editDestination.setEditText(eo)
65 co = self.comboOrigin.currentIndex()
66 cd = self.comboDestination.currentIndex()
67 self.comboOrigin.setCurrentIndex(cd)
68 self.comboDestination.setCurrentIndex(co)
70 if __name__ == "__main__":
71 app = QApplication(sys.argv)
73 t.load('', directory='lang', suffix='po')
74 app.installTranslator(t)