diff options
Diffstat (limited to 'src/gui/tasks/table/menu.py')
-rw-r--r-- | src/gui/tasks/table/menu.py | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/src/gui/tasks/table/menu.py b/src/gui/tasks/table/menu.py index f89ec92..51f7330 100644 --- a/src/gui/tasks/table/menu.py +++ b/src/gui/tasks/table/menu.py @@ -1,7 +1,7 @@ from PyQt5 import QtWidgets import db.tasks -import gui.tasks.modal +import gui.tasks.dialog from model.task import Task, ValidTaskForm def open(database, table, update_task_signal, position): @@ -20,24 +20,6 @@ def open(database, table, update_task_signal, position): if action == modify_action and len(rows) == 1: row = list(rows)[0] task = table.model().get_at(row) - show_update_dialog(database, table, update_task_signal, row, task) + gui.tasks.dialog.update(database, table, update_task_signal, row, task).exec_() elif action == delete_action: - confirm = QtWidgets.QMessageBox.question(table, 'Task deletion', 'Do you really want to delete the selected tasks ?', QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.Yes) - if confirm == QtWidgets.QMessageBox.Yes: - db.tasks.delete(database.cursor(), table.model().row_ids(rows)) - database.commit() - table.model().delete_tasks(rows) - -def show_update_dialog(database, parent_widget, update_task_signal, row, task): - dialog = gui.tasks.modal.dialog( - parent_widget, - 'Modify a task', - 'modify', - task, - lambda form: on_update(database, update_task_signal, row, task, form)) - dialog.exec_() - -def on_update(database, update_task_signal, row, task: Task, form: ValidTaskForm): - task = db.tasks.update(database.cursor(), task, form) - update_task_signal.emit(row, task) - database.commit() + gui.tasks.dialog.show_delete(database, table, rows) |