diff --git a/app/musicmuster.py b/app/musicmuster.py index d799124..7dfc96f 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -859,7 +859,8 @@ class Window(QMainWindow, Ui_MainWindow): # Update all displayed playlists with Session() as session: for i in range(self.tabPlaylist.count()): - self.tabPlaylist.widget(i).update_display(session) + self.tabPlaylist.widget(i).hide_played_tracks( + self.hide_played_tracks) def import_track(self) -> None: """Import track file""" diff --git a/app/playlists.py b/app/playlists.py index 7ac73a1..c99c768 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -599,6 +599,21 @@ class PlaylistTab(QTableWidget): return [plr for plr in plrs if plr is not None] + def hide_played_tracks(self, hide: bool) -> None: + """Hide played tracks if hide is True else show them""" + + with Session() as session: + played = [ + p.row_number for p in PlaylistRows.get_played_rows( + session, self.playlist_id) + ] + for row in range(self.rowCount()): + if row in played: + if hide: + self.hideRow(row) + else: + self.showRow(row) + def insert_header(self, session: scoped_session, note: str) -> None: """ Insert section header into playlist tab.