Merge branch 'mizaki-on_change_windows' into develop
This commit is contained in:
commit
7efef0bb44
@ -160,31 +160,10 @@ class IssueSelectionWindow(QtWidgets.QDialog):
|
||||
|
||||
for row, issue in enumerate(self.issue_list.values()):
|
||||
self.twList.insertRow(row)
|
||||
for i in range(3):
|
||||
self.twList.setItem(row, i, QtWidgets.QTableWidgetItem())
|
||||
|
||||
item_text = issue.issue or ""
|
||||
item = IssueNumberTableWidgetItem(item_text)
|
||||
item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text)
|
||||
item.setData(QtCore.Qt.ItemDataRole.UserRole, issue.issue_id)
|
||||
item.setData(QtCore.Qt.ItemDataRole.DisplayRole, item_text)
|
||||
item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||
self.twList.setItem(row, 0, item)
|
||||
|
||||
item_text = ""
|
||||
if issue.year is not None:
|
||||
item_text += f"-{issue.year:04}"
|
||||
if issue.month is not None:
|
||||
item_text += f"-{issue.month:02}"
|
||||
|
||||
qtw_item = QtWidgets.QTableWidgetItem(item_text.strip("-"))
|
||||
qtw_item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text)
|
||||
qtw_item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||
self.twList.setItem(row, 1, qtw_item)
|
||||
|
||||
item_text = issue.title or ""
|
||||
qtw_item = QtWidgets.QTableWidgetItem(item_text)
|
||||
qtw_item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text)
|
||||
qtw_item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||
self.twList.setItem(row, 2, qtw_item)
|
||||
self.update_row(row, issue)
|
||||
|
||||
if IssueString(issue.issue).as_string().casefold() == IssueString(self.issue_number).as_string().casefold():
|
||||
self.initial_id = issue.issue_id or ""
|
||||
@ -204,21 +183,56 @@ class IssueSelectionWindow(QtWidgets.QDialog):
|
||||
html = text
|
||||
widget.setHtml(html, QtCore.QUrl(self.talker.website))
|
||||
|
||||
def update_row(self, row: int, issue: GenericMetadata) -> None:
|
||||
item_text = issue.issue or ""
|
||||
item = self.twList.item(row, 0)
|
||||
item.setText(item_text)
|
||||
item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text)
|
||||
item.setData(QtCore.Qt.ItemDataRole.UserRole, issue.issue_id)
|
||||
item.setData(QtCore.Qt.ItemDataRole.DisplayRole, item_text)
|
||||
|
||||
item_text = ""
|
||||
if issue.year is not None:
|
||||
item_text += f"-{issue.year:04}"
|
||||
if issue.month is not None:
|
||||
item_text += f"-{issue.month:02}"
|
||||
|
||||
qtw_item = self.twList.item(row, 1)
|
||||
qtw_item.setText(item_text.strip("-"))
|
||||
qtw_item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text)
|
||||
qtw_item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||
|
||||
item_text = issue.title or ""
|
||||
qtw_item = self.twList.item(row, 2)
|
||||
qtw_item.setText(item_text)
|
||||
qtw_item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text)
|
||||
qtw_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:
|
||||
return
|
||||
if prev is not None and prev.row() == curr.row():
|
||||
return
|
||||
|
||||
self.issue_id = self.twList.item(curr.row(), 0).data(QtCore.Qt.ItemDataRole.UserRole)
|
||||
row = curr.row()
|
||||
self.issue_id = self.twList.item(row, 0).data(QtCore.Qt.ItemDataRole.UserRole)
|
||||
|
||||
# list selection was changed, update the the issue cover
|
||||
# list selection was changed, update the issue cover
|
||||
issue = self.issue_list[self.issue_id]
|
||||
if not (issue.issue and issue.year and issue.month and issue.cover_image):
|
||||
issue = self.talker.fetch_comic_data(issue_id=self.issue_id)
|
||||
if not (issue.issue and issue.year and issue.month and issue.cover_image and issue.title):
|
||||
QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor))
|
||||
try:
|
||||
issue = self.talker.fetch_comic_data(issue_id=self.issue_id)
|
||||
except TalkerError:
|
||||
pass
|
||||
QtWidgets.QApplication.restoreOverrideCursor()
|
||||
|
||||
self.issue_number = issue.issue or ""
|
||||
self.coverWidget.set_issue_details(self.issue_id, [issue.cover_image or "", *issue.alternate_images])
|
||||
if issue.description is None:
|
||||
self.set_description(self.teDescription, "")
|
||||
else:
|
||||
self.set_description(self.teDescription, issue.description)
|
||||
|
||||
# Update current record information
|
||||
self.update_row(row, issue)
|
||||
|
@ -481,36 +481,10 @@ class SeriesSelectionWindow(QtWidgets.QDialog):
|
||||
|
||||
for row, series in enumerate(self.series_list.values()):
|
||||
self.twList.insertRow(row)
|
||||
for i in range(4):
|
||||
self.twList.setItem(row, i, QtWidgets.QTableWidgetItem())
|
||||
|
||||
item_text = series.name
|
||||
item = QtWidgets.QTableWidgetItem(item_text)
|
||||
item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text)
|
||||
item.setData(QtCore.Qt.ItemDataRole.UserRole, series.id)
|
||||
item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||
self.twList.setItem(row, 0, item)
|
||||
|
||||
if series.start_year is not None:
|
||||
item_text = f"{series.start_year:04}"
|
||||
item = QtWidgets.QTableWidgetItem(item_text)
|
||||
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)
|
||||
self.twList.setItem(row, 1, item)
|
||||
|
||||
if series.count_of_issues is not None:
|
||||
item_text = f"{series.count_of_issues:04}"
|
||||
item = QtWidgets.QTableWidgetItem(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)
|
||||
self.twList.setItem(row, 2, item)
|
||||
|
||||
if series.publisher is not None:
|
||||
item_text = series.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)
|
||||
self.update_row(row, series)
|
||||
|
||||
self.twList.setSortingEnabled(True)
|
||||
self.twList.selectRow(0)
|
||||
@ -552,13 +526,42 @@ class SeriesSelectionWindow(QtWidgets.QDialog):
|
||||
html = text
|
||||
widget.setHtml(html, QUrl(self.talker.website))
|
||||
|
||||
def update_row(self, row: int, series: ComicSeries) -> None:
|
||||
item_text = series.name
|
||||
item = self.twList.item(row, 0)
|
||||
item.setText(item_text)
|
||||
item.setData(QtCore.Qt.ItemDataRole.ToolTipRole, item_text)
|
||||
item.setData(QtCore.Qt.ItemDataRole.UserRole, series.id)
|
||||
item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||
|
||||
item_text = str(series.start_year)
|
||||
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)
|
||||
|
||||
item_text = str(series.count_of_issues)
|
||||
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)
|
||||
|
||||
def current_item_changed(self, curr: QtCore.QModelIndex | None, prev: QtCore.QModelIndex | None) -> None:
|
||||
if curr is None:
|
||||
return
|
||||
if prev is not None and prev.row() == curr.row():
|
||||
return
|
||||
|
||||
self.series_id = self.twList.item(curr.row(), 0).data(QtCore.Qt.ItemDataRole.UserRole)
|
||||
row = curr.row()
|
||||
self.series_id = self.twList.item(row, 0).data(QtCore.Qt.ItemDataRole.UserRole)
|
||||
|
||||
# list selection was changed, update the info on the series
|
||||
series = self.series_list[self.series_id]
|
||||
@ -570,9 +573,19 @@ class SeriesSelectionWindow(QtWidgets.QDialog):
|
||||
and series.description
|
||||
and series.image_url
|
||||
):
|
||||
series = self.talker.fetch_series(self.series_id)
|
||||
QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor))
|
||||
# Changing of usernames and passwords with using cache can cause talker errors to crash out
|
||||
try:
|
||||
series = self.talker.fetch_series(self.series_id)
|
||||
except TalkerError:
|
||||
pass
|
||||
QtWidgets.QApplication.restoreOverrideCursor()
|
||||
|
||||
if series.description is None:
|
||||
self.set_description(self.teDetails, "")
|
||||
else:
|
||||
self.set_description(self.teDetails, series.description)
|
||||
self.imageWidget.set_url(series.image_url)
|
||||
|
||||
# Update current record information
|
||||
self.update_row(row, series)
|
||||
|
Loading…
Reference in New Issue
Block a user