Much improved performance adding tracks
This commit is contained in:
parent
403c470c8a
commit
c1fae2f91a
@ -1892,6 +1892,11 @@ 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()})
|
||||||
@ -1945,18 +1950,26 @@ 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 = 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 = QListWidgetItem()
|
||||||
t.setText(
|
track_text = (
|
||||||
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)
|
||||||
|
|
||||||
@ -1993,7 +2006,14 @@ 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)
|
||||||
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:
|
def title_artist_toggle(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user