aboutsummaryrefslogtreecommitdiff
path: root/src/gui/tasks/table
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/tasks/table')
-rw-r--r--src/gui/tasks/table/menu.py23
-rw-r--r--src/gui/tasks/table/widget.py12
2 files changed, 32 insertions, 3 deletions
diff --git a/src/gui/tasks/table/menu.py b/src/gui/tasks/table/menu.py
index 0ad9857..5356be2 100644
--- a/src/gui/tasks/table/menu.py
+++ b/src/gui/tasks/table/menu.py
@@ -19,10 +19,31 @@ def open(table: QtWidgets.QTableWidget, status: Status, update_task_signal, posi
delete_action = menu.addAction(gui.icon.trash(menu.style()), "delete")
+ if status != Status.READY:
+ move_to_ready = menu.addAction(gui.icon.task_ready(menu.style()), "move to ready")
+ else:
+ move_to_ready = QtWidgets.QAction(menu)
+
+ if status != Status.WAITING:
+ move_to_waiting = menu.addAction(gui.icon.task_waiting(menu.style()), "move to waiting")
+ else:
+ move_to_waiting = QtWidgets.QAction(menu)
+
+ if status != Status.MAYBE:
+ move_to_maybe = menu.addAction(gui.icon.task_maybe(menu.style()), "move to maybe")
+ else:
+ move_to_maybe = QtWidgets.QAction(menu)
+
action = menu.exec_(table.mapToGlobal(position + QtCore.QPoint(15, 20)))
if action == modify_action and len(rows) == 1:
row = list(rows)[0]
(task, tags) = table.get_at(row)
gui.tasks.dialog.update(table, update_task_signal, row, task, tags).exec_()
elif action == delete_action:
- gui.tasks.dialog.show_delete(table, rows, lambda: table.delete_rows(rows))
+ gui.tasks.dialog.confirm_delete(table, rows, lambda: table.delete_rows(rows))
+ elif action == move_to_ready:
+ gui.tasks.dialog.confirm_move(table, rows, Status.READY, lambda: table.update_status(rows, Status.READY))
+ elif action == move_to_waiting:
+ gui.tasks.dialog.confirm_move(table, rows, Status.WAITING, lambda: table.update_status(rows, Status.WAITING))
+ elif action == move_to_maybe:
+ gui.tasks.dialog.confirm_move(table, rows, Status.MAYBE, lambda: table.update_status(rows, Status.MAYBE))
diff --git a/src/gui/tasks/table/widget.py b/src/gui/tasks/table/widget.py
index 14806fa..aacae2f 100644
--- a/src/gui/tasks/table/widget.py
+++ b/src/gui/tasks/table/widget.py
@@ -192,10 +192,18 @@ class Widget(QtWidgets.QTableWidget):
def delete_rows(self, rows: List[int]):
task_ids = [task.id for i, task in enumerate(self._tasks) if i in rows]
service.tasks.delete(database.cursor(), task_ids)
- self._tasks = [t for t in self._tasks if t.id not in task_ids]
- self._task_tags = [tt for tt in self._task_tags if tt.task_id in [t.id for t in self._tasks]]
+ self.remove_rows_from_table(rows, task_ids)
+
+ def update_status(self, rows: List[int], status: Status):
+ task_ids = [task.id for i, task in enumerate(self._tasks) if i in rows]
+ service.tasks.update_status(database.cursor(), task_ids, status)
+ self.remove_rows_from_table(rows, task_ids)
+
+ def remove_rows_from_table(self, rows: List[int], task_ids: List[int]):
for row in sorted(rows, reverse=True):
self.removeRow(row)
+ self._tasks = [t for t in self._tasks if t.id not in task_ids]
+ self._task_tags = [tt for tt in self._task_tags if tt.task_id in [t.id for t in self._tasks]]
self.setRowCount(len(self._tasks))
def get_selected_rows(self):