From 03f19dfb9c4236250bac56307ffb02af9bfe816f Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Fri, 1 Dec 2023 17:08:13 +0000 Subject: [PATCH] Improve loading time for long playlists Fixes #199 --- app/playlistmodel.py | 11 +++++------ app/playlists.py | 7 ++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/playlistmodel.py b/app/playlistmodel.py index 32bcffd..0eb3469 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -220,12 +220,11 @@ class PlaylistModel(QAbstractTableModel): else: return QBrush(QColor(Config.COLOUR_BITRATE_OK)) if column == Col.NOTE.value: - with Session() as session: - note_colour = NoteColours.get_colour(session, prd.note) - if note_colour: - return QBrush(QColor(note_colour)) - else: - return QBrush() + if prd.note: + with Session() as session: + note_colour = NoteColours.get_colour(session, prd.note) + if note_colour: + return QBrush(QColor(note_colour)) return QBrush() diff --git a/app/playlists.py b/app/playlists.py index b9914bd..ff0ebb0 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -671,12 +671,9 @@ class PlaylistTab(QTableView): if not header: return - # Set width of last column to zero as it's set to stretch - self.setColumnWidth(header.count() - 1, 0) - - # Set remaining column widths from settings + # Last column is set to stretch so ignore it here with Session() as session: - for column_number in range(header.count() - 1): + for column_number in range(header.count() - 2): attr_name = f"playlist_col_{column_number}_width" record = Settings.get_int_settings(session, attr_name) if record.f_int is not None: