diff options
Diffstat (limited to 'src/gui/tasks/form')
-rw-r--r-- | src/gui/tasks/form/state.py | 19 | ||||
-rw-r--r-- | src/gui/tasks/form/widget.py | 15 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/gui/tasks/form/state.py b/src/gui/tasks/form/state.py index 9bd3ae3..5b48cd9 100644 --- a/src/gui/tasks/form/state.py +++ b/src/gui/tasks/form/state.py @@ -5,6 +5,7 @@ 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__( @@ -13,34 +14,32 @@ class TaskFormEdition: name_signal, duration, duration_signal, - tag, - tag_signal, difficulty, difficulty_signal, priority, priority_signal, + tags_signal: gui.tags.list.SelectionSignal, description, description_signal): self._name = name self._duration = duration - self._tag = tag 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)) - 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)) + 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) - tag = self._tag.strip() difficulty = self._difficulty priority = self._priority description = self._description.strip() @@ -49,9 +48,9 @@ class TaskFormEdition: return ValidTaskForm( name = name, duration = duration, - tag = tag, difficulty = difficulty, priority = priority, + tags = self._tags, description = description) else: return None @@ -64,10 +63,6 @@ class TaskFormEdition: self._duration = duration self.emit() - def on_tag_signal(self, tag: str): - self._tag = tag - self.emit() - def on_difficulty_signal(self, index: int): self._difficulty = Difficulty(index) self.emit() @@ -76,6 +71,10 @@ class TaskFormEdition: 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() diff --git a/src/gui/tasks/form/widget.py b/src/gui/tasks/form/widget.py index 9feaad0..49339e1 100644 --- a/src/gui/tasks/form/widget.py +++ b/src/gui/tasks/form/widget.py @@ -2,10 +2,12 @@ from PyQt5 import QtWidgets, QtCore from typing import Optional, Tuple, List, Any from model.task import Task, ValidTaskForm +from model.tag import Tag from model import difficulty, priority import gui.icon import gui.tasks.form.state import gui.tasks.duration +import gui.tags.list class TextEditSignal(QtCore.QObject): _signal = QtCore.pyqtSignal(str, name = 'textEdit') @@ -23,6 +25,7 @@ def widget( parent: QtWidgets.QWidget, action_title: str, task: Task, + tags: List[int], on_validated, on_cancel): @@ -41,9 +44,6 @@ def widget( init_duration = gui.tasks.duration.format(task.duration) if task is not None else '' duration_input = line_edit(grid, grid_layout, 1, 'Duration', init_duration) - init_tag = task.tag if task is not None else '' - tag_input = line_edit(grid, grid_layout, 2, 'Tag', init_tag) - init_difficulty = task.difficulty if task is not None else difficulty.Difficulty.NORMAL difficulty_input = combo_box( grid, @@ -62,6 +62,9 @@ def widget( [priority.format(d) for d in priority.values], int(init_priority)) + (tags_list_widget, tags_signal) = tags_selection(widget, tags) + layout.addWidget(tags_list_widget) + init_description = task.description if task is not None else '' (description_input, description_signal) = text_edit(widget, 'Description', init_description) layout.addWidget(description_input) @@ -71,12 +74,11 @@ def widget( name_input.textChanged, init_duration, duration_input.textChanged, - init_tag, - tag_input.textChanged, init_difficulty, difficulty_input.currentIndexChanged, init_priority, priority_input.currentIndexChanged, + tags_signal, init_description, description_signal) @@ -131,6 +133,9 @@ def combo_box( return box +def tags_selection(parent, init_tags: List[int]) -> QtWidgets.QWidget: + return gui.tags.list.widget(parent, init_tags) + def text_edit( parent, label: str, |