parent
b4fcd5f2c9
commit
7cfd2a45a2
@ -990,12 +990,28 @@ class PlaylistModel(QAbstractTableModel):
|
||||
|
||||
@line_profiler.profile
|
||||
def refresh_data(self, session: db.session, dummy_for_profiling=None) -> None:
|
||||
"""Populate dicts for data calls"""
|
||||
"""Populate self.playlist_rows with playlist data"""
|
||||
|
||||
# Populate self.playlist_rows with playlist data
|
||||
self.playlist_rows.clear()
|
||||
# We used to clear self.playlist_rows each time but that's
|
||||
# expensive and slow on big playlists
|
||||
|
||||
# Note where each playlist_id is
|
||||
plid_to_row: dict[int, int] = {}
|
||||
for oldrow in self.playlist_rows:
|
||||
plrdata = self.playlist_rows[oldrow]
|
||||
plid_to_row[plrdata.playlistrow_id] = plrdata.row_number
|
||||
|
||||
# build a new playlist_rows
|
||||
new_playlist_rows: dict[int, RowAndTrack] = {}
|
||||
for p in PlaylistRows.get_playlist_rows(session, self.playlist_id):
|
||||
self.playlist_rows[p.row_number] = RowAndTrack(p)
|
||||
if p.id not in plid_to_row:
|
||||
new_playlist_rows[p.row_number] = RowAndTrack(p)
|
||||
else:
|
||||
new_playlist_rows[p.row_number] = self.playlist_rows[plid_to_row[p.id]]
|
||||
new_playlist_rows[p.row_number].row_number = p.row_number
|
||||
|
||||
# Copy to self.playlist_rows
|
||||
self.playlist_rows = new_playlist_rows
|
||||
|
||||
def refresh_row(self, session, row_number):
|
||||
"""Populate dict for one row from database"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user