V3 tweaks and polishes
This commit is contained in:
parent
f8093bc642
commit
f9b8f1d8d3
@ -65,7 +65,7 @@ from dbconfig import (
|
|||||||
from dialogs import TrackSelectDialog
|
from dialogs import TrackSelectDialog
|
||||||
from log import log
|
from log import log
|
||||||
from models import Base, Carts, Playdates, PlaylistRows, Playlists, Settings, Tracks
|
from models import Base, Carts, Playdates, PlaylistRows, Playlists, Settings, Tracks
|
||||||
from playlistmodel import PlaylistModel
|
from playlistmodel import PlaylistModel, PlaylistProxyModel
|
||||||
from playlists import PlaylistTab
|
from playlists import PlaylistTab
|
||||||
from ui.dlg_cart_ui import Ui_DialogCartEdit # type: ignore
|
from ui.dlg_cart_ui import Ui_DialogCartEdit # type: ignore
|
||||||
from ui.dlg_SelectPlaylist_ui import Ui_dlgSelectPlaylist # type: ignore
|
from ui.dlg_SelectPlaylist_ui import Ui_dlgSelectPlaylist # type: ignore
|
||||||
@ -218,7 +218,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.active_tab = lambda: self.tabPlaylist.currentWidget()
|
self.active_tab = lambda: self.tabPlaylist.currentWidget()
|
||||||
self.active_model = lambda: self.tabPlaylist.currentWidget().model()
|
self.active_model = lambda: self.tabPlaylist.currentWidget().model()
|
||||||
self.move_source_rows: Optional[List[int]] = None
|
self.move_source_rows: Optional[List[int]] = None
|
||||||
self.move_source_model: Optional[PlaylistModel] = None
|
self.move_source_model: Optional[PlaylistProxyModel] = None
|
||||||
|
|
||||||
self.load_last_playlists()
|
self.load_last_playlists()
|
||||||
if Config.CARTS_HIDE:
|
if Config.CARTS_HIDE:
|
||||||
@ -1021,7 +1021,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
else:
|
else:
|
||||||
destination_row = self.active_model().rowCount()
|
destination_row = self.active_model().rowCount()
|
||||||
|
|
||||||
if to_playlist_id == self.move_source_model.playlist_id:
|
if to_playlist_id == self.move_source_model.data_model.playlist_id:
|
||||||
self.move_source_model.move_rows(self.move_source_rows, destination_row)
|
self.move_source_model.move_rows(self.move_source_rows, destination_row)
|
||||||
else:
|
else:
|
||||||
self.move_source_model.move_rows_between_playlists(
|
self.move_source_model.move_rows_between_playlists(
|
||||||
|
|||||||
@ -356,7 +356,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
PlaylistRows.fixup_rownumbers(session, self.playlist_id)
|
PlaylistRows.fixup_rownumbers(session, self.playlist_id)
|
||||||
self.refresh_data(session)
|
self.refresh_data(session)
|
||||||
self.row_order_changed(self.playlist_id)
|
self.reset_track_sequence_row_numbers()
|
||||||
|
|
||||||
def display_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant:
|
def display_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant:
|
||||||
"""
|
"""
|
||||||
@ -414,7 +414,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
with Session() as session:
|
with Session() as session:
|
||||||
self.refresh_data(session)
|
self.refresh_data(session)
|
||||||
super().endResetModel()
|
super().endResetModel()
|
||||||
self.row_order_changed(self.playlist_id)
|
self.reset_track_sequence_row_numbers()
|
||||||
|
|
||||||
def edit_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant:
|
def edit_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant:
|
||||||
"""
|
"""
|
||||||
@ -708,7 +708,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.refresh_data(session)
|
self.refresh_data(session)
|
||||||
super().endInsertRows()
|
super().endInsertRows()
|
||||||
|
|
||||||
self.row_order_changed(self.playlist_id)
|
self.reset_track_sequence_row_numbers()
|
||||||
self.invalidate_rows(list(range(new_row_number, len(self.playlist_rows))))
|
self.invalidate_rows(list(range(new_row_number, len(self.playlist_rows))))
|
||||||
|
|
||||||
def invalidate_row(self, modified_row: int) -> None:
|
def invalidate_row(self, modified_row: int) -> None:
|
||||||
@ -819,7 +819,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.refresh_data(session)
|
self.refresh_data(session)
|
||||||
|
|
||||||
# Update display
|
# Update display
|
||||||
self.signals.row_order_changed_signal.emit(self.playlist_id)
|
self.reset_track_sequence_row_numbers()
|
||||||
self.invalidate_rows(list(row_map.keys()))
|
self.invalidate_rows(list(row_map.keys()))
|
||||||
|
|
||||||
def mark_unplayed(self, row_numbers: List[int]) -> None:
|
def mark_unplayed(self, row_numbers: List[int]) -> None:
|
||||||
@ -887,7 +887,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.refresh_data(session)
|
self.refresh_data(session)
|
||||||
|
|
||||||
# Reset of model must come after session has been closed
|
# Reset of model must come after session has been closed
|
||||||
self.signals.row_order_changed_signal.emit(self.playlist_id)
|
self.reset_track_sequence_row_numbers()
|
||||||
self.signals.row_order_changed_signal.emit(to_playlist_id)
|
self.signals.row_order_changed_signal.emit(to_playlist_id)
|
||||||
self.signals.end_reset_model_signal.emit(to_playlist_id)
|
self.signals.end_reset_model_signal.emit(to_playlist_id)
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
@ -1033,6 +1033,31 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.invalidate_row(row_number)
|
self.invalidate_row(row_number)
|
||||||
self.signals.resize_rows_signal.emit(self.playlist_id)
|
self.signals.resize_rows_signal.emit(self.playlist_id)
|
||||||
|
|
||||||
|
def reset_track_sequence_row_numbers(self) -> None:
|
||||||
|
"""
|
||||||
|
Signal handler for when row ordering has changed
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Check the track_sequence next, now and previous plrs and
|
||||||
|
# update the row number
|
||||||
|
with Session() as session:
|
||||||
|
if track_sequence.next.plr_rownum:
|
||||||
|
next_plr = session.get(PlaylistRows, track_sequence.next.plr_id)
|
||||||
|
if next_plr:
|
||||||
|
track_sequence.next.plr_rownum = next_plr.plr_rownum
|
||||||
|
if track_sequence.now.plr_rownum:
|
||||||
|
now_plr = session.get(PlaylistRows, track_sequence.now.plr_id)
|
||||||
|
if now_plr:
|
||||||
|
track_sequence.now.plr_rownum = now_plr.plr_rownum
|
||||||
|
if track_sequence.previous.plr_rownum:
|
||||||
|
previous_plr = session.get(
|
||||||
|
PlaylistRows, track_sequence.previous.plr_id
|
||||||
|
)
|
||||||
|
if previous_plr:
|
||||||
|
track_sequence.previous.plr_rownum = previous_plr.plr_rownum
|
||||||
|
|
||||||
|
self.update_track_times()
|
||||||
|
|
||||||
def _reversed_contiguous_row_groups(
|
def _reversed_contiguous_row_groups(
|
||||||
self, row_numbers: List[int]
|
self, row_numbers: List[int]
|
||||||
) -> List[List[int]]:
|
) -> List[List[int]]:
|
||||||
@ -1071,26 +1096,11 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
Signal handler for when row ordering has changed
|
Signal handler for when row ordering has changed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Only action if this is for us
|
||||||
if playlist_id != self.playlist_id:
|
if playlist_id != self.playlist_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
with Session() as session:
|
self.reset_track_sequence_row_numbers()
|
||||||
if track_sequence.next.plr_rownum:
|
|
||||||
next_plr = session.get(PlaylistRows, track_sequence.next.plr_rownum)
|
|
||||||
if next_plr:
|
|
||||||
track_sequence.next.plr_rownum = next_plr.plr_rownum
|
|
||||||
if track_sequence.now.plr_rownum:
|
|
||||||
now_plr = session.get(PlaylistRows, track_sequence.now.plr_rownum)
|
|
||||||
if now_plr:
|
|
||||||
track_sequence.now.plr_rownum = now_plr.plr_rownum
|
|
||||||
if track_sequence.previous.plr_rownum:
|
|
||||||
previous_plr = session.get(
|
|
||||||
PlaylistRows, track_sequence.previous.plr_rownum
|
|
||||||
)
|
|
||||||
if previous_plr:
|
|
||||||
track_sequence.previous.plr_rownum = previous_plr.plr_rownum
|
|
||||||
|
|
||||||
self.update_track_times()
|
|
||||||
|
|
||||||
def selection_is_sortable(self, row_numbers: List[int]) -> bool:
|
def selection_is_sortable(self, row_numbers: List[int]) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user