from PyQt5 import QtWidgets import db.tasks import gui.tasks.dialog from model.task import Task, ValidTaskForm def open(database, table, 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.icons.dialog_open(menu.style()), 'modify') else: modify_action = QtWidgets.QAction(menu) delete_action = menu.addAction(gui.icons.trash(menu.style()), 'Delete') action = menu.exec_(table.mapToGlobal(position)) if action == modify_action and len(rows) == 1: row = list(rows)[0] task = table.model().get_at(row) gui.tasks.dialog.update(database, table, update_task_signal, row, task).exec_() elif action == delete_action: gui.tasks.dialog.show_delete(database, table, rows)