Speed up row insertion

This commit is contained in:
Keith Edmunds 2024-03-21 16:57:37 +00:00
parent 1363010da8
commit 90697652b0

View File

@ -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:
"""