From 5d95748640c5189715f36cdc435bbe4b87524cef Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 10 Feb 2024 15:52:03 +0000 Subject: [PATCH] Possibly fix row deleting bug Fixes #220 --- app/playlistmodel.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/playlistmodel.py b/app/playlistmodel.py index ff0948a..6dfc3d8 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -370,11 +370,15 @@ class PlaylistModel(QAbstractTableModel): with Session() as session: for row_number in row_numbers: super().beginRemoveRows(QModelIndex(), row_number, row_number) + # We need to remove data from the underlying data store, + # which is the database, but we cache in + # self.playlist_rows, which is what calls to data() + # reads, so fixup that too. PlaylistRows.delete_row(session, self.playlist_id, row_number) + PlaylistRows.fixup_rownumbers(session, self.playlist_id) + self.refresh_data(session) super().endRemoveRows() - PlaylistRows.fixup_rownumbers(session, self.playlist_id) - self.refresh_data(session) self.reset_track_sequence_row_numbers() def display_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant: @@ -1422,7 +1426,7 @@ class PlaylistProxyModel(QSortFilterProxyModel): self.setFilterKeyColumn(-1) def __repr__(self) -> str: - return (f"") + return f"" def filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) -> bool: """