Update headers when editing current/next track

Fixes #126
This commit is contained in:
Keith Edmunds 2022-09-30 22:25:40 +01:00
parent c3712eba27
commit 5d3d373abc
2 changed files with 19 additions and 0 deletions

View File

@ -949,6 +949,18 @@ class Window(QMainWindow, Ui_MainWindow):
if self.playing: if self.playing:
self.stop_playing() self.stop_playing()
def update_current_track(self, track):
"""Update current track with passed details"""
self.current_track = TrackData(track)
self.update_headers()
def update_next_track(self, track):
"""Update next track with passed details"""
self.next_track = TrackData(track)
self.update_headers()
def update_headers(self) -> None: def update_headers(self) -> None:
""" """
Update last / current / next track headers Update last / current / next track headers

View File

@ -432,10 +432,17 @@ class PlaylistTab(QTableWidget):
if track_id: if track_id:
track = session.get(Tracks, track_id) track = session.get(Tracks, track_id)
if track: if track:
update_current = row == self._get_current_track_row()
update_next = row == self._get_next_track_row()
if self.edit_cell_type == "title": if self.edit_cell_type == "title":
track.title = new_text track.title = new_text
elif self.edit_cell_type == "artist": elif self.edit_cell_type == "artist":
track.artist = new_text track.artist = new_text
if update_current:
self.musicmuster.update_current_track(track)
elif update_next:
self.musicmuster.update_next_track(track)
# Headers will be incorrect if the edited track is # Headers will be incorrect if the edited track is
# previous / current / next TODO: this will require # previous / current / next TODO: this will require
# the stored data in musicmuster to be updated, # the stored data in musicmuster to be updated,