From 5bdbe7d1814ecc1381a1a07c5c881fd356c4fc47 Mon Sep 17 00:00:00 2001 From: Mizaki Date: Thu, 5 Oct 2023 22:14:45 +0100 Subject: [PATCH] Always update rows even if None --- comictaggerlib/issueselectionwindow.py | 8 +++--- comictaggerlib/seriesselectionwindow.py | 35 +++++++++++-------------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/comictaggerlib/issueselectionwindow.py b/comictaggerlib/issueselectionwindow.py index b0f4d68..9000378 100644 --- a/comictaggerlib/issueselectionwindow.py +++ b/comictaggerlib/issueselectionwindow.py @@ -160,11 +160,9 @@ class IssueSelectionWindow(QtWidgets.QDialog): for row, issue in enumerate(self.issue_list.values()): self.twList.insertRow(row) - for i in range(3): - if i == 0: - self.twList.setItem(row, i, IssueNumberTableWidgetItem()) - else: - self.twList.setItem(row, i, QtWidgets.QTableWidgetItem()) + self.twList.setItem(row, 0, IssueNumberTableWidgetItem()) + self.twList.setItem(row, 1, QtWidgets.QTableWidgetItem()) + self.twList.setItem(row, 2, QtWidgets.QTableWidgetItem()) self.update_row(row, issue) diff --git a/comictaggerlib/seriesselectionwindow.py b/comictaggerlib/seriesselectionwindow.py index 8ce03b8..7d205df 100644 --- a/comictaggerlib/seriesselectionwindow.py +++ b/comictaggerlib/seriesselectionwindow.py @@ -534,27 +534,24 @@ class SeriesSelectionWindow(QtWidgets.QDialog): item.setData(QtCore.Qt.ItemDataRole.UserRole, series.id) item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) - if series.start_year is not None: - item_text = f"{series.start_year:04}" - item = self.twList.item(row, 1) - item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) - item.setData(QtCore.Qt.ItemDataRole.DisplayRole, series.start_year) - item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) + item_text = f"{series.start_year:04}" if series.start_year is not None else "" + item = self.twList.item(row, 1) + item.setText(item_text) + item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) + item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) - if series.count_of_issues is not None: - item_text = f"{series.count_of_issues:04}" - item = self.twList.item(row, 2) - item.setText(item_text) - item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) - item.setData(QtCore.Qt.ItemDataRole.DisplayRole, series.count_of_issues) - item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) + item_text = f"{series.count_of_issues:04}" if series.count_of_issues is not None else "" + item = self.twList.item(row, 2) + item.setText(item_text) + item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) + item.setData(QtCore.Qt.ItemDataRole.DisplayRole, series.count_of_issues) + item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) - if series.publisher is not None: - item_text = series.publisher - item = self.twList.item(row, 3) - item.setText(item_text) - item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) - item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) + item_text = series.publisher if series.publisher is not None else "" + item = self.twList.item(row, 3) + item.setText(item_text) + item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text) + item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled) def current_item_changed(self, curr: QtCore.QModelIndex | None, prev: QtCore.QModelIndex | None) -> None: if curr is None: