From 50b051a864aec84ed51c3084e1e99cfcb9f1533b Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Fri, 22 Mar 2024 14:21:37 +0000 Subject: [PATCH] Improve resize rows speed --- app/musicmuster.py | 8 ++------ app/playlists.py | 10 +++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/musicmuster.py b/app/musicmuster.py index 5fc139f..dd9ac9b 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -789,7 +789,7 @@ class Window(QMainWindow, Ui_MainWindow): self.active_proxy_model().hide_played_tracks(True) self.btnHidePlayed.setText("Show played") # Reset row heights - self.active_tab().resizeRowsToContents() + self.active_tab().resize_rows() def import_track(self) -> None: """Import track file""" @@ -1503,11 +1503,7 @@ class Window(QMainWindow, Ui_MainWindow): def tab_change(self): """Called when active tab changed""" - log.info("tab_change()") - - tab = self.active_tab() - if tab: - QTimer.singleShot(300, tab.resizeRowsToContents) + self.active_tab().resize_rows() def tick_10ms(self) -> None: """ diff --git a/app/playlists.py b/app/playlists.py index e5118f9..1a3d871 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -209,7 +209,7 @@ class PlaylistTab(QTableView): h_header.sectionResized.connect(self._column_resize) h_header.setStretchLastSection(True) # Setting ResizeToContents causes screen flash on load - QTimer.singleShot(300, self.resizeRowsToContents) + self.resize_rows() # ########## Overridden class functions ########## @@ -225,7 +225,7 @@ class PlaylistTab(QTableView): super(PlaylistTab, self).closeEditor(editor, hint) # 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 # edited @@ -260,7 +260,7 @@ class PlaylistTab(QTableView): self.clear_selection() # Resize rows - self.resizeRowsToContents() + self.resize_rows() event.accept() @@ -716,14 +716,14 @@ class PlaylistTab(QTableView): self.source_model.rescan_track(row_number) 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 """ 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 # self.resizeRowsToContents()