aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/tags/panel/widget.py7
-rw-r--r--src/gui/tasks/dialog.py5
-rw-r--r--src/gui/tasks/table/menu.py3
-rw-r--r--src/gui/tasks/table/widget.py30
-rw-r--r--src/gui/tasks/widget.py14
-rw-r--r--src/gui/window.py7
6 files changed, 44 insertions, 22 deletions
diff --git a/src/gui/tags/panel/widget.py b/src/gui/tags/panel/widget.py
index fb51385..faca1da 100644
--- a/src/gui/tags/panel/widget.py
+++ b/src/gui/tags/panel/widget.py
@@ -11,14 +11,19 @@ def widget(parent):
layout = QtWidgets.QVBoxLayout(widget)
widget.setLayout(layout)
+ layout.addSpacing(15)
+
add_tag_signal = gui.tags.panel.signal.AddTag()
- add_tag_button = QtWidgets.QPushButton("Add a tag", widget)
+ add_tag_button = QtWidgets.QPushButton(" Add a tag", widget)
+ add_tag_button.setFixedHeight(30)
add_tag_button.setIcon(gui.icon.new_folder(widget.style()))
add_tag_button.clicked.connect(lambda: gui.tags.panel.dialog.add(widget, add_tag_signal).exec_())
layout.addWidget(add_tag_button)
+ layout.addSpacing(20)
+
table = gui.tags.panel.table.widget.Widget(widget, add_tag_signal)
layout.addWidget(table)
diff --git a/src/gui/tasks/dialog.py b/src/gui/tasks/dialog.py
index 1471910..3233dd6 100644
--- a/src/gui/tasks/dialog.py
+++ b/src/gui/tasks/dialog.py
@@ -3,16 +3,17 @@ from typing import List
from model.tag import Tag
from model.task import Task, ValidTaskForm
+from model.status import Status
import database
import db.task_tags
import db.tasks
import gui.tasks.form.widget
import service.tasks
-def add(parent_widget, add_task_signal):
+def add(parent_widget, status: Status, add_task_signal):
def on_add(task_form: ValidTaskForm):
- task = service.tasks.create(database.cursor(), task_form)
+ task = service.tasks.create(database.cursor(), status, task_form)
add_task_signal.emit(task, task_form.tags)
return widget(parent_widget, "Add a task", "add", None, [], on_add)
diff --git a/src/gui/tasks/table/menu.py b/src/gui/tasks/table/menu.py
index db89551..0ad9857 100644
--- a/src/gui/tasks/table/menu.py
+++ b/src/gui/tasks/table/menu.py
@@ -3,10 +3,11 @@ from typing import List
import db.tasks
import gui.tasks.dialog
+from model.status import Status
from model.task import Task, ValidTaskForm
from model.tag import Tag
-def open(table, update_task_signal, position):
+def open(table: QtWidgets.QTableWidget, status: Status, update_task_signal, position):
rows = set([index.row() for index in table.selectedIndexes()])
menu = QtWidgets.QMenu(table)
diff --git a/src/gui/tasks/table/widget.py b/src/gui/tasks/table/widget.py
index 2f3328b..14806fa 100644
--- a/src/gui/tasks/table/widget.py
+++ b/src/gui/tasks/table/widget.py
@@ -10,6 +10,7 @@ from model.priority import Priority
from model.tag import Tag
from model.task import Task
from model.task_tag import TaskTag
+from model.status import Status
import database
import db.tags
import db.task_tags
@@ -29,10 +30,11 @@ class Widget(QtWidgets.QTableWidget):
self,
parent,
on_show: gui.signal.Reload,
- add_task_signal: gui.tasks.signal.AddTask):
+ add_task_signal: gui.tasks.signal.AddTask,
+ status: Status):
super().__init__(parent)
- self.init_state()
+ self.init_state(status)
self.sort()
self.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
@@ -46,27 +48,23 @@ class Widget(QtWidgets.QTableWidget):
# Menu
self.setContextMenuPolicy(Qt.CustomContextMenu)
- self.customContextMenuRequested.connect(lambda position: gui.tasks.table.menu.open(self, self._update_task_signal, position))
+ self.customContextMenuRequested.connect(lambda position: gui.tasks.table.menu.open(self, status, self._update_task_signal, position))
self.doubleClicked.connect(lambda index: self.on_double_click(index.row()))
add_task_signal.connect(lambda task, tags: self.insert(task, tags))
self._update_task_signal.connect(lambda row, task, tags: self.update_task(row, task, tags))
on_show.connect(lambda: self.on_show())
- def on_show(self):
- self._tags = db.tags.get(database.cursor())
- self.update_view()
-
- def init_state(self):
+ def init_state(self, status: Status):
self._update_task_signal = gui.tasks.signal.UpdateTask()
cursor = database.cursor()
- self._tasks = service.tasks.get(cursor)
+ self._status = status
+ self._tasks = service.tasks.get(cursor, self._status)
self._task_tags = db.task_tags.get(cursor)
self._tags = db.tags.get(cursor)
self._sort_column = 0
self._sort_is_ascending = True
-
def init_header(self):
self._header_view = QtWidgets.QHeaderView(Qt.Horizontal, self)
self._header_model = QtGui.QStandardItemModel()
@@ -75,7 +73,15 @@ class Widget(QtWidgets.QTableWidget):
self._header_view.setSectionsClickable(True)
self._header_view.sectionClicked.connect(self.on_header_click)
self.setHorizontalHeader(self._header_view)
- # header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents)
+
+ def on_show(self):
+ cursor = database.cursor()
+ self._tasks = service.tasks.get(cursor, self._status)
+ self._task_tags = db.task_tags.get(cursor)
+ self._tags = db.tags.get(cursor)
+ self.setRowCount(len(self._tasks))
+ self.sort()
+ self.update_view()
def on_header_click(self, column):
if self._sort_column == column:
@@ -138,6 +144,7 @@ class Widget(QtWidgets.QTableWidget):
self.insertRow(row)
self.update_row(row)
self._task_tags += [TaskTag(task_id=task.id, tag_id=tag_id) for tag_id in tags]
+ self.setRowCount(len(self._tasks))
return row
def is_reversed(self) -> bool:
@@ -189,6 +196,7 @@ class Widget(QtWidgets.QTableWidget):
self._task_tags = [tt for tt in self._task_tags if tt.task_id in [t.id for t in self._tasks]]
for row in sorted(rows, reverse=True):
self.removeRow(row)
+ self.setRowCount(len(self._tasks))
def get_selected_rows(self):
return list(set([index.row() for index in self.selectedIndexes()]))
diff --git a/src/gui/tasks/widget.py b/src/gui/tasks/widget.py
index 3134124..87b15d3 100644
--- a/src/gui/tasks/widget.py
+++ b/src/gui/tasks/widget.py
@@ -1,24 +1,30 @@
from PyQt5 import QtWidgets
+from model.status import Status
import gui.tasks.signal
import gui.tasks.table.widget
import gui.icon
import gui.signal
-def widget(parent, on_show: gui.signal.Reload):
+def widget(parent, on_show: gui.signal.Reload, status: Status):
widget = QtWidgets.QWidget(parent)
layout = QtWidgets.QVBoxLayout(widget)
widget.setLayout(layout)
+ layout.addSpacing(15)
+
add_task_signal = gui.tasks.signal.AddTask()
- add_task_button = QtWidgets.QPushButton("Add a task", widget)
+ add_task_button = QtWidgets.QPushButton(" Add a task", widget)
+ add_task_button.setFixedHeight(30)
add_task_button.setIcon(gui.icon.new_folder(widget.style()))
- add_task_button.clicked.connect(lambda: gui.tasks.dialog.add(widget, add_task_signal).exec_())
+ add_task_button.clicked.connect(lambda: gui.tasks.dialog.add(widget, status, add_task_signal).exec_())
layout.addWidget(add_task_button)
- table = gui.tasks.table.widget.Widget(widget, on_show, add_task_signal)
+ layout.addSpacing(20)
+
+ table = gui.tasks.table.widget.Widget(widget, on_show, add_task_signal, status)
layout.addWidget(table)
return widget
diff --git a/src/gui/window.py b/src/gui/window.py
index efacfd4..35670c7 100644
--- a/src/gui/window.py
+++ b/src/gui/window.py
@@ -4,6 +4,7 @@ import gui.tasks.widget
import gui.tasks.widget
import gui.tags.panel.widget
import gui.signal
+from model.status import Status
def get():
window = QtWidgets.QMainWindow()
@@ -27,9 +28,9 @@ def get():
tabs.currentChanged.connect(on_current_tab_changed)
- tabs.addTab(gui.tasks.widget.widget(tabs, show_todo), "Todo")
- tabs.addTab(gui.tasks.widget.widget(tabs, show_waiting), "Waiting")
- tabs.addTab(gui.tasks.widget.widget(tabs, show_maybe), "Maybe")
+ tabs.addTab(gui.tasks.widget.widget(tabs, show_todo, Status.READY), "Todo")
+ tabs.addTab(gui.tasks.widget.widget(tabs, show_waiting, Status.WAITING), "Waiting")
+ tabs.addTab(gui.tasks.widget.widget(tabs, show_maybe, Status.MAYBE), "Maybe")
tabs.addTab(gui.tags.panel.widget.widget(tabs), "Tags")
return window