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