src/eric7/QScintilla/EditorOutlineModel.py

branch
eric7
changeset 10832
479cf39ac9cb
parent 10588
8edb63666f73
child 11090
f5f5f5803935
diff -r f6be97f4d96a -r 479cf39ac9cb src/eric7/QScintilla/EditorOutlineModel.py
--- a/src/eric7/QScintilla/EditorOutlineModel.py	Sat Jul 06 19:48:50 2024 +0200
+++ b/src/eric7/QScintilla/EditorOutlineModel.py	Sun Jul 07 12:57:21 2024 +0200
@@ -23,7 +23,9 @@
     BrowserItem,
     BrowserMethodItem,
     BrowserModel,
+    BrowserModelType,
 )
+from eric7.UI.BrowserSortFilterProxyModel import BrowserSortFilterProxyModel
 from eric7.Utilities import ClassBrowsers
 from eric7.Utilities.ClassBrowsers import ClbrBaseClasses
 
@@ -50,7 +52,7 @@
         @param populate flag indicating to populate the outline
         @type bool
         """
-        super().__init__(nopopulate=True)
+        super().__init__(nopopulate=True, modelType=BrowserModelType.EditorOutline)
 
         self.__editor = editor
 
@@ -97,10 +99,18 @@
                             if isinstance(
                                 cl, (ClbrBaseClasses.Class, ClbrBaseClasses.Module)
                             ):
-                                node = BrowserClassItem(parentItem, cl, self.__filename)
+                                node = BrowserClassItem(
+                                    parentItem,
+                                    cl,
+                                    self.__filename,
+                                    modelType=self._modelType,
+                                )
                             elif isinstance(cl, ClbrBaseClasses.Function):
                                 node = BrowserMethodItem(
-                                    parentItem, cl, self.__filename
+                                    parentItem,
+                                    cl,
+                                    self.__filename,
+                                    modelType=self._modelType,
                                 )
                             else:
                                 node = None
@@ -280,3 +290,35 @@
         @rtype str
         """
         return list(ClassBrowsers.ClassBrowserRegistry) + list(cls.SupportedLanguages)
+
+
+class EditorOutlineSortFilterProxyModel(BrowserSortFilterProxyModel):
+    """
+    Class implementing the editor outline sort filter proxy model.
+    """
+
+    def __init__(self, parent=None):
+        """
+        Constructor
+
+        @param parent reference to the parent object
+        @type QObject
+        """
+        super().__init__(parent)
+
+    def filterAcceptsRow(self, _source_row, _source_parent):
+        """
+        Public method to filter rows.
+
+        This overrides the filtering of the parent class by always accept
+        the row.
+
+        @param _source_row row number (in the source model) of item
+        @type int
+        @param _source_parent index of parent item (in the source model)
+            of item
+        @type QModelIndex
+        @return flag indicating, if the item should be shown
+        @rtype bool
+        """
+        return True

eric ide

mercurial