Fixup section hiding
This commit is contained in:
parent
efde8fe7bc
commit
b9cb7cc326
@ -641,7 +641,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
|
||||
Actions required:
|
||||
- Reset track_sequence objects
|
||||
- Tell model track has finished
|
||||
- Tell playlist track has finished
|
||||
- Reset clocks
|
||||
- Update headers
|
||||
- Enable controls
|
||||
@ -1122,7 +1122,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
- Restore volume if -3dB active
|
||||
- Play (new) current track.
|
||||
- Show fade graph
|
||||
- Notify model
|
||||
- Notify playlist
|
||||
- Note that track is now playing
|
||||
- Disable play next controls
|
||||
- Update headers
|
||||
@ -1188,9 +1188,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.catch_return_key = True
|
||||
self.show_status_message("Play controls: Disabled", 0)
|
||||
|
||||
# Notify model
|
||||
log.debug("issue223: play_next: notify model")
|
||||
self.active_proxy_model().current_track_started()
|
||||
# Notify playlist
|
||||
log.debug("issue223: play_next: notify playlist")
|
||||
self.active_tab().current_track_started()
|
||||
|
||||
# Update headers
|
||||
log.debug("issue223: play_next: update headers")
|
||||
|
||||
@ -104,8 +104,8 @@ class PlaylistModel(QAbstractTableModel):
|
||||
|
||||
def active_section_header(self) -> int:
|
||||
"""
|
||||
Return the row number of the header above the first unplayed
|
||||
or currently being played track.
|
||||
Return the row number of the first header that has either unplayed tracks
|
||||
or currently being played track below it.
|
||||
"""
|
||||
|
||||
header_row = 0
|
||||
@ -113,8 +113,24 @@ class PlaylistModel(QAbstractTableModel):
|
||||
for row_number in range(len(self.playlist_rows)):
|
||||
if self.is_header_row(row_number):
|
||||
header_row = row_number
|
||||
elif not self.is_played_row(row_number):
|
||||
return header_row
|
||||
continue
|
||||
if not self.is_played_row(row_number):
|
||||
break
|
||||
|
||||
# If track is played, we need to check it's not the current
|
||||
# next or previous track because we don't want to scroll them
|
||||
# out of view
|
||||
|
||||
for ts in [
|
||||
track_sequence.next,
|
||||
track_sequence.current,
|
||||
track_sequence.previous,
|
||||
]:
|
||||
if ts and ts.row_number == row_number and ts.playlist_id == self.playlist_id:
|
||||
break
|
||||
else:
|
||||
continue # continue iterating over playlist_rows
|
||||
break # current row is in one of the track sequences
|
||||
|
||||
return header_row
|
||||
|
||||
@ -1228,7 +1244,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
Return header text witout markers
|
||||
"""
|
||||
|
||||
if header_text == '=':
|
||||
if header_text == "=":
|
||||
return ""
|
||||
while header_text.endswith(Config.SECTION_STARTS):
|
||||
header_text = header_text[0:-1]
|
||||
|
||||
@ -727,6 +727,23 @@ class PlaylistTab(QTableView):
|
||||
cb.clear(mode=cb.Mode.Clipboard)
|
||||
cb.setText(track_path, mode=cb.Mode.Clipboard)
|
||||
|
||||
def current_track_started(self) -> None:
|
||||
"""
|
||||
Called when track starts playing
|
||||
"""
|
||||
|
||||
self.source_model.current_track_started()
|
||||
# Scroll to current section if hide mode is by section
|
||||
if (
|
||||
self.musicmuster.hide_played_tracks
|
||||
and Config.HIDE_PLAYED_MODE == Config.HIDE_PLAYED_MODE_SECTIONS
|
||||
):
|
||||
# Hide section after delay
|
||||
QTimer.singleShot(
|
||||
Config.HIDE_AFTER_PLAYING_OFFSET + 100,
|
||||
lambda: self.hide_played_sections(),
|
||||
)
|
||||
|
||||
def _delete_rows(self) -> None:
|
||||
"""
|
||||
Delete mutliple rows
|
||||
@ -885,9 +902,6 @@ class PlaylistTab(QTableView):
|
||||
|
||||
# Let the model know
|
||||
self.source_model.previous_track_ended()
|
||||
# Scroll to current section if hide mode is by section
|
||||
if Config.HIDE_PLAYED_MODE == Config.HIDE_PLAYED_MODE_SECTIONS:
|
||||
self.hide_played_sections()
|
||||
|
||||
def _remove_comments(self) -> None:
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user