Fixup section hiding
This commit is contained in:
parent
efde8fe7bc
commit
b9cb7cc326
@ -641,7 +641,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
Actions required:
|
Actions required:
|
||||||
- Reset track_sequence objects
|
- Reset track_sequence objects
|
||||||
- Tell model track has finished
|
- Tell playlist track has finished
|
||||||
- Reset clocks
|
- Reset clocks
|
||||||
- Update headers
|
- Update headers
|
||||||
- Enable controls
|
- Enable controls
|
||||||
@ -1122,7 +1122,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
- Restore volume if -3dB active
|
- Restore volume if -3dB active
|
||||||
- Play (new) current track.
|
- Play (new) current track.
|
||||||
- Show fade graph
|
- Show fade graph
|
||||||
- Notify model
|
- Notify playlist
|
||||||
- Note that track is now playing
|
- Note that track is now playing
|
||||||
- Disable play next controls
|
- Disable play next controls
|
||||||
- Update headers
|
- Update headers
|
||||||
@ -1188,9 +1188,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.catch_return_key = True
|
self.catch_return_key = True
|
||||||
self.show_status_message("Play controls: Disabled", 0)
|
self.show_status_message("Play controls: Disabled", 0)
|
||||||
|
|
||||||
# Notify model
|
# Notify playlist
|
||||||
log.debug("issue223: play_next: notify model")
|
log.debug("issue223: play_next: notify playlist")
|
||||||
self.active_proxy_model().current_track_started()
|
self.active_tab().current_track_started()
|
||||||
|
|
||||||
# Update headers
|
# Update headers
|
||||||
log.debug("issue223: play_next: update headers")
|
log.debug("issue223: play_next: update headers")
|
||||||
|
|||||||
@ -104,8 +104,8 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
def active_section_header(self) -> int:
|
def active_section_header(self) -> int:
|
||||||
"""
|
"""
|
||||||
Return the row number of the header above the first unplayed
|
Return the row number of the first header that has either unplayed tracks
|
||||||
or currently being played track.
|
or currently being played track below it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
header_row = 0
|
header_row = 0
|
||||||
@ -113,8 +113,24 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
for row_number in range(len(self.playlist_rows)):
|
for row_number in range(len(self.playlist_rows)):
|
||||||
if self.is_header_row(row_number):
|
if self.is_header_row(row_number):
|
||||||
header_row = row_number
|
header_row = row_number
|
||||||
elif not self.is_played_row(row_number):
|
continue
|
||||||
return header_row
|
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
|
return header_row
|
||||||
|
|
||||||
@ -1228,7 +1244,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
Return header text witout markers
|
Return header text witout markers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if header_text == '=':
|
if header_text == "=":
|
||||||
return ""
|
return ""
|
||||||
while header_text.endswith(Config.SECTION_STARTS):
|
while header_text.endswith(Config.SECTION_STARTS):
|
||||||
header_text = header_text[0:-1]
|
header_text = header_text[0:-1]
|
||||||
|
|||||||
@ -727,6 +727,23 @@ class PlaylistTab(QTableView):
|
|||||||
cb.clear(mode=cb.Mode.Clipboard)
|
cb.clear(mode=cb.Mode.Clipboard)
|
||||||
cb.setText(track_path, 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:
|
def _delete_rows(self) -> None:
|
||||||
"""
|
"""
|
||||||
Delete mutliple rows
|
Delete mutliple rows
|
||||||
@ -885,9 +902,6 @@ class PlaylistTab(QTableView):
|
|||||||
|
|
||||||
# Let the model know
|
# Let the model know
|
||||||
self.source_model.previous_track_ended()
|
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:
|
def _remove_comments(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user