parent
a51dd3a998
commit
30d8b0d5c8
@ -1516,71 +1516,67 @@ class PlaylistProxyModel(QSortFilterProxyModel):
|
|||||||
|
|
||||||
def filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) -> bool:
|
def filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) -> bool:
|
||||||
"""
|
"""
|
||||||
Subclass to filter by played status
|
Subclass to filter by played status. Return True to show this row, False to hide it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.source_model.played_tracks_hidden:
|
if self.source_model.played_tracks_hidden:
|
||||||
if self.source_model.is_played_row(source_row):
|
if self.source_model.is_played_row(source_row):
|
||||||
# Don't hide current or next track
|
# Don't hide current track
|
||||||
with db.Session() as session:
|
if (
|
||||||
if track_sequence.next:
|
track_sequence.current
|
||||||
next_plr = session.get(PlaylistRows, track_sequence.next.plr_id)
|
and track_sequence.current.playlist_id == self.source_model.playlist_id
|
||||||
if (
|
and track_sequence.current.row_number == source_row
|
||||||
next_plr
|
):
|
||||||
and next_plr.plr_rownum == source_row
|
return True
|
||||||
and next_plr.playlist_id == self.source_model.playlist_id
|
|
||||||
):
|
|
||||||
return True
|
|
||||||
if track_sequence.current:
|
|
||||||
now_plr = session.get(
|
|
||||||
PlaylistRows, track_sequence.current.plr_id
|
|
||||||
)
|
|
||||||
if (
|
|
||||||
now_plr
|
|
||||||
and now_plr.plr_rownum == source_row
|
|
||||||
and now_plr.playlist_id == self.source_model.playlist_id
|
|
||||||
):
|
|
||||||
return True
|
|
||||||
# Don't hide previous track until
|
|
||||||
# HIDE_AFTER_PLAYING_OFFSET milliseconds after
|
|
||||||
# current track has started
|
|
||||||
if track_sequence.previous:
|
|
||||||
previous_plr = session.get(
|
|
||||||
PlaylistRows, track_sequence.previous.plr_id
|
|
||||||
)
|
|
||||||
if (
|
|
||||||
track_sequence.current
|
|
||||||
and previous_plr
|
|
||||||
and previous_plr.plr_rownum == source_row
|
|
||||||
and previous_plr.playlist_id
|
|
||||||
== self.source_model.playlist_id
|
|
||||||
):
|
|
||||||
if track_sequence.current.start_time:
|
|
||||||
if dt.datetime.now() > (
|
|
||||||
track_sequence.current.start_time
|
|
||||||
+ dt.timedelta(
|
|
||||||
milliseconds=Config.HIDE_AFTER_PLAYING_OFFSET
|
|
||||||
)
|
|
||||||
):
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
# Invalidate this row in
|
|
||||||
# HIDE_AFTER_PLAYING_OFFSET and a
|
|
||||||
# bit milliseconds
|
|
||||||
# so that it hides then - add 100mS
|
|
||||||
# on so that it if clause above it
|
|
||||||
# true next time through.
|
|
||||||
QTimer.singleShot(
|
|
||||||
Config.HIDE_AFTER_PLAYING_OFFSET + 100,
|
|
||||||
lambda: self.source_model.invalidate_row(
|
|
||||||
source_row
|
|
||||||
),
|
|
||||||
)
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
# Don't hide next track
|
||||||
|
if (
|
||||||
|
track_sequence.next
|
||||||
|
and track_sequence.next.playlist_id == self.source_model.playlist_id
|
||||||
|
and track_sequence.next.row_number == source_row
|
||||||
|
):
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Handle previous track
|
||||||
|
if track_sequence.previous:
|
||||||
|
if (
|
||||||
|
track_sequence.previous.playlist_id != self.source_model.playlist_id
|
||||||
|
or track_sequence.previous.row_number != source_row
|
||||||
|
):
|
||||||
|
# This row isn't our previous track: hide it
|
||||||
|
return False
|
||||||
|
if track_sequence.current and track_sequence.current.start_time:
|
||||||
|
# This row is our previous track. Don't hide it
|
||||||
|
# until HIDE_AFTER_PLAYING_OFFSET milliseconds
|
||||||
|
# after current track has started
|
||||||
|
if (
|
||||||
|
track_sequence.current.start_time
|
||||||
|
and dt.datetime.now() > (
|
||||||
|
track_sequence.current.start_time
|
||||||
|
+ dt.timedelta(milliseconds=Config.HIDE_AFTER_PLAYING_OFFSET)
|
||||||
|
)
|
||||||
|
):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
# Invalidate this row in
|
||||||
|
# HIDE_AFTER_PLAYING_OFFSET and a bit
|
||||||
|
# milliseconds so that it hides then. We add
|
||||||
|
# 100mS on so that the if clause above is
|
||||||
|
# true next time through.
|
||||||
|
QTimer.singleShot(
|
||||||
|
Config.HIDE_AFTER_PLAYING_OFFSET + 100,
|
||||||
|
lambda: self.source_model.invalidate_row(
|
||||||
|
source_row
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
# Next track not playing yet so don't hide previous
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# No previous track so hide this played track immediately
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return super().filterAcceptsRow(source_row, source_parent)
|
return super().filterAcceptsRow(source_row, source_parent)
|
||||||
|
|
||||||
def set_incremental_search(self, search_string: str) -> None:
|
def set_incremental_search(self, search_string: str) -> None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user