Windows
This commit is contained in:
@@ -138,11 +138,20 @@ class LibraryPanel(QWidget):
|
||||
header.addWidget(btn_manage)
|
||||
layout.addLayout(header)
|
||||
|
||||
# Søgefelt
|
||||
# Søgefelt + checkbox
|
||||
search_row = QHBoxLayout()
|
||||
search_row.setSpacing(6)
|
||||
self._search = QLineEdit()
|
||||
self._search.setPlaceholderText("Søg i titel, artist, album, dans...")
|
||||
self._search.textChanged.connect(self._on_search_changed)
|
||||
layout.addWidget(self._search)
|
||||
search_row.addWidget(self._search)
|
||||
from PyQt6.QtWidgets import QCheckBox
|
||||
self._chk_alt = QCheckBox("Inkl. alt.")
|
||||
self._chk_alt.setToolTip("Søg også i alternativ-danse")
|
||||
self._chk_alt.setChecked(False)
|
||||
self._chk_alt.toggled.connect(self._on_search_changed)
|
||||
search_row.addWidget(self._chk_alt)
|
||||
layout.addLayout(search_row)
|
||||
|
||||
# Resultat-tæller + drag-hint
|
||||
hint_row = QHBoxLayout()
|
||||
@@ -190,7 +199,10 @@ class LibraryPanel(QWidget):
|
||||
|
||||
def _do_search(self):
|
||||
q = self._search.text().strip().lower()
|
||||
self._filtered = [s for s in self._all_songs if self._matches(s, q)] if q else list(self._all_songs)
|
||||
incl_alt = self._chk_alt.isChecked()
|
||||
self._filtered = [
|
||||
s for s in self._all_songs if self._matches(s, q, incl_alt)
|
||||
] if q else list(self._all_songs)
|
||||
total = len(self._all_songs)
|
||||
found = len(self._filtered)
|
||||
q_text = self._search.text().strip()
|
||||
@@ -200,25 +212,14 @@ class LibraryPanel(QWidget):
|
||||
)
|
||||
self._render()
|
||||
|
||||
def _matches(self, song: dict, q: str) -> bool:
|
||||
return any(q in f.lower() for f in [
|
||||
def _matches(self, song: dict, q: str, incl_alt: bool = False) -> bool:
|
||||
fields = [
|
||||
song.get("title", ""), song.get("artist", ""),
|
||||
song.get("album", ""), song.get("file_format", ""),
|
||||
] + song.get("dances", []))
|
||||
|
||||
def _render(self):
|
||||
self._list.clear()
|
||||
q = self._search.text().strip().lower()
|
||||
for song in self._filtered:
|
||||
dances = song.get("dances", [])
|
||||
dance_levels = song.get("dance_levels", [])
|
||||
missing = song.get("file_missing", False)
|
||||
|
||||
dance_parts = []
|
||||
for i, d in enumerate(dances):
|
||||
lvl = dance_levels[i] if i < len(dance_levels) else ""
|
||||
dance_parts.append(f"{d} / {lvl}" if lvl else d)
|
||||
dance_str = " · " + " | ".join(dance_parts) if dance_parts else ""
|
||||
] + song.get("dances", [])
|
||||
if incl_alt:
|
||||
fields += song.get("alt_dances", [])
|
||||
return any(q in f.lower() for f in fields)
|
||||
|
||||
def _render(self):
|
||||
self._list.clear()
|
||||
|
||||
Reference in New Issue
Block a user