-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f978c8
commit 0c16fe3
Showing
5 changed files
with
218 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.