Compare commits

..

No commits in common. "dfc51e1399b77461ab633e2f4e551b2d358b3f89" and "80687df82e508dbc14bf0b1a36e525cea7dd9870" have entirely different histories.

4 changed files with 3 additions and 63 deletions

View File

@ -59,7 +59,6 @@ class Config(object):
HIDE_AFTER_PLAYING_OFFSET = 5000 HIDE_AFTER_PLAYING_OFFSET = 5000
INFO_TAB_TITLE_LENGTH = 15 INFO_TAB_TITLE_LENGTH = 15
LAST_PLAYED_TODAY_STRING = "Today" LAST_PLAYED_TODAY_STRING = "Today"
LAST_PLAYED_TOOLTIP_DATE_FORMAT = "%a, %d %b %Y"
LOG_LEVEL_STDERR = logging.INFO LOG_LEVEL_STDERR = logging.INFO
LOG_LEVEL_SYSLOG = logging.INFO LOG_LEVEL_SYSLOG = logging.INFO
LOG_NAME = "musicmuster" LOG_NAME = "musicmuster"

View File

@ -129,20 +129,6 @@ class Playdates(dbtables.PlaydatesTable):
session.add(self) session.add(self)
session.commit() session.commit()
@staticmethod
def last_playdates(session: Session, track_id: int, limit=5) -> Sequence["Playdates"]:
"""
Return a list of the last limit playdates for this track, sorted
earliest to latest.
"""
return session.scalars(
Playdates.select()
.where(Playdates.track_id == track_id)
.order_by(Playdates.lastplayed.asc())
.limit(limit)
).all()
@staticmethod @staticmethod
def last_played(session: Session, track_id: int) -> dt.datetime: def last_played(session: Session, track_id: int) -> dt.datetime:
"""Return datetime track last played or None""" """Return datetime track last played or None"""
@ -161,19 +147,6 @@ class Playdates(dbtables.PlaydatesTable):
# last_played value # last_played value
return Config.EPOCH # pragma: no cover return Config.EPOCH # pragma: no cover
@staticmethod
def last_played_tracks(session: Session, limit=5) -> Sequence["Playdates"]:
"""
Return a list of the last limit tracks played, sorted
earliest to latest.
"""
return session.scalars(
Playdates.select()
.order_by(Playdates.lastplayed.desc())
.limit(limit)
).all()
@staticmethod @staticmethod
def played_after(session: Session, since: dt.datetime) -> Sequence["Playdates"]: def played_after(session: Session, since: dt.datetime) -> Sequence["Playdates"]:
"""Return a list of Playdates objects since passed time""" """Return a list of Playdates objects since passed time"""

View File

@ -1178,15 +1178,6 @@ class Window(QMainWindow, Ui_MainWindow):
# Update headers # Update headers
log.debug("update headers") log.debug("update headers")
self.update_headers() self.update_headers()
with db.Session() as session:
last_played = Playdates.last_played_tracks(session)
tracklist = []
for lp in last_played:
track = session.get(Tracks, lp.track_id)
tracklist.append(f"{track.title} ({track.artist})")
tt = "<br>".join(reversed(tracklist))
self.hdrPreviousTrack.setToolTip(tt)
def preview(self) -> None: def preview(self) -> None:
""" """

View File

@ -349,11 +349,10 @@ class PlaylistModel(QAbstractTableModel):
# Dispatch to role-specific functions # Dispatch to role-specific functions
dispatch_table = { dispatch_table = {
int(Qt.ItemDataRole.BackgroundRole): self.background_role,
int(Qt.ItemDataRole.DisplayRole): self.display_role, int(Qt.ItemDataRole.DisplayRole): self.display_role,
int(Qt.ItemDataRole.EditRole): self.edit_role, int(Qt.ItemDataRole.EditRole): self.edit_role,
int(Qt.ItemDataRole.FontRole): self.font_role, int(Qt.ItemDataRole.FontRole): self.font_role,
int(Qt.ItemDataRole.ToolTipRole): self.tooltip_role, int(Qt.ItemDataRole.BackgroundRole): self.background_role,
} }
if role in dispatch_table: if role in dispatch_table:
@ -362,6 +361,7 @@ class PlaylistModel(QAbstractTableModel):
# Document other roles but don't use them # Document other roles but don't use them
if role in [ if role in [
Qt.ItemDataRole.DecorationRole, Qt.ItemDataRole.DecorationRole,
Qt.ItemDataRole.ToolTipRole,
Qt.ItemDataRole.StatusTipRole, Qt.ItemDataRole.StatusTipRole,
Qt.ItemDataRole.WhatsThisRole, Qt.ItemDataRole.WhatsThisRole,
Qt.ItemDataRole.SizeHintRole, Qt.ItemDataRole.SizeHintRole,
@ -860,9 +860,7 @@ class PlaylistModel(QAbstractTableModel):
# number of rows being move from above the destination row # number of rows being move from above the destination row
# otherwise rows below the destination row will end up above the # otherwise rows below the destination row will end up above the
# moved rows. # moved rows.
adjusted_to_row = to_row_number - len( adjusted_to_row = to_row_number - len([a for a in from_rows if a <= to_row_number])
[a for a in from_rows if a <= to_row_number]
)
# Put the from_row row numbers into the row_map. Ultimately the # Put the from_row row numbers into the row_map. Ultimately the
# total number of elements in the playlist doesn't change, so # total number of elements in the playlist doesn't change, so
@ -1379,27 +1377,6 @@ class PlaylistModel(QAbstractTableModel):
def supportedDropActions(self) -> Qt.DropAction: def supportedDropActions(self) -> Qt.DropAction:
return Qt.DropAction.MoveAction | Qt.DropAction.CopyAction return Qt.DropAction.MoveAction | Qt.DropAction.CopyAction
def tooltip_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant:
"""
Return tooltip. Currently only used for last_played column.
"""
if column != Col.LAST_PLAYED.value:
return QVariant()
with db.Session() as session:
track_id = self.playlist_rows[row].track_id
if not track_id:
return QVariant()
playdates = Playdates.last_playdates(session, track_id)
return QVariant(
"<br>".join(
[
a.lastplayed.strftime(Config.LAST_PLAYED_TOOLTIP_DATE_FORMAT)
for a in playdates
]
)
)
def update_track_times(self) -> None: def update_track_times(self) -> None:
""" """
Update track start/end times in self.playlist_rows Update track start/end times in self.playlist_rows