Post editing fixes

Fix row or cell colour
Fix row height after expanding when editing starts
This commit is contained in:
Keith Edmunds 2023-03-08 20:09:15 +00:00
parent ae1835a421
commit 889d32cc90

View File

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