diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/EricWidgets/EricTreeView.py --- a/src/eric7/EricWidgets/EricTreeView.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/EricWidgets/EricTreeView.py Wed Jul 13 14:55:47 2022 +0200 @@ -15,41 +15,43 @@ """ Class implementing a tree view supporting removal of entries. """ + def keyPressEvent(self, evt): """ Protected method implementing special key handling. - + @param evt reference to the event (QKeyEvent) """ if ( - evt.key() in [Qt.Key.Key_Delete, Qt.Key.Key_Backspace] and - self.model() is not None + evt.key() in [Qt.Key.Key_Delete, Qt.Key.Key_Backspace] + and self.model() is not None ): self.removeSelected() evt.setAccepted(True) else: super().keyPressEvent(evt) - + def removeSelected(self): """ Public method to remove the selected entries. """ if ( - self.model() is None or - self.selectionModel() is None or - not self.selectionModel().hasSelection() + self.model() is None + or self.selectionModel() is None + or not self.selectionModel().hasSelection() ): # no models available or nothing selected return - + selectedRows = self.selectionModel().selectedRows() for idx in sorted(selectedRows, reverse=True): self.model().removeRow(idx.row(), idx.parent()) - + def removeAll(self): """ Public method to clear the view. """ if self.model() is not None: - self.model().removeRows(0, self.model().rowCount(self.rootIndex()), - self.rootIndex()) + self.model().removeRows( + 0, self.model().rowCount(self.rootIndex()), self.rootIndex() + )