Compare commits
No commits in common. "634637f42cbe77aca7a6ecc8a33ab55bd4501964" and "e23f8afed2ed16bd0e1bc0e86399a6543989a388" have entirely different histories.
634637f42c
...
e23f8afed2
@ -601,11 +601,10 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
playlist_name: Optional[str] = None) -> Playlists:
|
playlist_name: Optional[str] = None) -> Playlists:
|
||||||
"""Create new playlist"""
|
"""Create new playlist"""
|
||||||
|
|
||||||
playlist_name = self.solicit_playlist_name()
|
while not playlist_name:
|
||||||
if not playlist_name:
|
playlist_name = self.solicit_playlist_name()
|
||||||
return
|
|
||||||
playlist = Playlists(session, playlist_name)
|
|
||||||
|
|
||||||
|
playlist = Playlists(session, playlist_name)
|
||||||
return playlist
|
return playlist
|
||||||
|
|
||||||
def create_and_show_playlist(self) -> None:
|
def create_and_show_playlist(self) -> None:
|
||||||
|
|||||||
@ -1411,17 +1411,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
|
|
||||||
return self.musicmuster.current_track.end_time
|
return self.musicmuster.current_track.end_time
|
||||||
|
|
||||||
def _get_current_track_start_time(self) -> Optional[datetime]:
|
|
||||||
"""
|
|
||||||
Return current track start time or None if no current track
|
|
||||||
"""
|
|
||||||
|
|
||||||
current_track_row = self._get_current_track_row_number()
|
|
||||||
if current_track_row is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return self.musicmuster.current_track.start_time
|
|
||||||
|
|
||||||
def _get_current_track_row_number(self) -> Optional[int]:
|
def _get_current_track_row_number(self) -> Optional[int]:
|
||||||
"""Return current track row or None"""
|
"""Return current track row or None"""
|
||||||
|
|
||||||
@ -2162,18 +2151,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
|
|
||||||
return self._set_item_text(row, START_TIME, time_str)
|
return self._set_item_text(row, START_TIME, time_str)
|
||||||
|
|
||||||
def _set_row_times(self, row: int, start: datetime,
|
|
||||||
duration: int) -> datetime:
|
|
||||||
"""
|
|
||||||
Set row start and end times, return end time
|
|
||||||
"""
|
|
||||||
|
|
||||||
self._set_row_start_time(row, start)
|
|
||||||
end_time = self._calculate_end_time(start, duration)
|
|
||||||
self._set_row_end_time(row, end_time)
|
|
||||||
|
|
||||||
return end_time
|
|
||||||
|
|
||||||
def _set_row_title(self, row: int,
|
def _set_row_title(self, row: int,
|
||||||
title: Optional[str]) -> QTableWidgetItem:
|
title: Optional[str]) -> QTableWidgetItem:
|
||||||
"""
|
"""
|
||||||
@ -2259,11 +2236,11 @@ class PlaylistTab(QTableWidget):
|
|||||||
def _update_start_end_times(self) -> None:
|
def _update_start_end_times(self) -> None:
|
||||||
""" Update track start and end times """
|
""" Update track start and end times """
|
||||||
|
|
||||||
|
next_start_time = None
|
||||||
|
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
current_track_end_time = self._get_current_track_end_time()
|
current_track_end_time = self._get_current_track_end_time()
|
||||||
current_track_row = self._get_current_track_row_number()
|
current_track_row = self._get_current_track_row_number()
|
||||||
current_track_start_time = self._get_current_track_start_time()
|
|
||||||
next_start_time = None
|
|
||||||
next_track_row = self._get_next_track_row_number()
|
next_track_row = self._get_next_track_row_number()
|
||||||
played_rows = self._get_played_rows(session)
|
played_rows = self._get_played_rows(session)
|
||||||
|
|
||||||
@ -2274,52 +2251,60 @@ class PlaylistTab(QTableWidget):
|
|||||||
current_track_row, next_track_row]:
|
current_track_row, next_track_row]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Get any timing from header row (that's all we need)
|
a_track_row = self._get_row_track_id(row) > 0
|
||||||
if self._get_row_track_id(row) == 0:
|
if not a_track_row:
|
||||||
note_time = self._get_section_start_time(session, row)
|
note_time = self._get_section_start_time(session, row)
|
||||||
if note_time:
|
if note_time:
|
||||||
next_start_time = note_time
|
next_start_time = note_time
|
||||||
|
# We have any timings from note; there's no track; go to
|
||||||
|
# next row
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# We have a track. Skip if it is unreadable
|
# Here means we have a track. Skip if track is
|
||||||
|
# unreadable
|
||||||
if not file_is_readable(self._get_row_path(row)):
|
if not file_is_readable(self._get_row_path(row)):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Set next track start from end of current track
|
|
||||||
if row == next_track_row:
|
if row == next_track_row:
|
||||||
|
# If we have a current track, set this next track start
|
||||||
|
# time from it
|
||||||
if current_track_end_time:
|
if current_track_end_time:
|
||||||
next_start_time = self._set_row_times(
|
self._set_row_start_time(row, current_track_end_time)
|
||||||
row, current_track_end_time,
|
next_start_time = self._calculate_end_time(
|
||||||
|
current_track_end_time,
|
||||||
self._get_row_duration(row))
|
self._get_row_duration(row))
|
||||||
|
self._set_row_end_time(row, next_start_time)
|
||||||
continue
|
continue
|
||||||
# Else set track times below
|
# Fall through to set times if next_start_time is
|
||||||
|
# set
|
||||||
|
|
||||||
if row == current_track_row:
|
if row == current_track_row:
|
||||||
if not current_track_start_time:
|
track_start = self.musicmuster.current_track.start_time
|
||||||
|
if not track_start:
|
||||||
continue
|
continue
|
||||||
self._set_row_start_time(row, current_track_start_time)
|
self._set_row_start_time(row, track_start)
|
||||||
self._set_row_end_time(row, current_track_end_time)
|
next_start_time = self._calculate_end_time(
|
||||||
# Next track may be above us so only reset
|
track_start, self._get_row_duration(row))
|
||||||
# next_start_time if it's not set
|
self._set_row_end_time(row, next_start_time)
|
||||||
if not next_start_time:
|
|
||||||
next_start_time = current_track_end_time
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not next_start_time:
|
if not next_start_time:
|
||||||
# Clear any existing times
|
|
||||||
self._set_row_start_time(row, None)
|
|
||||||
self._set_row_end_time(row, None)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# If we're between the current and next row, zero out
|
# If we're between the current and next row, zero out
|
||||||
# times
|
# times
|
||||||
if (current_track_row and next_track_row and
|
if (
|
||||||
current_track_row < row < next_track_row):
|
current_track_row and
|
||||||
|
next_track_row and
|
||||||
|
current_track_row < row < next_track_row
|
||||||
|
):
|
||||||
self._set_row_start_time(row, None)
|
self._set_row_start_time(row, None)
|
||||||
self._set_row_end_time(row, None)
|
self._set_row_end_time(row, None)
|
||||||
else:
|
else:
|
||||||
next_start_time = self._set_row_times(
|
self._set_row_start_time(row, next_start_time)
|
||||||
row, next_start_time, self._get_row_duration(row))
|
next_start_time = self._calculate_end_time(
|
||||||
|
next_start_time, self._get_row_duration(row))
|
||||||
|
self._set_row_end_time(row, next_start_time)
|
||||||
|
|
||||||
def _wikipedia(self, row_number: int) -> None:
|
def _wikipedia(self, row_number: int) -> None:
|
||||||
"""Look up passed row title in Wikipedia and display info tab"""
|
"""Look up passed row title in Wikipedia and display info tab"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user