def update(self): if self.initialColor != self.newColor or self.initialName != self.newName: prompt = confirm.confirm( text="You have unsaved work. Are you sure you want to quit?", title=" ") if not prompt.response: self.listWidget.blockSignals(True) self.listWidget.setCurrentRow(self.lastSelection) self.listWidget.blockSignals(False) return self.lastSelection = self.listWidget.currentRow() selected = self.listWidget.currentItem() name = selected.data(0) self.cursor.execute(f"SELECT color FROM types WHERE name = '{name}'") color = self.cursor.fetchall() self.initialName = str(name) self.initialColor = str(color[0][0]) self.newName = self.initialName self.newColor = self.initialColor self.fieldName.setText(name) self.buttonColor.setStyleSheet( f"background-color: {self.initialColor}")
def delete(self): prompt = confirm.confirm( text="Are you sure you want to delete this note?", title=" ") if prompt.response: self.cursor.execute(f"DELETE FROM data WHERE id == '{self.id}'") self.db.commit() self.close() else: pass
def cancel(self): if self.linkURL.text() != "" or self.linkNotes.toPlainText() != "": prompt = confirm.confirm( text="You have unsaved work. Are you sure you want to quit?", title=" ") if prompt.response: self.close() else: pass else: self.close()
def cancel(self): if self.initialColor != self.newColor or self.initialName != self.newName: prompt = confirm.confirm( text="You have unsaved work. Are you sure you want to quit?", title=" ") if prompt.response: self.close() else: pass else: self.close()
def delete(self): self.update() selected = self.fieldName.text() prompt = confirm.confirm( "This will delete the selected category and its data.\nAre you sure you want to proceed?", title="Warning!") if prompt.response: self.cursor.execute( f"DELETE FROM categories WHERE name = '{selected}'") self.cursor.execute( f"DELETE FROM data WHERE category = '{selected}'") self.db.commit() self.listWidget.takeItem(self.listWidget.currentRow()) else: pass