WIP: playlists.py refactor

Hide/show played tracks
This commit is contained in:
Keith Edmunds 2023-02-19 20:36:08 +00:00
parent 19377a8e1c
commit 6de95573ff
2 changed files with 17 additions and 1 deletions

View File

@ -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"""

View File

@ -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.