Correctly handle determining whether a playlist row is selected.

This commit is contained in:
Keith Edmunds 2021-04-10 12:54:08 +01:00
parent 9ee5730b14
commit 2d247db543

View File

@ -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):