Skip to content

Commit

Permalink
AttributeError when right clicking no items in Main Window TreeView (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
samtygier-stfc authored Jan 24, 2025
2 parents 1166cb4 + 46fcad0 commit 8fb608e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions mantidimaging/gui/windows/main/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,17 +652,18 @@ def _open_tree_menu(self, position: QPoint) -> None:
"""
self.menuTreeView = QMenu()

add_action = self.menuTreeView.addAction("Add / Replace Stack")
add_action.triggered.connect(self._add_images_to_existing_dataset)

if self.dataset_tree_widget.itemAt(position).id in self.presenter.all_stack_ids:
move_action = self.menuTreeView.addAction("Move Stack")
move_action.triggered.connect(self._move_stack)

delete_action = self.menuTreeView.addAction("Delete")
delete_action.triggered.connect(self._delete_container)

self.menuTreeView.exec_(self.dataset_tree_widget.viewport().mapToGlobal(position))
if self.dataset_tree_widget.itemAt(position) is not None:
if (self.dataset_tree_widget.itemAt(position).id in self.presenter.all_stack_ids
or self.dataset_tree_widget.itemAt(position).id in self.presenter.all_dataset_ids):
add_action = self.menuTreeView.addAction("Add / Replace Stack")
add_action.triggered.connect(self._add_images_to_existing_dataset)
delete_action = self.menuTreeView.addAction("Delete")
delete_action.triggered.connect(self._delete_container)
if self.dataset_tree_widget.itemAt(position).id in self.presenter.all_stack_ids:
move_action = self.menuTreeView.addAction("Move Stack")
move_action.triggered.connect(self._move_stack)

self.menuTreeView.exec_(self.dataset_tree_widget.viewport().mapToGlobal(position))

def _delete_container(self) -> None:
"""
Expand Down

0 comments on commit 8fb608e

Please sign in to comment.