implement generic table model
implement generic table model which reads table info from db and constructs table view
This commit is contained in:
committed by
Thomas Peetz
parent
c6d1e4d7e7
commit
3aed8af868
+15
-25
@@ -6,17 +6,17 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
from PySide6.QtGui import QAction, QIcon
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QMenu, QMessageBox, QTabWidget, QTableView, QHBoxLayout, QCheckBox
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QMenu, QMessageBox, QTabWidget, QTableView
|
||||
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow
|
||||
from platformdirs import PlatformDirs
|
||||
|
||||
from comic_model import ComicTableModel
|
||||
from media_file_model import MediaFileTableModel
|
||||
from model_config import KontorModelConfig
|
||||
from table_model import KontorTableModel
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
|
||||
|
||||
def __init__(self, config):
|
||||
super().__init__()
|
||||
|
||||
@@ -28,10 +28,10 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.setWindowTitle("Kontor")
|
||||
self.setMinimumSize(800, 500)
|
||||
self._createActions()
|
||||
self._createMenuBar()
|
||||
self._createToolBars()
|
||||
self._createStatusBar()
|
||||
self._create_actions()
|
||||
self._create_menubar()
|
||||
self._create_toolbars()
|
||||
self._create_statusbar()
|
||||
|
||||
self.data = []
|
||||
self.filter = {}
|
||||
@@ -47,7 +47,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.setCentralWidget(self.central_widget)
|
||||
|
||||
def _createActions(self):
|
||||
def _create_actions(self):
|
||||
self.newAction = QAction("&New", self)
|
||||
self.aboutAction = QAction("&Über...", self)
|
||||
self.aboutAction.triggered.connect(self.about)
|
||||
@@ -59,7 +59,7 @@ class MainWindow(QMainWindow):
|
||||
self.exitAction.setShortcut("Alt+F4")
|
||||
self.exitAction.triggered.connect(self.close)
|
||||
|
||||
def _createMenuBar(self):
|
||||
def _create_menubar(self):
|
||||
menu_bar = self.menuBar()
|
||||
# File menu
|
||||
file_menu = QMenu("&Datei")
|
||||
@@ -75,14 +75,14 @@ class MainWindow(QMainWindow):
|
||||
menu_bar.addMenu(help_menu)
|
||||
help_menu.addAction(self.aboutAction)
|
||||
|
||||
def _createToolBars(self):
|
||||
def _create_toolbars(self):
|
||||
# Kontor toolbar
|
||||
kontor_tool_bar = self.addToolBar("Kontor")
|
||||
kontor_tool_bar.addAction(self.importAction)
|
||||
kontor_tool_bar.addAction(self.exportAction)
|
||||
kontor_tool_bar.addAction(self.refreshAction)
|
||||
|
||||
def _createStatusBar(self):
|
||||
def _create_statusbar(self):
|
||||
self.statusBar = self.statusBar()
|
||||
self.statusBar.showMessage("Kontor ready", 6000)
|
||||
self.status_label = QLabel("")
|
||||
@@ -110,25 +110,15 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def generate_tab_media_file(self, db_configuration):
|
||||
media_file_tab = QWidget()
|
||||
table_config = KontorModelConfig(db_configuration, self, "media_file")
|
||||
model = KontorTableModel(table_config)
|
||||
layout = QVBoxLayout()
|
||||
filter_layout = QHBoxLayout()
|
||||
download_checkbox = QCheckBox()
|
||||
download_checkbox.setText("Download")
|
||||
download_checkbox.checkStateChanged.connect(self.refresh)
|
||||
self.filter["download"] = download_checkbox
|
||||
review_checkbox = QCheckBox()
|
||||
review_checkbox.setText("Review")
|
||||
review_checkbox.checkStateChanged.connect(self.refresh)
|
||||
self.filter["review"] = review_checkbox
|
||||
filter_layout.addWidget(review_checkbox)
|
||||
filter_layout.addWidget(download_checkbox)
|
||||
filter_layout.addStretch()
|
||||
model = MediaFileTableModel(db_configuration, self)
|
||||
# model = MediaFileTableModel(db_configuration, self)
|
||||
self.data.append(model)
|
||||
media_file_tab.setLayout(layout)
|
||||
table_view = QTableView()
|
||||
table_view.setModel(model)
|
||||
layout.addLayout(filter_layout)
|
||||
layout.addLayout(table_config.get_filter_layout())
|
||||
layout.addWidget(table_view)
|
||||
return media_file_tab
|
||||
|
||||
|
||||
Reference in New Issue
Block a user