Improve type hints, rework code

Fixes #147
This commit is contained in:
Keith Edmunds 2023-02-05 17:38:56 +00:00
parent 9e6c700644
commit e4ef0b34c8

View File

@ -1869,40 +1869,29 @@ class PlaylistTab(QTableWidget):
column = HEADER_NOTES_COLUMN column = HEADER_NOTES_COLUMN
# Update text # Update text
new_text = playlist_row.note + additional_text if playlist_row.note:
# FIXME temporary workaround to issue #147 new_text = playlist_row.note + additional_text
try: else:
self.item(playlist_row.row_number, column).setText(new_text) new_text = additional_text
except AttributeError as exc:
msg = f"Issue 147 occurred. {playlist_row=}, {additional_text=}" _ = self._set_item_text(playlist_row.row_number, column, new_text)
msg += "\n\n"
msg += stackprinter.format(exc)
helpers.send_mail(Config.ERRORS_TO, Confit.ERRORS_FROM,
"Issue #147 from musicmuster", msg)
def _update_row(self, session, row: int, track: Tracks) -> None: def _update_row(self, session, row: int, track: Tracks) -> None:
""" """
Update the passed row with info from the passed track. Update the passed row with info from the passed track.
""" """
item_startgap = self.item(row, START_GAP) start_gap_item = self._set_item_text(
item_startgap.setText(str(track.start_gap)) row, START_GAP, str(track.start_gap))
if track.start_gap >= 500: if track.start_gap and track.start_gap >= 500:
item_startgap.setBackground(QColor(Config.COLOUR_LONG_START)) start_gap_item.setBackground(QColor(Config.COLOUR_LONG_START))
else: else:
item_startgap.setBackground(QColor("white")) start_gap_item.setBackground(QColor("white"))
item_title = self.item(row, TITLE) _ = self._set_item_text(row, TITLE, track.title)
item_title.setText(track.title) _ = self._set_item_text(row, ARTIST, track.artist)
_ = self._set_item_text(row, DURATION, track.duration)
item_artist = self.item(row, ARTIST) _ = self._set_item_text(row, BITRATE, track.bitrate)
item_artist.setText(track.artist)
item_duration = self.item(row, DURATION)
item_duration.setText(ms_to_mmss(track.duration))
item_bitrate = self.item(row, BITRATE)
item_bitrate.setText(str(track.bitrate))
self.update_display(session) self.update_display(session)