Pull playlist changes from v2_editor

- minimum row height
- intelligent row resizing
This commit is contained in:
Keith Edmunds 2022-09-04 20:55:40 +01:00
parent 958edb0140
commit 6ede0ab7ea

View File

@ -57,6 +57,7 @@ from models import (
start_time_re = re.compile(r"@\d\d:\d\d:\d\d")
HEADER_NOTES_COLUMN = 2
MINIMUM_ROW_HEIGHT = 30
class RowMeta:
@ -149,6 +150,8 @@ class PlaylistTab(QTableWidget):
[a.heading for a in list(sorted(columns.values(),
key=lambda item: item.idx))]
)
self.horizontalHeader().sectionResized.connect(
self.resizeRowsToContents)
self.setAcceptDrops(True)
self.viewport().setAcceptDrops(True)
@ -1021,9 +1024,6 @@ class PlaylistTab(QTableWidget):
(self.item(row, columns['row_notes'].idx)
.setBackground(QColor(note_colour)))
# Ensure content is visible by wrapping cells
self.resizeRowToContents(row)
# Highlight low bitrates
if track.bitrate:
if track.bitrate < Config.BITRATE_LOW_THRESHOLD:
@ -1125,8 +1125,6 @@ class PlaylistTab(QTableWidget):
self._set_row_colour(row, QColor(note_colour))
# Section headers are always bold
self._set_row_bold(row)
# Ensure content is visible by wrapping cells
self.resizeRowToContents(row)
continue
# Have we had a section start but not end?
@ -1136,10 +1134,12 @@ class PlaylistTab(QTableWidget):
self._get_section_timing_string(section_time, no_end=True)
)
# Ensure content is visible by wrapping cells
self.resizeRowToContents(row)
# Scroll to put next track Config.SCROLL_TOP_MARGIN from the
# top. Rows number from zero, so set (current_row -
# Config.SCROLL_TOP_MARGIN + 1) row to be top row
if next_row is not None:
top_row = max(0, next_row - Config.SCROLL_TOP_MARGIN + 1)
scroll_item = self.item(top_row, 0)