eric7/E5Gui/E5ListView.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8355
8a7677a63c8d
child 8357
a081458cc57b
--- a/eric7/E5Gui/E5ListView.py	Sat May 22 17:01:51 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2009 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
-#
-
-"""
-Module implementing specialized list views.
-"""
-
-from PyQt6.QtCore import Qt, QItemSelectionModel
-from PyQt6.QtWidgets import QListView
-
-
-class E5ListView(QListView):
-    """
-    Class implementing a list 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
-        ):
-            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:
-            # no models available
-            return
-        
-        row = 0
-        selectedRows = self.selectionModel().selectedRows()
-        for selectedRow in reversed(selectedRows):
-            row = selectedRow.row()
-            self.model().removeRow(row, self.rootIndex())
-        
-        idx = self.model().index(row, 0, self.rootIndex())
-        if not idx.isValid():
-            idx = self.model().index(row - 1, 0, self.rootIndex())
-        self.selectionModel().select(
-            idx,
-            QItemSelectionModel.SelectionFlag.SelectCurrent |
-            QItemSelectionModel.SelectionFlag.Rows)
-        self.setCurrentIndex(idx)
-    
-    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())

eric ide

mercurial