Compare commits
2 Commits
403c470c8a
...
b2f826dfcc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2f826dfcc | ||
|
|
c1fae2f91a |
@ -718,7 +718,11 @@ class Tracks(Base):
|
||||
"""Search case-insenstively for titles containing str"""
|
||||
return (
|
||||
session.execute(
|
||||
select(cls).where(cls.title.like(f"{text}%")).order_by(cls.title)
|
||||
select(cls)
|
||||
.join(Playdates, isouter=True)
|
||||
.where(cls.title.like(f"{text}%"))
|
||||
.group_by(cls.title)
|
||||
.order_by(cls.title)
|
||||
)
|
||||
.scalars()
|
||||
.all()
|
||||
|
||||
@ -1892,6 +1892,11 @@ class DbDialog(QDialog):
|
||||
def __del__(self) -> None:
|
||||
"""Save dialog size and position"""
|
||||
|
||||
# FIXME:
|
||||
# if record.f_int != self.height():
|
||||
# ^^^^^^^^^^^^^
|
||||
# RuntimeError: wrapped C/C++ object of type DbDialog has been deleted
|
||||
|
||||
record = Settings.get_int_settings(self.session, "dbdialog_height")
|
||||
if record.f_int != self.height():
|
||||
record.update(self.session, {"f_int": self.height()})
|
||||
@ -1945,18 +1950,26 @@ class DbDialog(QDialog):
|
||||
self.ui.matchList.clear()
|
||||
if len(s) > 0:
|
||||
if self.ui.radioTitle.isChecked():
|
||||
matches = Tracks.search_titles(self.session, s)
|
||||
matches = Tracks.search_titles(self.session, "%" + s)
|
||||
else:
|
||||
matches = Tracks.search_artists(self.session, s)
|
||||
if matches:
|
||||
for track in matches:
|
||||
last_played = Playdates.last_played(self.session, track.id)
|
||||
last_played = None
|
||||
show_last_played = False
|
||||
if len(matches) < 20:
|
||||
show_last_played = True
|
||||
last_playdate = max(track.playdates, key=lambda p: p.lastplayed, default=None)
|
||||
if last_playdate:
|
||||
last_played = last_playdate.lastplayed
|
||||
t = QListWidgetItem()
|
||||
t.setText(
|
||||
track_text = (
|
||||
f"{track.title} - {track.artist} "
|
||||
f"[{helpers.ms_to_mmss(track.duration)}] "
|
||||
f"({helpers.get_relative_date(last_played)})"
|
||||
)
|
||||
if show_last_played:
|
||||
track_text += f"({helpers.get_relative_date(last_played)})"
|
||||
t.setText(track_text)
|
||||
t.setData(Qt.ItemDataRole.UserRole, track)
|
||||
self.ui.matchList.addItem(t)
|
||||
|
||||
@ -1993,7 +2006,14 @@ class DbDialog(QDialog):
|
||||
|
||||
item = self.ui.matchList.currentItem()
|
||||
track = item.data(Qt.ItemDataRole.UserRole)
|
||||
self.ui.dbPath.setText(track.path)
|
||||
last_playdate = max(track.playdates, key=lambda p: p.lastplayed, default=None)
|
||||
if last_playdate:
|
||||
last_played = last_playdate.lastplayed
|
||||
else:
|
||||
last_played = None
|
||||
path_text = f"{track.path} ({helpers.get_relative_date(last_played)})"
|
||||
|
||||
self.ui.dbPath.setText(path_text)
|
||||
|
||||
def title_artist_toggle(self) -> None:
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user