diff options
Diffstat (limited to 'src/gui/tasks/form/state.py')
-rw-r--r-- | src/gui/tasks/form/state.py | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/src/gui/tasks/form/state.py b/src/gui/tasks/form/state.py index 46e2909..727bedd 100644 --- a/src/gui/tasks/form/state.py +++ b/src/gui/tasks/form/state.py @@ -3,6 +3,8 @@ from PyQt5 import QtCore from typing import NamedTuple, Optional from model.task import ValidTaskForm +from model.difficulty import Difficulty +from model.priority import Priority import gui.tasks.duration class TaskFormEdition: @@ -10,36 +12,48 @@ class TaskFormEdition: self, name, name_signal, - description, - description_signal, duration, duration_signal, tag, - tag_signal): + tag_signal, + difficulty, + difficulty_signal, + priority, + priority_signal, + description, + description_signal): self._name = name - self._description = description self._duration = duration self._tag = tag + self._difficulty = difficulty + self._priority = priority + self._description = description self._signal = ValidTaskFormSignal() - name_signal.connect(lambda name: self.on_name_signal(name)) - description_signal.connect(lambda description: self.on_description_signal(description)) - duration_signal.connect(lambda duration: self.on_duration_signal(duration)) - tag_signal.connect(lambda tag: self.on_tag_signal(tag)) + name_signal.connect(lambda n: self.on_name_signal(n)) + duration_signal.connect(lambda d: self.on_duration_signal(d)) + tag_signal.connect(lambda t: self.on_tag_signal(t)) + difficulty_signal.connect(lambda d: self.on_difficulty_signal(d)) + priority_signal.connect(lambda p: self.on_priority_signal(p)) + description_signal.connect(lambda d: self.on_description_signal(d)) def get(self) -> Optional[ValidTaskForm]: name = self._name.strip() - description = self._description.strip() duration = gui.tasks.duration.parse(self._duration) tag = self._tag.strip() + difficulty = self._difficulty + priority = self._priority + description = self._description.strip() if name and duration != None: return ValidTaskForm( name = name, - description = description, duration = duration, - tag = tag) + tag = tag, + difficulty = difficulty, + priority = priority, + description = description) else: return None @@ -47,10 +61,6 @@ class TaskFormEdition: self._name = name self.emit() - def on_description_signal(self, description: str): - self._description = description - self.emit() - def on_duration_signal(self, duration: str): self._duration = duration self.emit() @@ -59,6 +69,18 @@ class TaskFormEdition: self._tag = tag self.emit() + def on_difficulty_signal(self, index: int): + self._difficulty = Difficulty(index) + self.emit() + + def on_priority_signal(self, index: int): + self._priority = Priority(index) + self.emit() + + def on_description_signal(self, description: str): + self._description = description + self.emit() + def emit(self): validForm = self.get() if validForm: |