add column header info
This commit is contained in:
+6
-5
@@ -19,7 +19,7 @@ class KontorTableModel(QAbstractTableModel):
|
||||
cursor = self._config.db_conn.cursor()
|
||||
cursor.execute(self._config.get_statement())
|
||||
rows = cursor.fetchall()
|
||||
print(len(rows))
|
||||
# print(len(rows))
|
||||
if len(rows) > 0:
|
||||
self.beginResetModel()
|
||||
for row in rows:
|
||||
@@ -39,7 +39,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]
|
||||
return self._config.header[col]['column']
|
||||
if orientation == Qt.Orientation.Vertical and role == Qt.ItemDataRole.DisplayRole:
|
||||
return str(col+1)
|
||||
|
||||
@@ -48,6 +48,7 @@ class KontorTableModel(QAbstractTableModel):
|
||||
return None
|
||||
value = self._data[index.row()][index.column()]
|
||||
if role == Qt.ItemDataRole.DisplayRole:
|
||||
# print('{}: {}'.format(value, type(value)))
|
||||
if isinstance(value, datetime):
|
||||
return value.strftime("%Y-%m-%d %M:%M:%S")
|
||||
if isinstance(value, str):
|
||||
@@ -57,7 +58,7 @@ class KontorTableModel(QAbstractTableModel):
|
||||
return self._main_window.tick
|
||||
else:
|
||||
return self._main_window.cross
|
||||
return value
|
||||
return str(value)
|
||||
if role == Qt.ItemDataRole.DecorationRole:
|
||||
if isinstance(value, bytes):
|
||||
# print('{}: {}'.format(value, type(value)))
|
||||
@@ -69,8 +70,8 @@ class KontorTableModel(QAbstractTableModel):
|
||||
def columnCount(self, index=QModelIndex()):
|
||||
# The following takes the first sub-list, and returns
|
||||
# the length (only works if all rows are an equal length)
|
||||
print(f"Header count: {len(self._config.get_header())}")
|
||||
return len(self._config.get_header())
|
||||
# print(f"Header count: {len(self._config.get_header())}")
|
||||
return len(self._config.header)
|
||||
|
||||
def setData(self, index, value, role=Qt.ItemDataRole.EditRole):
|
||||
if role == Qt.ItemDataRole.EditRole:
|
||||
|
||||
Reference in New Issue
Block a user