Section timing now works
This commit is contained in:
parent
56fb1aeb3d
commit
29857e1185
105
app/playlists.py
105
app/playlists.py
@ -988,7 +988,7 @@ class PlaylistTab(QTableWidget):
|
||||
else:
|
||||
filter_text = None
|
||||
next_start_time = None
|
||||
section_start_row = None
|
||||
section_start_plr = None
|
||||
section_time = 0
|
||||
|
||||
# Start time calculations
|
||||
@ -1023,7 +1023,7 @@ class PlaylistTab(QTableWidget):
|
||||
continue
|
||||
|
||||
# Add track time to section time if in timed section
|
||||
if section_start_row is not None:
|
||||
if section_start_plr is not None:
|
||||
section_time += track.duration
|
||||
|
||||
# If filtering, only show matching tracks
|
||||
@ -1135,14 +1135,16 @@ class PlaylistTab(QTableWidget):
|
||||
if row_time:
|
||||
next_start_time = row_time
|
||||
# Does it delimit a section?
|
||||
if section_start_row is not None:
|
||||
if section_start_plr is not None:
|
||||
if note_text.endswith("-"):
|
||||
self._set_timed_section(session, section_start_row,
|
||||
section_time)
|
||||
section_start_row = None
|
||||
self._update_note_text(
|
||||
section_start_plr,
|
||||
self._get_section_timing_string(section_time)
|
||||
)
|
||||
section_start_plr = None
|
||||
section_time = 0
|
||||
elif note_text.endswith("+"):
|
||||
section_start_row = row
|
||||
section_start_plr = playlist_row
|
||||
section_time = 0
|
||||
self._set_row_colour(
|
||||
row, QColor(note_colour)
|
||||
@ -1152,9 +1154,11 @@ class PlaylistTab(QTableWidget):
|
||||
continue
|
||||
|
||||
# Have we had a section start but not end?
|
||||
if section_start_row is not None:
|
||||
self._set_timed_section(
|
||||
session, section_start_row, section_time, no_end=True)
|
||||
if section_start_plr is not None:
|
||||
self._update_note_text(
|
||||
section_start_plr,
|
||||
self._get_section_timing_string(section_time, no_end=True)
|
||||
)
|
||||
#
|
||||
# # ########## Internally called functions ##########
|
||||
|
||||
@ -1856,43 +1860,52 @@ class PlaylistTab(QTableWidget):
|
||||
"""Mark this row as unreadable"""
|
||||
|
||||
self._meta_set_attribute(row, RowMeta.UNREADABLE)
|
||||
#
|
||||
# def _select_tracks(self, played: bool) -> None:
|
||||
# """
|
||||
# Select all played (played=True) or unplayed (played=False)
|
||||
# tracks in playlist
|
||||
# """
|
||||
#
|
||||
# # Need to allow multiple rows to be selected
|
||||
# self.setSelectionMode(QAbstractItemView.MultiSelection)
|
||||
# self.clear_selection()
|
||||
#
|
||||
# if played:
|
||||
# rows = self._get_played_track_rows()
|
||||
# else:
|
||||
# rows = self._get_unplayed_track_rows()
|
||||
#
|
||||
# for row in rows:
|
||||
# self.selectRow(row)
|
||||
#
|
||||
# # Reset extended selection
|
||||
# self.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
||||
#
|
||||
# def _select_tracks(self, played: bool) -> None:
|
||||
# """
|
||||
# Select all played (played=True) or unplayed (played=False)
|
||||
# tracks in playlist
|
||||
# """
|
||||
#
|
||||
# # Need to allow multiple rows to be selected
|
||||
# self.setSelectionMode(QAbstractItemView.MultiSelection)
|
||||
# self.clear_selection()
|
||||
#
|
||||
# if played:
|
||||
# rows = self._get_played_track_rows()
|
||||
# else:
|
||||
# rows = self._get_unplayed_track_rows()
|
||||
#
|
||||
# for row in rows:
|
||||
# self.selectRow(row)
|
||||
#
|
||||
# # Reset extended selection
|
||||
# self.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
||||
|
||||
#
|
||||
# def _set_timed_section(self, session, start_row, ms, no_end=False):
|
||||
# """Add duration to a marked section"""
|
||||
#
|
||||
# duration = ms_to_mmss(ms)
|
||||
# note_object = self._get_row_notes_object(start_row, session)
|
||||
# if not note_object:
|
||||
# log.error("Can't get note_object in playlists._set_timed_section")
|
||||
# note_text = note_object.note
|
||||
# caveat = ""
|
||||
# if no_end:
|
||||
# caveat = " (to end of playlist)"
|
||||
# display_text = note_text + ' [' + duration + caveat + ']'
|
||||
# item = self.item(start_row, FIXUP.COL_TITLE)
|
||||
# item.setText(display_text)
|
||||
def _get_section_timing_string(self, ms: int,
|
||||
no_end: bool = False) -> None:
|
||||
"""Return string describing section duration"""
|
||||
|
||||
duration = ms_to_mmss(ms)
|
||||
caveat = ""
|
||||
if no_end:
|
||||
caveat = " (to end of playlist)"
|
||||
return ' [' + duration + caveat + ']'
|
||||
|
||||
def _update_note_text(self, playlist_row: PlaylistRows,
|
||||
additional_text: str) -> None:
|
||||
"""Append additional_text to row display"""
|
||||
|
||||
# Column to update is either 1 for a section header or the
|
||||
# appropriate row_notes column for a track row
|
||||
if playlist_row.track_id:
|
||||
column = columns['row_notes'].idx
|
||||
else:
|
||||
column = 1
|
||||
|
||||
# Update text
|
||||
new_text = playlist_row.note + additional_text
|
||||
self.item(playlist_row.row_number, column).setText(new_text)
|
||||
|
||||
def _update_row(self, session, row: int, track: Tracks) -> None:
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user