Skip to content

Commit

Permalink
Delete a node or link from topology summary view using Delete key. Ref
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed May 14, 2023
1 parent d1fae54 commit 59ef34c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions gns3/topology_summary_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,22 @@ def _resumeAllLinksSlot(self, *args):
for link in self._topology.links():
if link.suspended():
link.toggleSuspend()

def keyPressEvent(self, event):
"""
Handles key press events
"""

from .main_window import MainWindow
view = MainWindow.instance().uiGraphicsView
# only deleting a link or node is supported for now
if event.key() == QtCore.Qt.Key_Delete:
current_item = self.currentItem()
if isinstance(current_item, TopologyNodeItem):
current_item.node().delete()
else:
link = current_item.data(0, QtCore.Qt.UserRole)
for item in view.scene().items():
if isinstance(item, LinkItem) and item.link() == link:
item.delete()
super().keyPressEvent(event)

0 comments on commit 59ef34c

Please sign in to comment.