diff options
Diffstat (limited to 'src/gui/tasks/form/state.py')
-rw-r--r-- | src/gui/tasks/form/state.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/gui/tasks/form/state.py b/src/gui/tasks/form/state.py new file mode 100644 index 0000000..6aedb95 --- /dev/null +++ b/src/gui/tasks/form/state.py @@ -0,0 +1,39 @@ +from PyQt5 import QtCore + +from model.task import TaskForm + +class TaskFormEdition: + def __init__(self, name, name_signal, tag, tag_signal): + self._name = name + self._tag = tag + self._signal = TaskFormSignal() + name_signal.connect(lambda name: self.on_name_signal(name)) + tag_signal.connect(lambda tag: self.on_tag_signal(tag)) + + def get(self): + return TaskForm( + name = self._name, + tag = self._tag) + + def on_name_signal(self, name: str): + self._name = name + self._signal.emit(self.get()) + + def on_tag_signal(self, tag: str): + self._tag = tag + self._signal.emit(self.get()) + + def signal(self): + return self._signal + +class TaskFormSignal(QtCore.QObject): + _signal = QtCore.pyqtSignal(TaskForm, name = 'taskForm') + + def __init__(self): + QtCore.QObject.__init__(self) + + def emit(self, taskForm): + self._signal.emit(taskForm) + + def connect(self, f): + self._signal.connect(f) |