diff options
author | Joris | 2020-06-06 17:44:26 +0200 |
---|---|---|
committer | Joris | 2020-06-06 19:54:03 +0200 |
commit | 1595e0de940a86a7810df0e02e43838d97c0d846 (patch) | |
tree | 9701eeec0d98baa9f6044b1911df68e4c8539819 /src/gui/tasks/form/state.py | |
parent | 6b9195000eb5404c247288b384d7ca2bacc1ab23 (diff) |
Provide nix build
Diffstat (limited to 'src/gui/tasks/form/state.py')
-rw-r--r-- | src/gui/tasks/form/state.py | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/src/gui/tasks/form/state.py b/src/gui/tasks/form/state.py deleted file mode 100644 index 09e658e..0000000 --- a/src/gui/tasks/form/state.py +++ /dev/null @@ -1,100 +0,0 @@ -from PyQt5 import QtCore -from typing import Optional - -from model.task import ValidTaskForm -from model.difficulty import Difficulty -from model.priority import Priority -import gui.tasks.duration -import gui.tags.list - -class TaskFormEdition: - def __init__( - self, - name, - name_signal, - duration, - duration_signal, - difficulty, - difficulty_signal, - priority, - priority_signal, - tags_signal: gui.tags.list.SelectionSignal, - description, - description_signal): - - self._name = name - self._duration = duration - self._difficulty = difficulty - self._priority = priority - self._tags = [] - self._description = description - self._signal = ValidTaskFormSignal() - - name_signal.connect(lambda n: self.on_name_signal(n)) - duration_signal.connect(lambda d: self.on_duration_signal(d)) - difficulty_signal.connect(lambda d: self.on_difficulty_signal(d)) - priority_signal.connect(lambda p: self.on_priority_signal(p)) - tags_signal.connect(lambda ts: self.on_tags_signal(ts)) - description_signal.connect(lambda d: self.on_description_signal(d)) - - def get(self) -> Optional[ValidTaskForm]: - name = self._name.strip() - duration = gui.tasks.duration.parse(self._duration) - difficulty = self._difficulty - priority = self._priority - description = self._description.strip() - - if name and duration != None: - return ValidTaskForm( - name = name, - duration = duration, - difficulty = difficulty, - priority = priority, - tags = self._tags, - description = description) - else: - return None - - def on_name_signal(self, name: str): - self._name = name - self.emit() - - def on_duration_signal(self, duration: str): - self._duration = duration - 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_tags_signal(self, tags: [int]): - self._tags = tags - self.emit() - - def on_description_signal(self, description: str): - self._description = description - self.emit() - - def emit(self): - validForm = self.get() - if validForm: - self._signal.emit(validForm) - - def signal(self): - return self._signal - -class ValidTaskFormSignal(QtCore.QObject): - _signal = QtCore.pyqtSignal(ValidTaskForm, name = "validTaskForm") - - def __init__(self): - QtCore.QObject.__init__(self) - - def emit(self, form: Optional[ValidTaskForm]): - self._signal.emit(form) - - def connect(self, f): - self._signal.connect(f) |