aboutsummaryrefslogtreecommitdiff
path: root/todo/gui/tasks/form/state.py
diff options
context:
space:
mode:
Diffstat (limited to 'todo/gui/tasks/form/state.py')
-rw-r--r--todo/gui/tasks/form/state.py45
1 files changed, 13 insertions, 32 deletions
diff --git a/todo/gui/tasks/form/state.py b/todo/gui/tasks/form/state.py
index c073214..ed64747 100644
--- a/todo/gui/tasks/form/state.py
+++ b/todo/gui/tasks/form/state.py
@@ -1,10 +1,8 @@
from PyQt5 import QtCore
from typing import Optional, List
+from datetime import date, datetime
from todo.model.task import ValidTaskForm
-from todo.model.difficulty import Difficulty
-from todo.model.priority import Priority
-import todo.gui.tasks.duration
import todo.gui.tags.list
class TaskFormEdition:
@@ -12,45 +10,33 @@ class TaskFormEdition:
self,
name,
name_signal,
- duration,
- duration_signal,
- difficulty,
- difficulty_signal,
- priority,
- priority_signal,
+ due_date,
+ due_date_signal,
tags: List[int],
tags_signal: todo.gui.tags.list.SelectionSignal,
description,
description_signal):
self._name = name
- self._duration = duration
- self._difficulty = difficulty
- self._priority = priority
+ self._due_date = parse_date(due_date)
self._tags = 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))
+ due_date_signal.connect(lambda d: self.on_due_date_signal(d))
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 = todo.gui.tasks.duration.parse(self._duration)
- difficulty = self._difficulty
- priority = self._priority
+ due_date = self._due_date
description = self._description.strip()
- if name and duration != None:
+ if name:
return ValidTaskForm(
name = name,
- duration = duration,
- difficulty = difficulty,
- priority = priority,
+ due_date = due_date,
tags = self._tags,
description = description)
else:
@@ -60,16 +46,8 @@ class TaskFormEdition:
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)
+ def on_due_date_signal(self, due_date: str):
+ self._due_date = parse_date(due_date)
self.emit()
def on_tags_signal(self, tags: List[int]):
@@ -99,3 +77,6 @@ class ValidTaskFormSignal(QtCore.QObject):
def connect(self, f):
self._signal.connect(f)
+
+def parse_date(d: str) -> date:
+ return datetime.strptime(d, "%d/%m/%Y").date() if d else None