WIP V3: section timings in place
This commit is contained in:
parent
6d648a56b7
commit
b399abb471
@ -339,7 +339,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.signals.span_cells_signal.emit(
|
self.signals.span_cells_signal.emit(
|
||||||
row, HEADER_NOTES_COLUMN, 1, self.columnCount() - 1
|
row, HEADER_NOTES_COLUMN, 1, self.columnCount() - 1
|
||||||
)
|
)
|
||||||
return QVariant(prd.note)
|
return QVariant(self.header_text(prd))
|
||||||
else:
|
else:
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
@ -459,6 +459,60 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
|
def header_text(self, prd: PlaylistRowData) -> str:
|
||||||
|
"""
|
||||||
|
Process possible section timing directives embeded in header
|
||||||
|
"""
|
||||||
|
|
||||||
|
count: int = 0
|
||||||
|
duration: int = 0
|
||||||
|
|
||||||
|
if prd.note.endswith("+"):
|
||||||
|
# This header is the start of a timed section
|
||||||
|
for row_number in range(prd.plr_rownum + 1, len(self.playlist_rows)):
|
||||||
|
row_prd = self.playlist_rows[row_number]
|
||||||
|
if self.is_header_row(row_number):
|
||||||
|
if row_prd.note.endswith("-"):
|
||||||
|
return (
|
||||||
|
f"{prd.note[:-1].strip()} "
|
||||||
|
f"[{count} tracks, {ms_to_mmss(duration)} unplayed]"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
count += 1
|
||||||
|
if not row_prd.played:
|
||||||
|
duration += row_prd.duration
|
||||||
|
return (
|
||||||
|
f"{prd.note[:-1].strip()} "
|
||||||
|
f"[{count} tracks, {ms_to_mmss(duration)} unplayed (to end of playlist)]"
|
||||||
|
)
|
||||||
|
elif prd.note.endswith("="):
|
||||||
|
# Show subtotal
|
||||||
|
for row_number in range(prd.plr_rownum - 1, -1, -1):
|
||||||
|
row_prd = self.playlist_rows[row_number]
|
||||||
|
if self.is_header_row(row_number):
|
||||||
|
if row_prd.note.endswith(("+", "=")):
|
||||||
|
stripped_note = prd.note[:-1].strip()
|
||||||
|
if stripped_note:
|
||||||
|
return (
|
||||||
|
f"{stripped_note} [{count} tracks, "
|
||||||
|
f"{ms_to_mmss(duration)} unplayed]"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return (
|
||||||
|
f"[Subtotal: {count} tracks, "
|
||||||
|
f"{ms_to_mmss(duration)} unplayed]"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
count += 1
|
||||||
|
if not row_prd.played:
|
||||||
|
duration += row_prd.duration
|
||||||
|
|
||||||
|
return prd.note
|
||||||
|
|
||||||
def is_header_row(self, row_number: int) -> bool:
|
def is_header_row(self, row_number: int) -> bool:
|
||||||
"""
|
"""
|
||||||
Return True if row is a header row, else False
|
Return True if row is a header row, else False
|
||||||
@ -656,7 +710,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
plr = session.get(PlaylistRows, plrid)
|
plr = session.get(PlaylistRows, plrid)
|
||||||
if plr:
|
if plr:
|
||||||
# Check this isn't a header row
|
# Check this isn't a header row
|
||||||
if plr.track is None:
|
if self.is_header_row(row_number):
|
||||||
return
|
return
|
||||||
# Check track is readable
|
# Check track is readable
|
||||||
if file_is_unreadable(plr.track.path):
|
if file_is_unreadable(plr.track.path):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user