src/eric7/Preferences/__init__.py

branch
eric7
changeset 9525
477545eef9f4
parent 9522
f46abb15aab2
child 9527
8601253e7633
--- a/src/eric7/Preferences/__init__.py	Wed Nov 23 16:07:16 2022 +0100
+++ b/src/eric7/Preferences/__init__.py	Thu Nov 24 11:51:40 2022 +0100
@@ -52,17 +52,6 @@
 from eric7.EricWidgets.EricApplication import ericApp
 from eric7.EricWidgets.EricIconBar import EricIconBar
 
-# TODO: eliminate ProjectBrowserFlags
-from eric7.Project.ProjectBrowserFlags import (
-    AllBrowsersFlag,
-    FormsBrowserFlag,
-    InterfacesBrowserFlag,
-    OthersBrowserFlag,
-    ProtocolsBrowserFlag,
-    ResourcesBrowserFlag,
-    SourcesBrowserFlag,
-    TranslationsBrowserFlag,
-)
 from eric7.QScintilla.Shell import ShellHistoryStyle
 from eric7.Utilities.crypto import pwConvert
 from eric7.Utilities.crypto.py3PBKDF2 import hashPassword
@@ -775,95 +764,55 @@
         "Workspace": "",
     }
 
-    # defaults for the project browser flags settings
-    # TODO: change this to 'projectBrowserTypesDefaults
-    #       all without 'interfaces' and 'protocols'
-    projectBrowserFlagsDefaults = {
+    # defaults for the project browser lists settings
+    projectBrowsersDefaults = {
+        "allBrowsers": (
+            "sources", "forms", "resources", "translations", "others",
+            "interfaces", "protocols",
+        ),
         "PyQt5": (
-            SourcesBrowserFlag
-            | FormsBrowserFlag
-            | ResourcesBrowserFlag
-            | TranslationsBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "forms", "resources", "translations", "others",
+            "interfaces", "protocols",
         ),
         "PyQt5C": (
-            SourcesBrowserFlag
-            | ResourcesBrowserFlag
-            | TranslationsBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "resources", "translations", "others",
+            "interfaces", "protocols",
         ),
         "PyQt6": (
-            SourcesBrowserFlag
-            | FormsBrowserFlag
-            | TranslationsBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "forms", "translations", "others",
+            "interfaces", "protocols",
         ),
         "PyQt6C": (
-            SourcesBrowserFlag
-            | TranslationsBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "translations", "others",
+            "interfaces", "protocols",
         ),
         "E7Plugin": (
-            SourcesBrowserFlag
-            | FormsBrowserFlag
-            | TranslationsBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "forms", "translations", "others",
+            "interfaces", "protocols",
         ),
         "Console": (
-            SourcesBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "others",
+            "interfaces", "protocols",
         ),
         "Other": (
-            SourcesBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "others",
+            "interfaces", "protocols",
         ),
         "PySide2": (
-            SourcesBrowserFlag
-            | FormsBrowserFlag
-            | ResourcesBrowserFlag
-            | TranslationsBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "forms", "resources", "translations", "others",
+            "interfaces", "protocols",
         ),
         "PySide2C": (
-            SourcesBrowserFlag
-            | ResourcesBrowserFlag
-            | TranslationsBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "resources", "translations", "others",
+            "interfaces", "protocols",
         ),
         "PySide6": (
-            SourcesBrowserFlag
-            | FormsBrowserFlag
-            | ResourcesBrowserFlag
-            | TranslationsBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "forms", "resources", "translations", "others",
+            "interfaces", "protocols",
         ),
         "PySide6C": (
-            SourcesBrowserFlag
-            | ResourcesBrowserFlag
-            | TranslationsBrowserFlag
-            | InterfacesBrowserFlag
-            | OthersBrowserFlag
-            | ProtocolsBrowserFlag
+            "sources", "resources", "translations", "others",
+            "interfaces", "protocols",
         ),
     }
 
@@ -2660,30 +2609,33 @@
         Prefs.settings.setValue("Project/" + key, value)
 
 
-# TODO: change this to use the type names
-def getProjectBrowserFlags(key):
+def getProjectBrowsers(key):
     """
-    Module function to retrieve the various project browser flags settings.
-
-    @param key the key of the value to get
-    @return the requested project setting
+    Function to retrieve the enabled project browsers per project type.
+
+    @param key project type
+    @type str
+    @return list of enabled project browsers
+    @rtype list of str
     """
     try:
-        default = Prefs.projectBrowserFlagsDefaults[key]
+        default = list(Prefs.projectBrowsersDefaults[key][:])
     except KeyError:
-        default = AllBrowsersFlag
-
-    return int(Prefs.settings.value("Project/BrowserFlags/" + key, default))
-
-
-def setProjectBrowserFlags(key, value):
+        default = list(Prefs.projectBrowsersDefaults["allBrowsers"][:])
+
+    return toList(Prefs.settings.value("Project/BrowsersEnabled/" + key, default))
+
+
+def setProjectBrowsers(key, value):
     """
-    Module function to store the various project browser flags settings.
-
-    @param key the key of the setting to be set
-    @param value the value to be set
+    Function to store the enabled project browsers per project type.
+
+    @param key project type
+    @type str
+    @param value list of enabled project browsers
+    @type list of str
     """
-    Prefs.settings.setValue("Project/BrowserFlags/" + key, value)
+    Prefs.settings.setValue("Project/BrowsersEnabled/" + key, value)
 
 
 def getProjectBrowserColour(key):

eric ide

mercurial