src/eric7/QScintilla/Editor.py

branch
eric7
changeset 10473
f45fd45cb11d
parent 10465
56a3364150b1
child 10474
c18ca679259d
diff -r 3aecfec97f7c -r f45fd45cb11d src/eric7/QScintilla/Editor.py
--- a/src/eric7/QScintilla/Editor.py	Wed Jan 03 12:12:44 2024 +0100
+++ b/src/eric7/QScintilla/Editor.py	Wed Jan 03 16:29:32 2024 +0100
@@ -11,6 +11,7 @@
 import collections
 import contextlib
 import difflib
+import enum
 import os
 import pathlib
 import re
@@ -69,6 +70,28 @@
 )
 
 
+class EditorIconId(enum.IntEnum):
+    """
+    Class defining the completion icon IDs.
+    """
+
+    Class = 1
+    ClassProtected = 2
+    ClassPrivate = 3
+    Method = 4
+    MethodProtected = 5
+    MethodPrivate = 6
+    Attribute = 7
+    AttributeProtected = 8
+    AttributePrivate = 9
+    Enum = 10
+    Keywords = 11
+    Module = 12
+
+    FromDocument = 99
+    TemplateImage = 100
+
+
 class Editor(QsciScintillaCompat):
     """
     Class implementing the editor component of the eric IDE.
@@ -153,25 +176,6 @@
     WarningInfo = 4
     WarningError = 5
 
-    # TODO: convert to an enum.IntEnum (also in Assistant plugin)
-    # Autocompletion icon definitions
-    ClassID = 1
-    ClassProtectedID = 2
-    ClassPrivateID = 3
-    MethodID = 4
-    MethodProtectedID = 5
-    MethodPrivateID = 6
-    AttributeID = 7
-    AttributeProtectedID = 8
-    AttributePrivateID = 9
-    EnumID = 10
-    KeywordsID = 11
-    ModuleID = 12
-
-    FromDocumentID = 99
-
-    TemplateImageID = 100
-
     # Cooperation related definitions
     Separator = "@@@"
 
@@ -657,49 +661,63 @@
         # finale size of the completion images
         imageSize = QSize(22, 22)
 
-        self.registerImage(self.ClassID, EricPixmapCache.getPixmap("class", imageSize))
         self.registerImage(
-            self.ClassProtectedID,
+            EditorIconId.Class,
+            EricPixmapCache.getPixmap("class", imageSize),
+        )
+        self.registerImage(
+            EditorIconId.ClassProtected,
             EricPixmapCache.getPixmap("class_protected", imageSize),
         )
         self.registerImage(
-            self.ClassPrivateID, EricPixmapCache.getPixmap("class_private", imageSize)
+            EditorIconId.ClassPrivate,
+            EricPixmapCache.getPixmap("class_private", imageSize),
         )
         self.registerImage(
-            self.MethodID, EricPixmapCache.getPixmap("method", imageSize)
+            EditorIconId.Method,
+            EricPixmapCache.getPixmap("method", imageSize),
         )
         self.registerImage(
-            self.MethodProtectedID,
+            EditorIconId.MethodProtected,
             EricPixmapCache.getPixmap("method_protected", imageSize),
         )
         self.registerImage(
-            self.MethodPrivateID, EricPixmapCache.getPixmap("method_private", imageSize)
+            EditorIconId.MethodPrivate,
+            EricPixmapCache.getPixmap("method_private", imageSize),
         )
         self.registerImage(
-            self.AttributeID, EricPixmapCache.getPixmap("attribute", imageSize)
+            EditorIconId.Attribute,
+            EricPixmapCache.getPixmap("attribute", imageSize),
         )
         self.registerImage(
-            self.AttributeProtectedID,
+            EditorIconId.AttributeProtected,
             EricPixmapCache.getPixmap("attribute_protected", imageSize),
         )
         self.registerImage(
-            self.AttributePrivateID,
+            EditorIconId.AttributePrivate,
             EricPixmapCache.getPixmap("attribute_private", imageSize),
         )
-        self.registerImage(self.EnumID, EricPixmapCache.getPixmap("enum", imageSize))
-        self.registerImage(
-            self.KeywordsID, EricPixmapCache.getPixmap("keywords", imageSize)
-        )
         self.registerImage(
-            self.ModuleID, EricPixmapCache.getPixmap("module", imageSize)
+            EditorIconId.Enum,
+            EricPixmapCache.getPixmap("enum", imageSize),
+        )
+        self.registerImage(
+            EditorIconId.Keywords,
+            EricPixmapCache.getPixmap("keywords", imageSize),
+        )
+        self.registerImage(
+            EditorIconId.Module,
+            EricPixmapCache.getPixmap("module", imageSize),
         )
 
         self.registerImage(
-            self.FromDocumentID, EricPixmapCache.getPixmap("editor", imageSize)
+            EditorIconId.FromDocument,
+            EricPixmapCache.getPixmap("editor", imageSize),
         )
 
         self.registerImage(
-            self.TemplateImageID, EricPixmapCache.getPixmap("templateViewer", imageSize)
+            EditorIconId.TemplateImage,
+            EricPixmapCache.getPixmap("templateViewer", imageSize),
         )
 
     def addClone(self, editor):
@@ -8604,7 +8622,7 @@
                             self.showUserList(
                                 TemplateCompletionListID,
                                 [
-                                    "{0}?{1:d}".format(t, self.TemplateImageID)
+                                    "{0}?{1:d}".format(t, EditorIconId.TemplateImage)
                                     for t in templateNames
                                 ],
                             )

eric ide

mercurial