1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
from PyQt5 import QtWidgets, QtCore
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: QtWidgets.QTableWidget, status: Status, update_task_signal, position):
rows = set([index.row() for index in table.selectedIndexes()])
menu = QtWidgets.QMenu(table)
if len(rows) == 1:
modify_action = menu.addAction(gui.icon.dialog_open(menu.style()), "modify")
else:
modify_action = QtWidgets.QAction(menu)
delete_action = menu.addAction(gui.icon.trash(menu.style()), "delete")
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))
|