diff --git a/app/models.py b/app/models.py
index 1ba9695..ae88f55 100644
--- a/app/models.py
+++ b/app/models.py
@@ -495,8 +495,8 @@ class Tracks(Base):
path: str,
title: Optional[str] = None,
artist: Optional[str] = None,
- duration: Optional[int] = None,
- start_gap: Optional[int] = None,
+ duration: int = 0,
+ start_gap: int = 0,
fade_at: Optional[int] = None,
silence_at: Optional[int] = None,
mtime: Optional[float] = None,
diff --git a/app/musicmuster.py b/app/musicmuster.py
index cfcfd01..6736de2 100755
--- a/app/musicmuster.py
+++ b/app/musicmuster.py
@@ -64,7 +64,6 @@ class Window(QMainWindow, Ui_MainWindow):
self.timer: QTimer = QTimer()
self.even_tick: bool = True
self.playing: bool = False
- self.connect_signals_slots()
self.disable_play_next_controls()
self.music: music.Music = music.Music()
@@ -91,6 +90,7 @@ class Window(QMainWindow, Ui_MainWindow):
self.enable_play_next_controls()
self.check_audacity()
self.timer.start(Config.TIMER_MS)
+ self.connect_signals_slots()
def set_main_window_size(self) -> None:
"""Set size of window from database"""
@@ -629,15 +629,24 @@ class Window(QMainWindow, Ui_MainWindow):
dlg.exec()
def search_playlist(self):
+ """Show text box to search playlist"""
+
+ self.disable_play_next_controls()
self.txtSearch.setHidden(False)
self.txtSearch.setFocus()
def search_playlist_return(self):
+ """Close off search box when return pressed"""
+
+ self.txtSearch.setText("")
self.txtSearch.setHidden(True)
- # TODO show all of playlist again
+ self.enable_play_next_controls()
+ self.visible_playlist_tab().set_filter("")
def search_playlist_update(self):
- print("search_playlist_update")
+ """Update search when search string changes"""
+
+ self.visible_playlist_tab().set_filter(self.txtSearch.text())
def open_playlist(self):
with Session() as session:
diff --git a/app/playlists.py b/app/playlists.py
index e2b4dd5..7ddeed9 100644
--- a/app/playlists.py
+++ b/app/playlists.py
@@ -136,6 +136,7 @@ class PlaylistTab(QTableWidget):
self.itemSelectionChanged.connect(self._select_event)
+ self.row_filter: Optional[str] = None
self.editing_cell: bool = False
self.selecting_in_progress = False
self.cellChanged.connect(self._cell_changed)
@@ -664,6 +665,13 @@ class PlaylistTab(QTableWidget):
self.selecting_in_progress = False
self._select_event()
+ def set_filter(self, text: Optional[str]) -> None:
+ """Filter rows to only show those containing text"""
+
+ self.row_filter = text
+ with Session() as session:
+ self.update_display(session)
+
def set_selected_as_next(self) -> None:
"""Sets the select track as next to play"""
@@ -723,6 +731,14 @@ class PlaylistTab(QTableWidget):
if row in notes:
# Extract note text from database to ignore section timings
note_text = self._get_row_notes_object(row, session).note
+ if self.row_filter:
+ if self.row_filter not in note_text:
+ self.hideRow(row)
+ continue
+ else:
+ self.showRow(row)
+ else:
+ self.showRow(row)
# Does the note have a start time?
row_time = self._get_note_text_time(note_text)
if row_time:
@@ -762,6 +778,20 @@ class PlaylistTab(QTableWidget):
if section_start_row is not None:
section_time += track.duration
# Render current track
+ if self.row_filter:
+ try:
+ if (track.title
+ and self.row_filter not in track.title
+ and track.artist
+ and self.row_filter not in track.artist):
+ self.hideRow(row)
+ continue
+ else:
+ self.showRow(row)
+ except TypeError:
+ print(f"TypeError: {track=}")
+ else:
+ self.showRow(row)
if row == current_row:
# Set start time
self._set_row_start_time(
diff --git a/app/ui/main_window.ui b/app/ui/main_window.ui
index 19cf39a..c115c70 100644
--- a/app/ui/main_window.ui
+++ b/app/ui/main_window.ui
@@ -782,8 +782,6 @@ border: 1px solid rgb(85, 87, 83);
-
-
@@ -795,6 +793,7 @@ border: 1px solid rgb(85, 87, 83);
+