separate cli and gui application in own python packages. provide database schema as python package.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
from PySide6.QtWidgets import QHBoxLayout, QCheckBox
|
||||
from kontor_schema import KontorDB
|
||||
|
||||
|
||||
class KontorModelConfig:
|
||||
|
||||
def __init__(self, kontor_db: KontorDB, main_window, table_name: str):
|
||||
self.header = {}
|
||||
self.filter = {}
|
||||
self.main_window = main_window
|
||||
self._table_name = table_name
|
||||
self.kontor_db = kontor_db
|
||||
self.get_table_config()
|
||||
|
||||
def get_table_config(self):
|
||||
self.header = self.kontor_db.get_column_meta_data(self._table_name)
|
||||
self.filter = self.kontor_db.get_filters(self._table_name)
|
||||
|
||||
def filters(self) -> dict:
|
||||
_filters = {}
|
||||
# print(self.filter["download"].isChecked())
|
||||
for column, filter_info in self.filter.items():
|
||||
# print(column, filter_info)
|
||||
if filter_info['widget'].isChecked():
|
||||
_filters[column] = True
|
||||
# print(f"{filter_rule=}")
|
||||
return _filters
|
||||
|
||||
def get_data(self) -> list:
|
||||
# data = self.kontor_db.get_data(self._table_name, self.header, self.get_filter())
|
||||
# data.clear()
|
||||
data = self.kontor_db.data(self._table_name, self.header, self.filters())
|
||||
# print(f"KontorModelConfig.get_data: {len(data)}")
|
||||
# comics = self.kontor_db.session.query(Comic).all()
|
||||
# print(f'{len(comics)} Comics loaded')
|
||||
return data
|
||||
|
||||
def get_filter_layout(self) -> QHBoxLayout:
|
||||
filter_layout = QHBoxLayout()
|
||||
for column, filter_info in self.filter.items():
|
||||
filter_checkbox = QCheckBox()
|
||||
filter_checkbox.setText(filter_info['label'])
|
||||
filter_checkbox.checkStateChanged.connect(self.main_window.refresh)
|
||||
self.filter[column]['widget'] = filter_checkbox
|
||||
filter_layout.addWidget(filter_checkbox)
|
||||
filter_layout.addStretch()
|
||||
return filter_layout
|
||||
Reference in New Issue
Block a user