diff --git a/app/config.py b/app/config.py index b26bfe6..1e3fd12 100644 --- a/app/config.py +++ b/app/config.py @@ -11,7 +11,7 @@ class Config(object): COLOUR_EVEN_PLAYLIST = "#d9d9d9" COLOUR_NEXT_HEADER = "#fff3cd" COLOUR_NEXT_PLAYLIST = "#ffc107" - COLOUR_NOTES_PLAYLIST = "#668cff" + COLOUR_NOTES_PLAYLIST = "#3399ff" COLOUR_PREVIOUS_HEADER = "#f8d7da" COLOUR_WARNING_TIMER = "#ffc107" DBFS_FADE = -12 diff --git a/app/model.py b/app/model.py index 9472c36..0fc72cf 100644 --- a/app/model.py +++ b/app/model.py @@ -61,6 +61,13 @@ class Notes(Base): session.commit() return note + @staticmethod + def delete_note(id): + DEBUG(f"delete_note(id={id}") + + session.query(Notes).filter(Notes.id == id).delete() + session.commit() + @classmethod def update_note(cls, id, row, text): DEBUG(f"update_note(id={id}, row={row}, text={text})") diff --git a/app/playlists.py b/app/playlists.py index d84d9cd..b975142 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -30,14 +30,14 @@ class Playlist(QTableWidget): # Column names COL_INDEX = 0 COL_MSS = 1 - COL_NOTE = 1 + COL_NOTE = 2 COL_TITLE = 2 COL_ARTIST = 3 COL_DURATION = 4 COL_ENDTIME = 5 COL_PATH = 6 - NOTE_COL_SPAN = 4 + NOTE_COL_SPAN = 3 NOTE_ROW_SPAN = 1 def __init__(self, *args, **kwargs): @@ -107,11 +107,7 @@ class Playlist(QTableWidget): def delete_row(self, row): "Delete row" - notes_rows = self.meta_get_notes() - if row in notes_rows: - # TODO - DEBUG("playlist.delete_row(): Delete notes not yet implemented") - elif row == self.meta_get_current(): + if row == self.meta_get_current(): # TODO DEBUG("playlist.delete_row(): Can't delete playing track") elif row == self.meta_get_next(): @@ -119,18 +115,21 @@ class Playlist(QTableWidget): DEBUG("playlist.delete_row(): Can't delete next track") else: - track_title = self.item(row, self.COL_TITLE).text() + title = self.item(row, self.COL_TITLE).text() - msg = QMessageBox() + msg = QMessageBox(self) msg.setIcon(QMessageBox.Warning) - msg.setText(f"Delete '{track_title}'?") + msg.setText(f"Delete '{title}'?") msg.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel) msg.setDefaultButton(QMessageBox.Cancel) msg.setWindowTitle("Delete row") if msg.exec() == QMessageBox.Yes: DEBUG(f"playlist.delete_row(): Delete row {row}") - track_id = int(self.item(row, self.COL_INDEX).text()) - PlaylistTracks.remove_track(self.playlist_id, track_id) + id = int(self.item(row, self.COL_INDEX).text()) + if row in self.meta_get_notes(): + Notes.delete_note(id) + else: + PlaylistTracks.remove_track(self.playlist_id, id) self.removeRow(row) self.repaint()