Skip to content

Commit

Permalink
delete selection items
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhrisca committed Oct 20, 2023
1 parent 9f978c8 commit 0c16fe3
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 145 deletions.
1 change: 1 addition & 0 deletions src/asammdf/gui/dialogs/advanced_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(
super().__init__(*args, **kwargs)
self.setupUi(self)

self.selection.can_delete_items = True
self.selection.all_texts = True

self.result = {}
Expand Down
42 changes: 42 additions & 0 deletions src/asammdf/gui/dialogs/advanced_search_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from PySide6 import QtCore, QtWidgets


class SearchTreeItem(QtWidgets.QTreeWidgetItem):
def __init__(self, name, group, index, unit, source_name, source_path, comment):
super().__init__([name, group, index, unit, source_name, source_path, comment])

self.name = name
self.group = group
self.index = index
self.unit = unit
self.source_name = source_name
self.source_path = source_path
self.comment = comment

def __del__(self):
self.name = None
self.group = None
self.index = None
self.unit = None
self.source_name = None
self.source_path = None
self.comment = None


class SearchTreeWidget(QtWidgets.QTreeWidget):
def __init__(self, can_delete_items=False, *args, **kwargs):
super().__init__(*args, **kwargs)

self.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)
self.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.NoDragDrop)
self.setUniformRowHeights(True)

self.can_delete_items = can_delete_items

def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key.Key_Delete and self.can_delete_items:
selected_items = self.selectedItems()

root = self.invisibleRootItem()
for item in selected_items:
(item.parent() or root).removeChild(item)
Loading

0 comments on commit 0c16fe3

Please sign in to comment.