aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/tasks/table/widget.py29
-rw-r--r--src/gui/window.py16
2 files changed, 30 insertions, 15 deletions
diff --git a/src/gui/tasks/table/widget.py b/src/gui/tasks/table/widget.py
index fe8ea2e..2f3328b 100644
--- a/src/gui/tasks/table/widget.py
+++ b/src/gui/tasks/table/widget.py
@@ -24,15 +24,12 @@ import service.tasks
import util.array
import util.range
-header_labels = ["Age", "Name", "Duration", "Difficulty", "Priority", "Tag"]
-
class Widget(QtWidgets.QTableWidget):
def __init__(
self,
parent,
on_show: gui.signal.Reload,
add_task_signal: gui.tasks.signal.AddTask):
-
super().__init__(parent)
self.init_state()
@@ -41,7 +38,7 @@ class Widget(QtWidgets.QTableWidget):
self.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
self.init_header()
self.setRowCount(len(self._tasks))
- self.setColumnCount(len(header_labels))
+ self.setColumnCount(len(self.header_labels()))
self.setColumnWidth(1, 500)
self.update_view()
@@ -52,7 +49,6 @@ class Widget(QtWidgets.QTableWidget):
self.customContextMenuRequested.connect(lambda position: gui.tasks.table.menu.open(self, 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())
@@ -72,13 +68,13 @@ class Widget(QtWidgets.QTableWidget):
def init_header(self):
- h = QtWidgets.QHeaderView(Qt.Horizontal, self)
+ self._header_view = QtWidgets.QHeaderView(Qt.Horizontal, self)
self._header_model = QtGui.QStandardItemModel()
- self._header_model.setHorizontalHeaderLabels(header_labels)
- h.setModel(self._header_model)
- h.setSectionsClickable(True)
- h.sectionClicked.connect(self.on_header_click)
- self.setHorizontalHeader(h)
+ self._header_model.setHorizontalHeaderLabels(self.header_labels())
+ self._header_view.setModel(self._header_model)
+ 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_header_click(self, column):
@@ -88,7 +84,7 @@ class Widget(QtWidgets.QTableWidget):
self._sort_is_ascending = True
self._sort_column = column
self.sort()
- # self._header_model.setItem(column, QtGui.QStandardItem("Hey!"))
+ self._header_model.setHorizontalHeaderLabels(self.header_labels())
self.update_view()
def sort(self):
@@ -206,6 +202,15 @@ class Widget(QtWidgets.QTableWidget):
tags = [tt.tag_id for tt in self._task_tags if tt.task_id == task.id]
return (task, tags)
+ def header_labels(self):
+ labels = ["Age", "Name", "Duration", "Difficulty", "Priority", "Tag"]
+ if self._sort_is_ascending:
+ sign = "▼"
+ else:
+ sign = "▲"
+ labels[self._sort_column] = labels[self._sort_column] + " " + sign
+ return labels
+
def item(text: str):
item = QtWidgets.QTableWidgetItem(text)
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
diff --git a/src/gui/window.py b/src/gui/window.py
index f2a5910..efacfd4 100644
--- a/src/gui/window.py
+++ b/src/gui/window.py
@@ -13,13 +13,23 @@ def get():
tabs = QtWidgets.QTabWidget(window)
window.setCentralWidget(tabs)
- open_tasks = gui.signal.Reload()
+ show_todo = gui.signal.Reload()
+ show_waiting = gui.signal.Reload()
+ show_maybe = gui.signal.Reload()
+
def on_current_tab_changed(index: int):
if index == 0:
- open_tasks.emit()
+ show_todo.emit()
+ elif index == 1:
+ show_waiting.emit()
+ elif index == 2:
+ show_maybe.emit()
+
tabs.currentChanged.connect(on_current_tab_changed)
- tabs.addTab(gui.tasks.widget.widget(tabs, open_tasks), "Tasks")
+ 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.tags.panel.widget.widget(tabs), "Tags")
return window