implement general data tab view
This commit is contained in:
committed by
Thomas Peetz
parent
1a7da0ab9f
commit
c769115331
+11
-13
@@ -12,24 +12,22 @@ class KontorTableModel(QAbstractTableModel):
|
||||
super().__init__()
|
||||
self._main_window = model_config.main_window
|
||||
self._config = model_config
|
||||
self._data = None
|
||||
self._data = []
|
||||
|
||||
def refresh(self):
|
||||
data = []
|
||||
cursor = self._config.db_conn.cursor()
|
||||
cursor.execute(self._config.get_statement())
|
||||
rows = cursor.fetchall()
|
||||
# print(len(rows))
|
||||
if len(rows) > 0:
|
||||
data = self._config.get_data()
|
||||
count = 0
|
||||
# print(data)
|
||||
if data is not None:
|
||||
self.beginResetModel()
|
||||
for row in rows:
|
||||
data.append(list(row))
|
||||
self._data.clear()
|
||||
self._data = data
|
||||
self.endResetModel()
|
||||
else:
|
||||
self._data = None
|
||||
count = len(data)
|
||||
# print(data)
|
||||
# print(self._data)
|
||||
self.layoutChanged.emit()
|
||||
self._main_window.statusBar.showMessage(f"{len(rows)} Einträge geladen", 3000)
|
||||
self._main_window.statusBar.showMessage(f"{count} Einträge geladen", 3000)
|
||||
|
||||
def rowCount(self, parent=QModelIndex()):
|
||||
# The length of the outer list.
|
||||
@@ -39,7 +37,7 @@ class KontorTableModel(QAbstractTableModel):
|
||||
|
||||
def headerData(self, col, orientation, role=Qt.ItemDataRole.DisplayRole):
|
||||
if orientation == Qt.Orientation.Horizontal and role == Qt.ItemDataRole.DisplayRole:
|
||||
return self._config.header[col]['column']
|
||||
return self._config.header[col]['label']
|
||||
if orientation == Qt.Orientation.Vertical and role == Qt.ItemDataRole.DisplayRole:
|
||||
return str(col+1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user