WIP V3: move unplayed rows
This commit is contained in:
parent
80c363c316
commit
551a574eac
@ -973,13 +973,10 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
Move unplayed rows to another playlist
|
Move unplayed rows to another playlist
|
||||||
"""
|
"""
|
||||||
|
|
||||||
playlist_id = self.active_tab().playlist_id
|
unplayed_rows = self.active_model().get_unplayed_rows()
|
||||||
with Session() as session:
|
if not unplayed_rows:
|
||||||
unplayed_plrs = PlaylistRows.get_unplayed_rows(session, playlist_id)
|
return
|
||||||
if helpers.ask_yes_no(
|
self.move_playlist_rows(unplayed_rows)
|
||||||
"Move tracks", f"Move {len(unplayed_plrs)} tracks:" " Are you sure?"
|
|
||||||
):
|
|
||||||
self.move_playlist_rows(session, unplayed_plrs)
|
|
||||||
|
|
||||||
def new_from_template(self) -> None:
|
def new_from_template(self) -> None:
|
||||||
"""Create new playlist from template"""
|
"""Create new playlist from template"""
|
||||||
|
|||||||
@ -297,11 +297,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# Find next track
|
# Find next track
|
||||||
# Get all unplayed track rows
|
# Get all unplayed track rows
|
||||||
next_row = None
|
next_row = None
|
||||||
unplayed_rows = [
|
unplayed_rows = self.get_unplayed_rows()
|
||||||
a.plr_rownum
|
|
||||||
for a in PlaylistRows.get_unplayed_rows(session, self.playlist_id)
|
|
||||||
]
|
|
||||||
|
|
||||||
if unplayed_rows:
|
if unplayed_rows:
|
||||||
try:
|
try:
|
||||||
# Find next row after current track
|
# Find next row after current track
|
||||||
@ -542,6 +538,13 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return self.playlist_rows[row_number]
|
return self.playlist_rows[row_number]
|
||||||
|
|
||||||
|
def get_unplayed_rows(self) -> List[int]:
|
||||||
|
"""
|
||||||
|
Return a list of unplayed row numbers
|
||||||
|
"""
|
||||||
|
|
||||||
|
return [a.plr_rownum for a in self.playlist_rows.values() if not a.played]
|
||||||
|
|
||||||
def headerData(
|
def headerData(
|
||||||
self,
|
self,
|
||||||
section: int,
|
section: int,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user