diff --git a/app/musicmuster.py b/app/musicmuster.py index 41c805d..38d8e64 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -1609,8 +1609,13 @@ class DbDialog(QDialog): self.accept() return - self.parent().visible_playlist_tab().insert_track( - self.session, track, note=self.ui.txtNote.text()) + if track: + self.parent().visible_playlist_tab().insert_track( + self.session, track, note=self.ui.txtNote.text()) + else: + self.parent().visible_playlist_tab().insert_header( + self.session, note=self.ui.txtNote.text()) + # Save to database (which will also commit changes) self.parent().visible_playlist_tab().save_playlist(self.session) # Clear note field and select search text to make it easier for diff --git a/app/playlists.py b/app/playlists.py index 09fb22c..e935610 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -669,7 +669,7 @@ class PlaylistTab(QTableWidget): self.update_display(session) def insert_track(self, session: scoped_session, track: Tracks, - note: str = None, repaint: bool = True) -> None: + note: Optional[str] = None, repaint: bool = True) -> None: """ Insert track into playlist tab. @@ -680,10 +680,10 @@ class PlaylistTab(QTableWidget): to do the heavy lifing. """ - if not track and track.id: + if not track: log.debug( - f"insert_track({session=}, {track=}, {note=}, {repaint=}" - " called with either no track or no track.id" + f"insert_track({session=}, {note=}, {repaint=}" + " called with no track" ) return