aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-04-10 19:10:13 +0200
committerlonkaars <loek@pipeframe.xyz>2023-04-10 19:10:13 +0200
commit18cf64ff465efbef39ec38bb760ec35b2fe26637 (patch)
tree5a086cbae861a4aba52ccad0451f45e9d0bbb27b
parentb52f329310cc4abaf2c85e3abc498b3b8a39f47d (diff)
add season selection to menu bar
-rw-r--r--gui/main_window.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/gui/main_window.py b/gui/main_window.py
index 7247e8e..9e2f40e 100644
--- a/gui/main_window.py
+++ b/gui/main_window.py
@@ -11,6 +11,7 @@ class MainWindow(QMainWindow):
cursor: mariadb.Cursor = None
db: mariadb.Connection = None
menu_bar: QMenuBar
+ calendar_id: int
_tab_drivers: TabDrivers
_tab_teams: TabTeams
@@ -47,6 +48,17 @@ class MainWindow(QMainWindow):
def call_delete_flags(self):
self.cursor.execute("call spDeleteFlags()")
+ def update(self, cascade=True):
+ if cascade == False: return
+ self._tab_drivers.update()
+ self._tab_teams.update()
+ # self._tab_circuits.update()
+ # self._tab_races.update()
+
+ def switch_season(self):
+ self.calendar_id = self.sender().property("id")
+ self.update()
+
def __init__(self, cursor: mariadb.Cursor, db: mariadb.Connection, parent=None):
super(MainWindow, self).__init__(parent)
@@ -85,8 +97,19 @@ class MainWindow(QMainWindow):
action.triggered.connect(self.commit)
menu = self.menu_bar.addMenu("seasons")
+ group = QActionGroup(menu)
+ group.setExclusive(True)
+ self.cursor.execute("select ID, year from calendar")
+ for i, season in enumerate(self.cursor.fetchall()):
+ action = menu.addAction(str(season[1]))
+ action.setProperty("id", season[0])
+ action.triggered.connect(self.switch_season)
+ action.setCheckable(True)
+ if i == 0:
+ action.setChecked(True)
+ self.calendar_id = season[0]
+ group.addAction(action)
self.setMenuBar(self.menu_bar)
self.setCentralWidget(main_layout)
-