Change intro gap warning to 300ms
This commit is contained in:
parent
4816520343
commit
30b836895e
177
app/playlists.py
177
app/playlists.py
@ -725,185 +725,8 @@ class PlaylistTab(QTableView):
|
||||
def _unmark_as_next(self) -> None:
|
||||
"""Rescan track"""
|
||||
|
||||
<<<<<<< HEAD
|
||||
self.data_model.set_next_row(None)
|
||||
self.clear_selection()
|
||||
||||||| parent of 705f3ea (Fix bug with unended timed section)
|
||||
# Reorder rows
|
||||
new_order = [a[0] for a in sorted_rows]
|
||||
self.sort_undo = [
|
||||
new_order.index(x) + min(new_order)
|
||||
for x in range(min(new_order), max(new_order) + 1)
|
||||
]
|
||||
self._reorder_rows(new_order)
|
||||
|
||||
# Reset drag mode to allow row selection by dragging
|
||||
self.setDragEnabled(False)
|
||||
|
||||
# Save playlist
|
||||
with Session() as session:
|
||||
self.save_playlist(session)
|
||||
self._update_start_end_times(session)
|
||||
|
||||
def _sort_undo(self):
|
||||
"""Undo last sort"""
|
||||
|
||||
if not self.sort_undo:
|
||||
return
|
||||
|
||||
new_order = self.sort_undo
|
||||
|
||||
self._reorder_rows(new_order)
|
||||
|
||||
self.sort_undo = [
|
||||
new_order.index(x) + min(new_order)
|
||||
for x in range(min(new_order), max(new_order) + 1)
|
||||
]
|
||||
|
||||
# Reset drag mode to allow row selection by dragging
|
||||
self.setDragEnabled(False)
|
||||
|
||||
# Save playlist
|
||||
with Session() as session:
|
||||
self.save_playlist(session)
|
||||
self._update_start_end_times(session)
|
||||
|
||||
def _unplayed_track_time_between_rows(
|
||||
self, session: scoped_session, from_plr: PlaylistRows, to_plr: PlaylistRows
|
||||
) -> int:
|
||||
"""
|
||||
Returns the total unplayed duration of all tracks in rows between
|
||||
from_row and to_row inclusive
|
||||
"""
|
||||
|
||||
plr_tracks = PlaylistRows.get_rows_with_tracks(
|
||||
session, self.playlist_id, from_plr.plr_rownum, to_plr.plr_rownum
|
||||
)
|
||||
|
||||
unplayed_time = 0
|
||||
unplayed_time = sum(
|
||||
[a.track.duration for a in plr_tracks if a.track.duration and not a.played]
|
||||
)
|
||||
|
||||
return unplayed_time
|
||||
|
||||
def _update_row_track_info(
|
||||
self, session: scoped_session, row: int, track: Tracks
|
||||
) -> None:
|
||||
"""
|
||||
Update the passed row with info from the passed track.
|
||||
"""
|
||||
|
||||
_ = self._set_row_artist(row, track.artist)
|
||||
_ = self._set_row_bitrate(row, track.bitrate)
|
||||
_ = self._set_row_duration(row, track.duration)
|
||||
_ = self._set_row_end_time(row, None)
|
||||
if track.playdates:
|
||||
last_play = max([a.lastplayed for a in track.playdates])
|
||||
else:
|
||||
last_play = Config.EPOCH
|
||||
_ = self._set_row_last_played_time(row, last_play)
|
||||
_ = self._set_row_start_gap(row, track.start_gap)
|
||||
_ = self._set_row_start_time(row, None)
|
||||
_ = self._set_row_title(row, track.title)
|
||||
_ = self._set_row_track_id(row, track.id)
|
||||
_ = self._set_row_track_path(row, track.path)
|
||||
|
||||
if file_is_unreadable(track.path):
|
||||
self._set_row_colour_unreadable(row)
|
||||
|
||||
def _update_section_headers(self, session: scoped_session) -> None:
|
||||
"""
|
||||
Update section headers with run time of section
|
||||
"""
|
||||
|
||||
section_start_rows: List[PlaylistRows] = []
|
||||
subtotal_from: Optional[PlaylistRows] = None
|
||||
active_row: Optional[int] = None
|
||||
active_endtime: Optional[datetime] = None
|
||||
current_row_prlid = self.musicmuster.current_track.plr_id
|
||||
if current_row_prlid:
|
||||
current_row = self._plrid_to_row_number(current_row_prlid)
|
||||
if current_row:
|
||||
active_row = current_row
|
||||
active_end = self.musicmuster.current_track.end_time
|
||||
else:
|
||||
previous_row_plrid = self.musicmuster.previous_track.plr_id
|
||||
if previous_row_plrid:
|
||||
previous_row = self._plrid_to_row_number(previous_row_plrid)
|
||||
if previous_row:
|
||||
active_row = previous_row
|
||||
active_end = self.musicmuster.previous_track.end_time
|
||||
|
||||
header_rows = [
|
||||
self._get_row_plr_id(row_number)
|
||||
for row_number in range(self.rowCount())
|
||||
if self._get_row_track_id(row_number) == 0
|
||||
]
|
||||
plrs = PlaylistRows.plrids_to_plrs(session, self.playlist_id, header_rows)
|
||||
for plr in plrs:
|
||||
# Start of timed section
|
||||
if plr.note.endswith("+"):
|
||||
section_start_rows.append(plr)
|
||||
subtotal_from = plr
|
||||
continue
|
||||
# End of timed section
|
||||
elif plr.note.endswith("-"):
|
||||
try:
|
||||
from_plr = section_start_rows.pop()
|
||||
to_plr = plr
|
||||
unplayed_time = self._unplayed_track_time_between_rows(
|
||||
session, from_plr, to_plr
|
||||
)
|
||||
if (
|
||||
active_row
|
||||
and active_row >= from_plr.plr_rownum
|
||||
and active_row <= to_plr.plr_rownum
|
||||
):
|
||||
time_str = self._get_section_timing_string(
|
||||
unplayed_time, active_end
|
||||
)
|
||||
else:
|
||||
time_str = self._get_section_timing_string(unplayed_time, None)
|
||||
self._set_row_header_text(
|
||||
session, from_plr.plr_rownum, from_plr.note + time_str
|
||||
)
|
||||
|
||||
# Update section end
|
||||
if to_plr.note.strip() == "-":
|
||||
new_text = (
|
||||
"[End "
|
||||
+ re.sub(
|
||||
section_header_cleanup_re,
|
||||
"",
|
||||
from_plr.note,
|
||||
).strip()
|
||||
+ "]"
|
||||
)
|
||||
self._set_row_header_text(session, to_plr.plr_rownum, new_text)
|
||||
subtotal_from = None
|
||||
except IndexError:
|
||||
# This ending row may have a time left from before a
|
||||
# starting row above was deleted, so replace content
|
||||
self._set_row_header_text(session, plr.plr_rownum, plr.note)
|
||||
continue
|
||||
# Subtotal
|
||||
elif plr.note.endswith("="):
|
||||
if not subtotal_from:
|
||||
return
|
||||
from_plr = subtotal_from
|
||||
to_plr = plr
|
||||
unplayed_time = self._unplayed_track_time_between_rows(
|
||||
session, subtotal_from, to_plr
|
||||
)
|
||||
if (
|
||||
active_row
|
||||
and active_row >= from_plr.plr_rownum
|
||||
and active_row <= to_plr.plr_rownum
|
||||
):
|
||||
time_str = self._get_section_timing_string(
|
||||
unplayed_time, active_end
|
||||
)
|
||||
else:
|
||||
time_str = self._get_section_timing_string(unplayed_time, None)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user