From 3c946e02e59a05ea0b04aa6c95ce38d9d1f8ae30 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 9 May 2020 13:37:08 +0200 Subject: Use duration format in form --- src/gui/tasks/form/state.py | 8 +++++--- src/gui/tasks/form/widget.py | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/gui/tasks/form') 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) -- cgit v1.2.3