blob: e28605195424ca77349903b44c474e195bc0370d (
plain)
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
29
30
31
32
33
34
35
|
from PyQt5 import QtWidgets, QtCore
from todo.model.tag import Tag, ValidTagForm
import todo.database
import todo.db.task_tags
import todo.gui.tags.panel.dialog
def open(table, update_tag_signal, position):
rows = set([index.row() for index in table.selectedIndexes()])
menu = QtWidgets.QMenu(table)
actions = 0
if len(rows) == 1:
modify_action = menu.addAction(todo.gui.icon.dialog_open(menu.style()), "modify")
actions += 1
else:
modify_action = QtWidgets.QAction(menu)
tags = table.model().row_ids(rows)
if not todo.db.task_tags.one_is_used(todo.database.cursor(), tags):
delete_action = menu.addAction(todo.gui.icon.trash(menu.style()), "delete")
actions += 1
else:
delete_action = QtWidgets.QAction(menu)
if actions > 0:
action = menu.exec_(table.mapToGlobal(position + QtCore.QPoint(15, 20)))
if action == modify_action and len(rows) == 1:
row = list(rows)[0]
tag = table.model().get_at(row)
todo.gui.tags.panel.dialog.update(table, update_tag_signal, row, tag).exec_()
elif action == delete_action:
todo.gui.tags.panel.dialog.show_delete(table, rows)
|