diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-04-09 21:21:58 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-04-09 21:21:58 +0200 |
commit | 8a32646063bf0ff70b0560b192189e171e376717 (patch) | |
tree | cf70cf53367ea9ef04d46eadc934c0d2ba93ce4b | |
parent | 6d5c0901baf7a96e36e5e075b52970e0df2ccf19 (diff) |
more application
-rw-r--r-- | gui/login_dialog.py | 4 | ||||
-rwxr-xr-x | gui/main.py | 9 | ||||
-rw-r--r-- | gui/main_window.py | 11 | ||||
-rw-r--r-- | gui/split_view_layout.py | 15 | ||||
-rw-r--r-- | gui/tab_calendar.py | 4 | ||||
-rw-r--r-- | gui/tab_circuits.py | 4 | ||||
-rw-r--r-- | gui/tab_drivers.py | 100 | ||||
-rw-r--r-- | gui/tab_races.py | 4 | ||||
-rw-r--r-- | gui/tab_teams.py | 4 | ||||
-rw-r--r-- | schema.mwb | bin | 15938 -> 14093 bytes |
10 files changed, 119 insertions, 36 deletions
diff --git a/gui/login_dialog.py b/gui/login_dialog.py index 3be923e..02ea1af 100644 --- a/gui/login_dialog.py +++ b/gui/login_dialog.py @@ -1,6 +1,6 @@ import os -from PyQt6.QtGui import * -from PyQt6.QtWidgets import * +from PySide6.QtGui import * +from PySide6.QtWidgets import * class LoginDialog(QDialog): hostname = "localhost" diff --git a/gui/main.py b/gui/main.py index 335d7ed..ee84dfa 100755 --- a/gui/main.py +++ b/gui/main.py @@ -2,16 +2,15 @@ import sys import mariadb -from PyQt6.QtGui import * -from PyQt6.QtWidgets import * -from PyQt6 import * +from PySide6.QtGui import * +from PySide6.QtWidgets import * +from PySide6 import * from login_dialog import * from main_window import * if __name__ == '__main__': app = QApplication(sys.argv) - win = MainWindow() login_dialog = LoginDialog() db = None while True: @@ -21,7 +20,7 @@ if __name__ == '__main__': break except: print("Login failed, please try again") - win.set_cursor(db.cursor(buffered=True)) + win = MainWindow(db.cursor(buffered=True)) win.show() app.exec() diff --git a/gui/main_window.py b/gui/main_window.py index 957bd27..d30633d 100644 --- a/gui/main_window.py +++ b/gui/main_window.py @@ -1,6 +1,6 @@ import mariadb -from PyQt6.QtGui import * -from PyQt6.QtWidgets import * +from PySide6.QtGui import * +from PySide6.QtWidgets import * from tab_drivers import * from tab_teams import * @@ -32,12 +32,15 @@ class MainWindow(QMainWindow): def call_delete_flags(self): self.cursor.execute("call spDeleteFlags()") - def __init__(self, parent=None): + def __init__(self, cursor: mariadb.Cursor, parent=None): super(MainWindow, self).__init__(parent) + + self.set_cursor(cursor) + self.setWindowTitle("[floating] dab2 eindopdracht main window") self.setMinimumHeight(500) - self._tab_drivers = TabDrivers(self) + self._tab_drivers = TabDrivers(self.cursor, self) self._tab_teams = TabTeams(self) self._tab_calendar = TabCalendar(self) self._tab_circuits = TabCircuits(self) diff --git a/gui/split_view_layout.py b/gui/split_view_layout.py index ef0a14c..6ab14e9 100644 --- a/gui/split_view_layout.py +++ b/gui/split_view_layout.py @@ -1,19 +1,14 @@ import os -from PyQt6.QtGui import * -from PyQt6.QtWidgets import * -from PyQt6.QtCore import Qt +from PySide6.QtGui import * +from PySide6.QtWidgets import * +from PySide6.QtCore import Qt class SplitViewLayout(QGridLayout): - def _setWidget(self, column: int, w: QWidget): - self.addWidget(w, 0, column, Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft) - - return - def leftWidget(self, w: QWidget): - self._setWidget(0, w) + self.addWidget(w, 0, 0) def rightWidget(self, w: QWidget): - self._setWidget(1, w) + self.addWidget(w, 0, 1, Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft) def __init__(self, parent=None): super(SplitViewLayout, self).__init__(parent) diff --git a/gui/tab_calendar.py b/gui/tab_calendar.py index 98aec52..9802143 100644 --- a/gui/tab_calendar.py +++ b/gui/tab_calendar.py @@ -1,6 +1,6 @@ import os -from PyQt6.QtGui import * -from PyQt6.QtWidgets import * +from PySide6.QtGui import * +from PySide6.QtWidgets import * class TabCalendar(QWidget): def __init__(self, parent=None): diff --git a/gui/tab_circuits.py b/gui/tab_circuits.py index 332a9a4..19ba979 100644 --- a/gui/tab_circuits.py +++ b/gui/tab_circuits.py @@ -1,6 +1,6 @@ import os -from PyQt6.QtGui import * -from PyQt6.QtWidgets import * +from PySide6.QtGui import * +from PySide6.QtWidgets import * class TabCircuits(QWidget): def __init__(self, parent=None): diff --git a/gui/tab_drivers.py b/gui/tab_drivers.py index d9a6098..a94ee14 100644 --- a/gui/tab_drivers.py +++ b/gui/tab_drivers.py @@ -1,18 +1,104 @@ import os -from PyQt6.QtGui import * -from PyQt6.QtWidgets import * +import mariadb +from PySide6.QtGui import * +from PySide6.QtWidgets import * +from PySide6.QtCore import * +from PySide6.QtCore import Qt from split_view_layout import * +from dataclasses import dataclass + +@dataclass +class DBDriver(): + id: int + first_name: str + last_name: str + +class DriverModel(QAbstractTableModel): + cursor: mariadb.Cursor + + _header = ["first name", "last name"] + _data: [DBDriver] = [] + + def update(self): + self.beginResetModel() + self.cursor.execute("select `ID`, `firstName`, `lastName` from `member`") + self._data = list() + for result in self.cursor.fetchall(): + self._data.append(DBDriver(*result)) + self.endResetModel() + + def __init__(self, cursor): + super().__init__() + self.cursor = cursor + self.update() + + def rowCount(self, index=0): + return len(self._data) + + def columnCount(self, index=0): + return len(self._header) + + def headerData(self, section, orientation, role): + if role == Qt.DisplayRole: + if orientation == Qt.Horizontal: + return self._header[section] + else: + return self._data[section].id + + def data(self, index, role): + if role == Qt.DisplayRole: + driver = self._data[index.row()] + return ( + driver.first_name, + driver.last_name, + )[index.column()] + +class DriverDetailsWidget(QWidget): + def __init__(self, cursor: mariadb.Cursor, parent=None): + super(DriverDetailsWidget, self).__init__(parent) + + layout = QVBoxLayout(self) + # layout.setAlignment(Qt.AlignmentFlag.AlignTop) + + label_portrait = QLabel("Driver portrait") + layout.addWidget(label_portrait) + + details_form = QFormLayout(self) + details_form.addRow("First name", QLineEdit("hoi")) + details_form.addRow("Middle name", QLineEdit("hoi")) + details_form.addRow("Last name", QLineEdit("hoi")) + layout.addLayout(details_form) + + self.setLayout(layout) + class TabDrivers(QWidget): layout: SplitViewLayout + cursor: mariadb.Cursor + + widget_driver_table: QTableView + model_driver_table: DriverModel + model_proxy: QSortFilterProxyModel + + driver_details: DriverDetailsWidget - def __init__(self, parent=None): + def __init__(self, cursor: mariadb.Cursor, parent=None): super(TabDrivers, self).__init__(parent) + self.cursor = cursor + self.layout = SplitViewLayout(self) - layout = SplitViewLayout(self) - layout.leftWidget(QLabel("hoi")) - layout.rightWidget(QLabel("doei")) + self.widget_driver_table = QTableView(self) + self.widget_driver_table.setSelectionBehavior(QAbstractItemView.SelectRows) + self.model_driver_table = DriverModel(self.cursor) + self.model_proxy = QSortFilterProxyModel() + self.model_proxy.setSourceModel(self.model_driver_table) + self.widget_driver_table.setModel(self.model_proxy) + self.widget_driver_table.setSortingEnabled(True) + self.layout.leftWidget(self.widget_driver_table) - self.setLayout(layout) + self.driver_details = DriverDetailsWidget(self) + self.layout.rightWidget(self.driver_details) + + self.setLayout(self.layout) diff --git a/gui/tab_races.py b/gui/tab_races.py index 316e0af..6d96152 100644 --- a/gui/tab_races.py +++ b/gui/tab_races.py @@ -1,6 +1,6 @@ import os -from PyQt6.QtGui import * -from PyQt6.QtWidgets import * +from PySide6.QtGui import * +from PySide6.QtWidgets import * class TabRaces(QWidget): def __init__(self, parent=None): diff --git a/gui/tab_teams.py b/gui/tab_teams.py index 2b25900..a96b3e2 100644 --- a/gui/tab_teams.py +++ b/gui/tab_teams.py @@ -1,6 +1,6 @@ import os -from PyQt6.QtGui import * -from PyQt6.QtWidgets import * +from PySide6.QtGui import * +from PySide6.QtWidgets import * class TabTeams(QWidget): def __init__(self, parent=None): Binary files differ |