Move track to under current makes it next track

Fixes #261
This commit is contained in:
Keith Edmunds 2024-11-16 13:04:11 +00:00
parent 3cec08db85
commit 98a8e20baa
2 changed files with 26 additions and 0 deletions

View File

@ -1083,6 +1083,16 @@ class Window(QMainWindow, Ui_MainWindow):
else:
destination_row = self.active_proxy_model().rowCount()
# If we move a row to immediately under the current track, make
# that moved row the next track
set_next_row: Optional[int] = None
if (
track_sequence.current
and track_sequence.current.playlist_id == to_playlist_model.playlist_id
and destination_row == track_sequence.current.row_number + 1
):
set_next_row = destination_row
if (
to_playlist_model.playlist_id
== self.move_source_model.source_model.playlist_id
@ -1095,6 +1105,9 @@ class Window(QMainWindow, Ui_MainWindow):
self.active_tab().resize_rows()
self.active_tab().clear_selection()
if set_next_row:
to_playlist_model.set_next_row(set_next_row)
def play_next(self, position: Optional[float] = None) -> None:
"""
Play next track, optionally from passed position.

View File

@ -296,6 +296,15 @@ class PlaylistTab(QTableView):
and 0 <= max(from_rows) <= self.source_model.rowCount()
and 0 <= to_model_row <= self.source_model.rowCount()
):
# If we move a row to immediately under the current track, make
# that moved row the next track
set_next_row: Optional[int] = None
if (
track_sequence.current
and to_model_row == track_sequence.current.row_number + 1
):
set_next_row = to_model_row
self.source_model.move_rows(from_rows, to_model_row)
# Reset drag mode to allow row selection by dragging
@ -307,6 +316,10 @@ class PlaylistTab(QTableView):
# Resize rows
self.resize_rows()
# Set next row if we are immediately under current row
if set_next_row:
self.source_model.set_next_row(set_next_row)
event.accept()
def mouseReleaseEvent(self, event):