From 9d3743ceb5e6cbdbaec099d8482948f6156edb55 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Tue, 28 Feb 2023 21:27:48 +0000 Subject: [PATCH] Update section timer and end of section note --- app/playlists.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/app/playlists.py b/app/playlists.py index 9c45412..d21c9ec 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -2198,6 +2198,19 @@ class PlaylistTab(QTableWidget): self.musicmuster.tabInfolist.open_in_songfacts(title) + def _update_note_text(self, playlist_row: PlaylistRows, + new_text: str) -> None: + """Update note text""" + + # Column to update is either HEADER_NOTES_COLUMN for a section + # header or the appropriate row_notes column for a track row + if playlist_row.track_id: + column = ROW_NOTES + else: + column = HEADER_NOTES_COLUMN + + _ = 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. @@ -2235,12 +2248,16 @@ class PlaylistTab(QTableWidget): total_time = 0 total_time = sum([a.track.duration for a in plr_tracks]) - import ipdb; ipdb.set_trace() time_str = self._get_section_timing_string(total_time) - new_text = self._get_row_note(from_row) + time_str - _ = self._set_row_note(session, from_row, new_text) + self._update_note_text(from_plr, from_plr.note + time_str) + # Update section end + if plr.note.strip() == "-": + new_text = ( + "[End " + from_plr.note.strip()[:-1].strip() + "]" + ) + self._update_note_text(plr, new_text) def _update_start_end_times(self) -> None: """ Update track start and end times """