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