From 90697652b04111a636dd3e1192c4cd237aadc7c6 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Thu, 21 Mar 2024 16:57:37 +0000 Subject: [PATCH] Speed up row insertion --- app/playlists.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/playlists.py b/app/playlists.py index a8b8a26..e5118f9 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -726,7 +726,19 @@ class PlaylistTab(QTableView): if playlist_id != self.playlist_id: return - self.resizeRowsToContents() + # self.resizeRowsToContents() + # Suggestion from phind.com + def resize_row(row, count=1): + row_count = self.source_model.rowCount() + for todo in range(count): + if row < row_count: + self.resizeRowToContents(row) + row += 1 + if row < row_count: + QTimer.singleShot(0, lambda: resize_row(row, count)) + + # Start resizing from row 0, 10 rows at a time + QTimer.singleShot(0, lambda: resize_row(0, 10)) def scroll_to_top(self, row_number: int) -> None: """