Skip to content

Commit

Permalink
Methods deletion simplification and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvisscher committed Sep 30, 2024
1 parent 9a4f00b commit d781f33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions activity_browser/actions/method/method_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,19 @@ class MethodDelete(ABAction):
@staticmethod
@exception_dialogs
def run(methods: List[tuple], level: str):
# this action can handle only one selected method for now
selected_method = methods[0]

# check whether we're dealing with a leaf or node. If it's a node, select all underlying methods for deletion
if level is not None and level != "leaf":
all_methods = [
bd.Method(method)
for method in bd.methods
if set(selected_method).issubset(method)
]
all_methods = [bd.Method(method) for method in methods]

if len(all_methods) == 1:
warning_text = f"Are you sure you want to delete this method?\n\n{methods[0]}"
else:
all_methods = [bd.Method(selected_method)]
warning_text = f"Are you sure you want to delete {len(all_methods)} methods?"

# warn the user about the pending deletion
warning = QtWidgets.QMessageBox.warning(
application.main_window,
"Deleting Method",
f"Are you sure you want to delete this method and possible underlying "
f"methods?\n\n{selected_method}",
warning_text,
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
QtWidgets.QMessageBox.No,
)
Expand Down
2 changes: 1 addition & 1 deletion activity_browser/ui/tables/impact_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def selected_methods(self) -> Iterable:
filter_on = ", ".join(tree_level[1]) + ", "

methods = self.model.get_methods(filter_on)
return methods
return list(methods)

def tree_level(self) -> tuple:
"""Return list of (tree level, content).
Expand Down

0 comments on commit d781f33

Please sign in to comment.