diff --git a/app/playlists.py b/app/playlists.py index 7910a7f..09af2fe 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -143,12 +143,12 @@ class Playlist(QTableWidget): playlist. """ - DEBUG(f"add_note({text}): self.currentRow()={self.currentRow()}") - - row = self.currentRow() - if row < 0: + if self.selectionModel().hasSelection(): + row = self.currentRow() + else: row = self.rowCount() DEBUG(f"playlist.add_note(): row={row}") + note_id = Notes.add_note(self.playlist_id, row, text) # TODO: this largely duplicates what's in add_to_playlist() @@ -169,13 +169,12 @@ class Playlist(QTableWidget): Notes object. """ - row = self.currentRow() - if row < 0: + if self.selectionModel().hasSelection(): + row = self.currentRow() + else: row = self.rowCount() - DEBUG( - f"currentRow={self.currentRow()} " - f"hasSeleciont={self.selectionModel().hasSelection()}" - ) + DEBUG(f"add_to_playlist(data={data}): row={row}") + self.insertRow(row) if isinstance(data, Tracks): @@ -553,6 +552,9 @@ class Playlist(QTableWidget): Sets the selected track as the next track. """ + if not self.selectionModel().hasSelection(): + return + self.set_next(self.currentRow()) def set_next(self, row):