From 889d32cc90eefcccd1a66a3b5e39309683919cfc Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Wed, 8 Mar 2023 20:09:15 +0000 Subject: [PATCH] Post editing fixes Fix row or cell colour Fix row height after expanding when editing starts --- app/playlists.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/app/playlists.py b/app/playlists.py index adac8db..9b351c3 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -374,6 +374,9 @@ class PlaylistTab(QTableWidget): super(PlaylistTab, self).closeEditor(editor, hint) + # Optimise row heights after increasing row height for editing + self.resizeRowsToContents() + # Update start times in case a start time in a note has been # edited self._update_start_end_times() @@ -1672,6 +1675,21 @@ class PlaylistTab(QTableWidget): else: self.musicmuster.lblSumPlaytime.setText("") + def _set_cell_colour(self, row: int, column: int, + colour: Optional[QColor] = None) -> None: + """ + Set or reset a cell background colour + """ + + if colour: + brush = QBrush(colour) + else: + brush = QBrush() + + item = self.item(row, column) + if item: + item.setBackground(brush) + def _set_column_widths(self, session: scoped_session) -> None: """Column widths from settings""" @@ -1917,12 +1935,16 @@ class PlaylistTab(QTableWidget): notes_item = self._set_item_text(row, column, note_text) note_colour = NoteColours.get_colour(session, note_text) - if section_header and not note_colour: note_colour = Config.COLOUR_NOTES_PLAYLIST - if note_colour: - notes_item.setBackground(QColor(note_colour)) + new_colour = QColor(note_colour) + else: + new_colour = None + if section_header: + self._set_row_colour(row, new_colour) + else: + self._set_cell_colour(row, column, new_colour) return notes_item