aboutsummaryrefslogtreecommitdiff
path: root/src/gui/tasks/form
diff options
context:
space:
mode:
authorJoris2020-05-09 13:37:08 +0200
committerJoris2020-05-09 13:37:08 +0200
commit3c946e02e59a05ea0b04aa6c95ce38d9d1f8ae30 (patch)
treea044b3d4a47f98722bec170d7519eaef49c10b36 /src/gui/tasks/form
parent6ed4e669ef7cb857c7b0ac774c41e8f9c7758217 (diff)
Use duration format in form
Diffstat (limited to 'src/gui/tasks/form')
-rw-r--r--src/gui/tasks/form/state.py8
-rw-r--r--src/gui/tasks/form/widget.py3
2 files changed, 7 insertions, 4 deletions
diff --git a/src/gui/tasks/form/state.py b/src/gui/tasks/form/state.py
index a47aec7..12ffe36 100644
--- a/src/gui/tasks/form/state.py
+++ b/src/gui/tasks/form/state.py
@@ -1,7 +1,9 @@
+import re
from PyQt5 import QtCore
from typing import NamedTuple, Optional
from model.task import ValidTaskForm
+import gui.tasks.duration
class TaskFormEdition:
def __init__(self, name, name_signal, duration, duration_signal, tag, tag_signal):
@@ -15,13 +17,13 @@ class TaskFormEdition:
def get(self) -> Optional[ValidTaskForm]:
name = self._name.strip()
- duration = self._duration.strip()
+ duration = gui.tasks.duration.parse(self._duration)
tag = self._tag.strip()
- if name and (duration == '' or duration.isdigit()):
+ if name and duration != None:
return ValidTaskForm(
name = name,
- duration = 0 if duration == '' else int(duration),
+ duration = duration,
tag = tag)
else:
return None
diff --git a/src/gui/tasks/form/widget.py b/src/gui/tasks/form/widget.py
index 8063d8d..6421747 100644
--- a/src/gui/tasks/form/widget.py
+++ b/src/gui/tasks/form/widget.py
@@ -6,6 +6,7 @@ from model.task import Task, ValidTaskForm
import gui.icons
import gui.tasks.form.state
+import gui.tasks.duration
def widget(
parent: QtWidgets.QWidget,
@@ -22,7 +23,7 @@ def widget(
(name_labelled_input, name_input) = labelled_input(widget, 'Name', init_name)
layout.addWidget(name_labelled_input)
- init_duration = str(task.duration) if task is not None else ''
+ init_duration = gui.tasks.duration.format(task.duration) if task is not None else ''
(duration_labelled_input, duration_input) = labelled_input(widget, 'Duration', init_duration)
layout.addWidget(duration_labelled_input)