parent
7e7ae7dddf
commit
e8d9cf8f00
@ -288,7 +288,6 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# Update Playdates in database
|
# Update Playdates in database
|
||||||
log.debug(f"{self}: update playdates {track_id=}")
|
log.debug(f"{self}: update playdates {track_id=}")
|
||||||
Playdates(session, track_id)
|
Playdates(session, track_id)
|
||||||
session.commit()
|
|
||||||
|
|
||||||
# Mark track as played in playlist
|
# Mark track as played in playlist
|
||||||
log.debug(f"{self}: Mark track as played")
|
log.debug(f"{self}: Mark track as played")
|
||||||
@ -298,39 +297,41 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.refresh_row(session, plr.row_number)
|
self.refresh_row(session, plr.row_number)
|
||||||
else:
|
else:
|
||||||
log.error(
|
log.error(
|
||||||
f"{self}: Can't retrieve plr, {track_sequence.current.playlistrow_id=}"
|
f"{self}: Can't retrieve plr, "
|
||||||
|
f"{track_sequence.current.playlistrow_id=}"
|
||||||
)
|
)
|
||||||
|
session.commit()
|
||||||
|
|
||||||
# Update colour and times for current row
|
# Update colour and times for current row
|
||||||
|
# only invalidate required roles
|
||||||
|
roles = [
|
||||||
|
Qt.ItemDataRole.DisplayRole
|
||||||
|
]
|
||||||
|
self.invalidate_row(row_number, roles)
|
||||||
|
|
||||||
|
# Update previous row in case we're hiding played rows
|
||||||
|
if track_sequence.previous and track_sequence.previous.row_number:
|
||||||
# only invalidate required roles
|
# only invalidate required roles
|
||||||
roles = [
|
self.invalidate_row(track_sequence.previous.row_number, roles)
|
||||||
Qt.ItemDataRole.DisplayRole
|
|
||||||
]
|
|
||||||
self.invalidate_row(row_number, roles)
|
|
||||||
|
|
||||||
# Update previous row in case we're hiding played rows
|
# Update all other track times
|
||||||
if track_sequence.previous and track_sequence.previous.row_number:
|
self.update_track_times()
|
||||||
# only invalidate required roles
|
|
||||||
self.invalidate_row(track_sequence.previous.row_number, roles)
|
|
||||||
|
|
||||||
# Update all other track times
|
# Find next track
|
||||||
self.update_track_times()
|
next_row = None
|
||||||
|
unplayed_rows = [
|
||||||
# Find next track
|
a
|
||||||
next_row = None
|
for a in self.get_unplayed_rows()
|
||||||
unplayed_rows = [
|
if not self.is_header_row(a)
|
||||||
a
|
and not file_is_unreadable(self.playlist_rows[a].path)
|
||||||
for a in self.get_unplayed_rows()
|
]
|
||||||
if not self.is_header_row(a)
|
if unplayed_rows:
|
||||||
and not file_is_unreadable(self.playlist_rows[a].path)
|
try:
|
||||||
]
|
next_row = min([a for a in unplayed_rows if a > row_number])
|
||||||
if unplayed_rows:
|
except ValueError:
|
||||||
try:
|
next_row = min(unplayed_rows)
|
||||||
next_row = min([a for a in unplayed_rows if a > row_number])
|
if next_row is not None:
|
||||||
except ValueError:
|
self.set_next_row(next_row)
|
||||||
next_row = min(unplayed_rows)
|
|
||||||
if next_row is not None:
|
|
||||||
self.set_next_row(next_row)
|
|
||||||
|
|
||||||
def data(
|
def data(
|
||||||
self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole
|
self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user