Improve resize rows speed

This commit is contained in:
Keith Edmunds 2024-03-22 14:21:37 +00:00
parent 90697652b0
commit 50b051a864
2 changed files with 7 additions and 11 deletions

View File

@ -789,7 +789,7 @@ class Window(QMainWindow, Ui_MainWindow):
self.active_proxy_model().hide_played_tracks(True) self.active_proxy_model().hide_played_tracks(True)
self.btnHidePlayed.setText("Show played") self.btnHidePlayed.setText("Show played")
# Reset row heights # Reset row heights
self.active_tab().resizeRowsToContents() self.active_tab().resize_rows()
def import_track(self) -> None: def import_track(self) -> None:
"""Import track file""" """Import track file"""
@ -1503,11 +1503,7 @@ class Window(QMainWindow, Ui_MainWindow):
def tab_change(self): def tab_change(self):
"""Called when active tab changed""" """Called when active tab changed"""
log.info("tab_change()") self.active_tab().resize_rows()
tab = self.active_tab()
if tab:
QTimer.singleShot(300, tab.resizeRowsToContents)
def tick_10ms(self) -> None: def tick_10ms(self) -> None:
""" """

View File

@ -209,7 +209,7 @@ class PlaylistTab(QTableView):
h_header.sectionResized.connect(self._column_resize) h_header.sectionResized.connect(self._column_resize)
h_header.setStretchLastSection(True) h_header.setStretchLastSection(True)
# Setting ResizeToContents causes screen flash on load # Setting ResizeToContents causes screen flash on load
QTimer.singleShot(300, self.resizeRowsToContents) self.resize_rows()
# ########## Overridden class functions ########## # ########## Overridden class functions ##########
@ -225,7 +225,7 @@ class PlaylistTab(QTableView):
super(PlaylistTab, self).closeEditor(editor, hint) super(PlaylistTab, self).closeEditor(editor, hint)
# Optimise row heights after increasing row height for editing # Optimise row heights after increasing row height for editing
self.resizeRowsToContents() self.resize_rows()
# Update start times in case a start time in a note has been # Update start times in case a start time in a note has been
# edited # edited
@ -260,7 +260,7 @@ class PlaylistTab(QTableView):
self.clear_selection() self.clear_selection()
# Resize rows # Resize rows
self.resizeRowsToContents() self.resize_rows()
event.accept() event.accept()
@ -716,14 +716,14 @@ class PlaylistTab(QTableView):
self.source_model.rescan_track(row_number) self.source_model.rescan_track(row_number)
self.clear_selection() self.clear_selection()
def resize_rows(self, playlist_id: int) -> None: def resize_rows(self, playlist_id: Optional[int] = None) -> None:
""" """
If playlist_id is us, resize rows If playlist_id is us, resize rows
""" """
log.info(f"resize_rows({playlist_id=}) {self.playlist_id=}") log.info(f"resize_rows({playlist_id=}) {self.playlist_id=}")
if playlist_id != self.playlist_id: if playlist_id and playlist_id != self.playlist_id:
return return
# self.resizeRowsToContents() # self.resizeRowsToContents()