From 2d247db543d77ba5491bb0a8134e94bb76d25048 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 10 Apr 2021 12:54:08 +0100 Subject: [PATCH] Correctly handle determining whether a playlist row is selected. --- app/playlists.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) 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):