From 81b15a5877c318c0d1b4624c003b0c57e63eda48 Mon Sep 17 00:00:00 2001 From: Mizaki Date: Tue, 27 Jun 2023 00:21:28 +0100 Subject: [PATCH 1/2] Fixes sorting by year and issue count. Removed superfluous if for publisher. Fixes #475 --- comictaggerlib/seriesselectionwindow.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/comictaggerlib/seriesselectionwindow.py b/comictaggerlib/seriesselectionwindow.py index 938975b..edfd4ad 100644 --- a/comictaggerlib/seriesselectionwindow.py +++ b/comictaggerlib/seriesselectionwindow.py @@ -465,24 +465,24 @@ class SeriesSelectionWindow(QtWidgets.QDialog): self.twList.setItem(row, 0, item) item_text = str(record.start_year) - item = QtWidgets.QTableWidgetItem(item_text) + item = QtWidgets.QTableWidgetItem(record.start_year) item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) + item.setData(QtCore.Qt.ItemDataRole.DisplayRole, record.start_year) item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) self.twList.setItem(row, 1, item) item_text = str(record.count_of_issues) - item = QtWidgets.QTableWidgetItem(item_text) + item = QtWidgets.QTableWidgetItem(record.count_of_issues) item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) item.setData(QtCore.Qt.ItemDataRole.DisplayRole, record.count_of_issues) item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) self.twList.setItem(row, 2, item) - if record.publisher is not None: - item_text = record.publisher - item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) - item = QtWidgets.QTableWidgetItem(item_text) - item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) - self.twList.setItem(row, 3, item) + item_text = record.publisher + item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) + item = QtWidgets.QTableWidgetItem(item_text) + item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) + self.twList.setItem(row, 3, item) row += 1 From 16b13a6fe019bcb0eeae2b6bcae9da370bc78e3c Mon Sep 17 00:00:00 2001 From: Mizaki Date: Wed, 28 Jun 2023 01:08:04 +0100 Subject: [PATCH 2/2] Format year and count of issues to 4 digits and do a None check --- comictaggerlib/seriesselectionwindow.py | 37 +++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/comictaggerlib/seriesselectionwindow.py b/comictaggerlib/seriesselectionwindow.py index edfd4ad..7d90d44 100644 --- a/comictaggerlib/seriesselectionwindow.py +++ b/comictaggerlib/seriesselectionwindow.py @@ -464,25 +464,28 @@ class SeriesSelectionWindow(QtWidgets.QDialog): item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) self.twList.setItem(row, 0, item) - item_text = str(record.start_year) - item = QtWidgets.QTableWidgetItem(record.start_year) - item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) - item.setData(QtCore.Qt.ItemDataRole.DisplayRole, record.start_year) - item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) - self.twList.setItem(row, 1, item) + if record.start_year is not None: + item_text = f"{record.start_year:04}" + item = QtWidgets.QTableWidgetItem(item_text) + item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) + item.setData(QtCore.Qt.ItemDataRole.DisplayRole, record.start_year) + item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) + self.twList.setItem(row, 1, item) - item_text = str(record.count_of_issues) - item = QtWidgets.QTableWidgetItem(record.count_of_issues) - item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) - item.setData(QtCore.Qt.ItemDataRole.DisplayRole, record.count_of_issues) - item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) - self.twList.setItem(row, 2, item) + if record.count_of_issues is not None: + item_text = f"{record.count_of_issues:04}" + item = QtWidgets.QTableWidgetItem(item_text) + item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) + item.setData(QtCore.Qt.ItemDataRole.DisplayRole, record.count_of_issues) + item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) + self.twList.setItem(row, 2, item) - item_text = record.publisher - item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) - item = QtWidgets.QTableWidgetItem(item_text) - item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) - self.twList.setItem(row, 3, item) + if record.publisher is not None: + item_text = record.publisher + item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) + item = QtWidgets.QTableWidgetItem(item_text) + item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) + self.twList.setItem(row, 3, item) row += 1