Compare commits
No commits in common. "b2f826dfccf6cacd210ff3f53894dfe1191d1d6b" and "403c470c8aa5612caab3ce0ec8302488d17267f5" have entirely different histories.
b2f826dfcc
...
403c470c8a
@ -718,11 +718,7 @@ class Tracks(Base):
|
|||||||
"""Search case-insenstively for titles containing str"""
|
"""Search case-insenstively for titles containing str"""
|
||||||
return (
|
return (
|
||||||
session.execute(
|
session.execute(
|
||||||
select(cls)
|
select(cls).where(cls.title.like(f"{text}%")).order_by(cls.title)
|
||||||
.join(Playdates, isouter=True)
|
|
||||||
.where(cls.title.like(f"{text}%"))
|
|
||||||
.group_by(cls.title)
|
|
||||||
.order_by(cls.title)
|
|
||||||
)
|
)
|
||||||
.scalars()
|
.scalars()
|
||||||
.all()
|
.all()
|
||||||
|
|||||||
@ -1892,11 +1892,6 @@ class DbDialog(QDialog):
|
|||||||
def __del__(self) -> None:
|
def __del__(self) -> None:
|
||||||
"""Save dialog size and position"""
|
"""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")
|
record = Settings.get_int_settings(self.session, "dbdialog_height")
|
||||||
if record.f_int != self.height():
|
if record.f_int != self.height():
|
||||||
record.update(self.session, {"f_int": self.height()})
|
record.update(self.session, {"f_int": self.height()})
|
||||||
@ -1950,26 +1945,18 @@ class DbDialog(QDialog):
|
|||||||
self.ui.matchList.clear()
|
self.ui.matchList.clear()
|
||||||
if len(s) > 0:
|
if len(s) > 0:
|
||||||
if self.ui.radioTitle.isChecked():
|
if self.ui.radioTitle.isChecked():
|
||||||
matches = Tracks.search_titles(self.session, "%" + s)
|
matches = Tracks.search_titles(self.session, s)
|
||||||
else:
|
else:
|
||||||
matches = Tracks.search_artists(self.session, s)
|
matches = Tracks.search_artists(self.session, s)
|
||||||
if matches:
|
if matches:
|
||||||
for track in matches:
|
for track in matches:
|
||||||
last_played = None
|
last_played = Playdates.last_played(self.session, track.id)
|
||||||
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 = QListWidgetItem()
|
||||||
track_text = (
|
t.setText(
|
||||||
f"{track.title} - {track.artist} "
|
f"{track.title} - {track.artist} "
|
||||||
f"[{helpers.ms_to_mmss(track.duration)}] "
|
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)
|
t.setData(Qt.ItemDataRole.UserRole, track)
|
||||||
self.ui.matchList.addItem(t)
|
self.ui.matchList.addItem(t)
|
||||||
|
|
||||||
@ -2006,14 +1993,7 @@ class DbDialog(QDialog):
|
|||||||
|
|
||||||
item = self.ui.matchList.currentItem()
|
item = self.ui.matchList.currentItem()
|
||||||
track = item.data(Qt.ItemDataRole.UserRole)
|
track = item.data(Qt.ItemDataRole.UserRole)
|
||||||
last_playdate = max(track.playdates, key=lambda p: p.lastplayed, default=None)
|
self.ui.dbPath.setText(track.path)
|
||||||
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:
|
def title_artist_toggle(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user