aboutsummaryrefslogtreecommitdiff
path: root/gui/main_window.py
diff options
context:
space:
mode:
Diffstat (limited to 'gui/main_window.py')
-rw-r--r--gui/main_window.py49
1 files changed, 37 insertions, 12 deletions
diff --git a/gui/main_window.py b/gui/main_window.py
index 9e2f40e..a269f45 100644
--- a/gui/main_window.py
+++ b/gui/main_window.py
@@ -18,6 +18,8 @@ class MainWindow(QMainWindow):
_tab_circuits: TabCircuits
_tab_races: TabRaces
+ main_layout: QTabWidget
+
def set_cursor(self, cursor: mariadb.Cursor):
self.cursor = cursor
@@ -39,20 +41,41 @@ class MainWindow(QMainWindow):
def call_update_flags(self):
folder = QFileDialog().getExistingDirectory(self, "Open directory", "/var/dab2/")
+ if not folder: return
+ folder += "/"
self.cursor.execute("call spUpdateFlags(?)", (folder,))
def call_update_persons(self):
folder = QFileDialog().getExistingDirectory(self, "Open directory", "/var/dab2/")
+ if not folder: return
+ folder += "/"
self.cursor.execute("call spUpdatePersons(?)", (folder,))
+ def call_update_circuits(self):
+ folder = QFileDialog().getExistingDirectory(self, "Open directory", "/var/dab2/")
+ if not folder: return
+ folder += "/"
+ self.cursor.execute("call spUpdateCircuits(?)", (folder,))
+
def call_delete_flags(self):
self.cursor.execute("call spDeleteFlags()")
+ def focus_member(self, id):
+ self.set_tab_index(0)
+ self._tab_drivers.set_driver_id(id)
+
+ def focus_team(self, id):
+ self.set_tab_index(1)
+ self._tab_teams.set_team_id(id)
+
+ def set_tab_index(self, index):
+ self.main_layout.setCurrentIndex(index)
+
def update(self, cascade=True):
if cascade == False: return
self._tab_drivers.update()
self._tab_teams.update()
- # self._tab_circuits.update()
+ self._tab_circuits.update()
# self._tab_races.update()
def switch_season(self):
@@ -70,33 +93,35 @@ class MainWindow(QMainWindow):
self._tab_drivers = TabDrivers(self.cursor, self)
self._tab_teams = TabTeams(self.cursor, self)
- self._tab_circuits = TabCircuits(self)
+ self._tab_circuits = TabCircuits(self.cursor, self)
self._tab_races = TabRaces(self)
- main_layout = QTabWidget(self);
- main_layout.addTab(self._tab_drivers, "drivers")
- main_layout.addTab(self._tab_teams, "teams")
- main_layout.addTab(self._tab_circuits, "cirucits")
- main_layout.addTab(self._tab_races, "races")
+ self.main_layout = QTabWidget(self);
+ self.main_layout.addTab(self._tab_drivers, "Drivers")
+ self.main_layout.addTab(self._tab_teams, "Teams")
+ self.main_layout.addTab(self._tab_circuits, "Cirucits")
+ self.main_layout.addTab(self._tab_races, "Races")
self.menu_bar = QMenuBar(self)
- menu = self.menu_bar.addMenu("file")
+ menu = self.menu_bar.addMenu("File")
action = menu.addAction("Exit (commit changes)")
action.triggered.connect(self.exit_commit)
action = menu.addAction("Exit (don't commit changes)")
action.triggered.connect(self.exit_no_commit)
- menu = self.menu_bar.addMenu("procedures")
+ menu = self.menu_bar.addMenu("Procedures")
action = menu.addAction("Import/update flags")
action.triggered.connect(self.call_update_flags)
action = menu.addAction("Import/update driver portraits")
action.triggered.connect(self.call_update_persons)
+ action = menu.addAction("Import/update circuit maps")
+ action.triggered.connect(self.call_update_circuits)
action = menu.addAction("Delete flags")
action.triggered.connect(self.call_delete_flags)
- menu = self.menu_bar.addMenu("database")
+ menu = self.menu_bar.addMenu("Database")
action = menu.addAction("Commit changes")
action.triggered.connect(self.commit)
- menu = self.menu_bar.addMenu("seasons")
+ menu = self.menu_bar.addMenu("Seasons")
group = QActionGroup(menu)
group.setExclusive(True)
self.cursor.execute("select ID, year from calendar")
@@ -111,5 +136,5 @@ class MainWindow(QMainWindow):
group.addAction(action)
self.setMenuBar(self.menu_bar)
- self.setCentralWidget(main_layout)
+ self.setCentralWidget(self.main_layout)