Always update rows even if None

This commit is contained in:
Mizaki 2023-10-05 22:14:45 +01:00
parent 80f3dd7ce4
commit 5bdbe7d181
2 changed files with 19 additions and 24 deletions

View File

@ -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)

View File

@ -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: