Implement deleting of notes
This commit is contained in:
parent
830c88cc33
commit
f61c6fd74f
@ -11,7 +11,7 @@ class Config(object):
|
|||||||
COLOUR_EVEN_PLAYLIST = "#d9d9d9"
|
COLOUR_EVEN_PLAYLIST = "#d9d9d9"
|
||||||
COLOUR_NEXT_HEADER = "#fff3cd"
|
COLOUR_NEXT_HEADER = "#fff3cd"
|
||||||
COLOUR_NEXT_PLAYLIST = "#ffc107"
|
COLOUR_NEXT_PLAYLIST = "#ffc107"
|
||||||
COLOUR_NOTES_PLAYLIST = "#668cff"
|
COLOUR_NOTES_PLAYLIST = "#3399ff"
|
||||||
COLOUR_PREVIOUS_HEADER = "#f8d7da"
|
COLOUR_PREVIOUS_HEADER = "#f8d7da"
|
||||||
COLOUR_WARNING_TIMER = "#ffc107"
|
COLOUR_WARNING_TIMER = "#ffc107"
|
||||||
DBFS_FADE = -12
|
DBFS_FADE = -12
|
||||||
|
|||||||
@ -61,6 +61,13 @@ class Notes(Base):
|
|||||||
session.commit()
|
session.commit()
|
||||||
return note
|
return note
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def delete_note(id):
|
||||||
|
DEBUG(f"delete_note(id={id}")
|
||||||
|
|
||||||
|
session.query(Notes).filter(Notes.id == id).delete()
|
||||||
|
session.commit()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_note(cls, id, row, text):
|
def update_note(cls, id, row, text):
|
||||||
DEBUG(f"update_note(id={id}, row={row}, text={text})")
|
DEBUG(f"update_note(id={id}, row={row}, text={text})")
|
||||||
|
|||||||
@ -30,14 +30,14 @@ class Playlist(QTableWidget):
|
|||||||
# Column names
|
# Column names
|
||||||
COL_INDEX = 0
|
COL_INDEX = 0
|
||||||
COL_MSS = 1
|
COL_MSS = 1
|
||||||
COL_NOTE = 1
|
COL_NOTE = 2
|
||||||
COL_TITLE = 2
|
COL_TITLE = 2
|
||||||
COL_ARTIST = 3
|
COL_ARTIST = 3
|
||||||
COL_DURATION = 4
|
COL_DURATION = 4
|
||||||
COL_ENDTIME = 5
|
COL_ENDTIME = 5
|
||||||
COL_PATH = 6
|
COL_PATH = 6
|
||||||
|
|
||||||
NOTE_COL_SPAN = 4
|
NOTE_COL_SPAN = 3
|
||||||
NOTE_ROW_SPAN = 1
|
NOTE_ROW_SPAN = 1
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -107,11 +107,7 @@ class Playlist(QTableWidget):
|
|||||||
def delete_row(self, row):
|
def delete_row(self, row):
|
||||||
"Delete row"
|
"Delete row"
|
||||||
|
|
||||||
notes_rows = self.meta_get_notes()
|
if row == self.meta_get_current():
|
||||||
if row in notes_rows:
|
|
||||||
# TODO
|
|
||||||
DEBUG("playlist.delete_row(): Delete notes not yet implemented")
|
|
||||||
elif row == self.meta_get_current():
|
|
||||||
# TODO
|
# TODO
|
||||||
DEBUG("playlist.delete_row(): Can't delete playing track")
|
DEBUG("playlist.delete_row(): Can't delete playing track")
|
||||||
elif row == self.meta_get_next():
|
elif row == self.meta_get_next():
|
||||||
@ -119,18 +115,21 @@ class Playlist(QTableWidget):
|
|||||||
DEBUG("playlist.delete_row(): Can't delete next track")
|
DEBUG("playlist.delete_row(): Can't delete next track")
|
||||||
|
|
||||||
else:
|
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.setIcon(QMessageBox.Warning)
|
||||||
msg.setText(f"Delete '{track_title}'?")
|
msg.setText(f"Delete '{title}'?")
|
||||||
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel)
|
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel)
|
||||||
msg.setDefaultButton(QMessageBox.Cancel)
|
msg.setDefaultButton(QMessageBox.Cancel)
|
||||||
msg.setWindowTitle("Delete row")
|
msg.setWindowTitle("Delete row")
|
||||||
if msg.exec() == QMessageBox.Yes:
|
if msg.exec() == QMessageBox.Yes:
|
||||||
DEBUG(f"playlist.delete_row(): Delete row {row}")
|
DEBUG(f"playlist.delete_row(): Delete row {row}")
|
||||||
track_id = int(self.item(row, self.COL_INDEX).text())
|
id = int(self.item(row, self.COL_INDEX).text())
|
||||||
PlaylistTracks.remove_track(self.playlist_id, track_id)
|
if row in self.meta_get_notes():
|
||||||
|
Notes.delete_note(id)
|
||||||
|
else:
|
||||||
|
PlaylistTracks.remove_track(self.playlist_id, id)
|
||||||
self.removeRow(row)
|
self.removeRow(row)
|
||||||
|
|
||||||
self.repaint()
|
self.repaint()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user