diff options
author | Joris | 2020-05-10 20:24:24 +0200 |
---|---|---|
committer | Joris | 2020-05-10 20:24:24 +0200 |
commit | 8a6e10d401eea8db0947f8c4b309b8a6256f9748 (patch) | |
tree | 6e2dc6956ce7825f0f1b6c3ed6f0b4171fe9c274 /src/gui/tags/table/menu.py | |
parent | 3e1415c738facb8b0274adb50ae65f218fd59c9b (diff) | |
download | todo-8a6e10d401eea8db0947f8c4b309b8a6256f9748.tar.gz todo-8a6e10d401eea8db0947f8c4b309b8a6256f9748.tar.bz2 todo-8a6e10d401eea8db0947f8c4b309b8a6256f9748.zip |
Add tags panel
Diffstat (limited to 'src/gui/tags/table/menu.py')
-rw-r--r-- | src/gui/tags/table/menu.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gui/tags/table/menu.py b/src/gui/tags/table/menu.py new file mode 100644 index 0000000..7acdda1 --- /dev/null +++ b/src/gui/tags/table/menu.py @@ -0,0 +1,25 @@ +from PyQt5 import QtWidgets + +import db.tags +import gui.tags.dialog +from model.tag import Tag, ValidTagForm + +def open(database, table, update_tag_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)) + if action == modify_action and len(rows) == 1: + row = list(rows)[0] + tag = table.model().get_at(row) + gui.tags.dialog.update(database, table, update_tag_signal, row, tag).exec_() + elif action == delete_action: + gui.tags.dialog.show_delete(database, table, rows) |