From bff2dfd96169f595510b16980a4cb2f3d4548029 Mon Sep 17 00:00:00 2001 From: Joris Date: Fri, 8 May 2020 14:33:15 +0200 Subject: Extract task form code from the dialog file --- src/gui/tasks/main.py | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 src/gui/tasks/main.py (limited to 'src/gui/tasks/main.py') diff --git a/src/gui/tasks/main.py b/src/gui/tasks/main.py deleted file mode 100644 index 3c7d3db..0000000 --- a/src/gui/tasks/main.py +++ /dev/null @@ -1,39 +0,0 @@ -from PyQt5 import QtWidgets, QtCore - -import db.tasks -import gui.tasks.signal -import gui.tasks.table.main -import gui.icons -from model.task import TaskForm - -def widget(database, parent): - widget = QtWidgets.QWidget(parent) - - layout = QtWidgets.QVBoxLayout(widget) - widget.setLayout(layout) - - add_task_signal = gui.tasks.signal.AddTask() - - add_task_button = QtWidgets.QPushButton('Add a task', widget) - add_task_button.setIcon(gui.icons.new_folder(widget.style())) - add_task_button.clicked.connect(lambda: show_add_dialog(database, widget, add_task_signal)) - layout.addWidget(add_task_button) - - table = gui.tasks.table.main.widget(database, widget, add_task_signal) - layout.addWidget(table) - - return widget - -def show_add_dialog(database, parent_widget, add_task_signal): - dialog = gui.tasks.modal.dialog( - parent_widget, - 'Add a task', - 'add', - None, - lambda taskForm: on_add(database, taskForm, add_task_signal)) - dialog.exec_() - -def on_add(database, taskForm: TaskForm, add_task_signal): - task = db.tasks.insert(database.cursor(), taskForm) - database.commit() - add_task_signal.emit(task) -- cgit v1.2.3