Improved the handling of the various auto-completion actions. 6_0_x

Fri, 27 Feb 2015 19:43:04 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 27 Feb 2015 19:43:04 +0100
branch
6_0_x
changeset 4135
e429edcd67cf
parent 4129
8d557a90b6e7
child 4136
8254abb49c53

Improved the handling of the various auto-completion actions.
(grafted from 3d868439dddcf70105db1d61dbed34996414d3cf)

QScintilla/APIsManager.py file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
ViewManager/ViewManager.py file | annotate | diff | comparison | revisions
--- a/QScintilla/APIsManager.py	Tue Feb 24 18:31:14 2015 +0100
+++ b/QScintilla/APIsManager.py	Fri Feb 27 19:43:04 2015 +0100
@@ -100,6 +100,14 @@
             self.prepareAPIs()
         return self.__apis
     
+    def isEmpty(self):
+        """
+        Public method to check, if the object has API files configured.
+        
+        @return flag indicating no API files have been configured (boolean)
+        """
+        return len(self.__apifiles) == 0
+    
     def __apiPreparationFinished(self):
         """
         Private method called to save an API, after it has been prepared.
--- a/QScintilla/Editor.py	Tue Feb 24 18:31:14 2015 +0100
+++ b/QScintilla/Editor.py	Fri Feb 27 19:43:04 2015 +0100
@@ -1561,7 +1561,7 @@
         
         # initialize the lexer APIs settings
         api = self.vm.getAPIsManager().getAPIs(self.apiLanguage)
-        if api is not None:
+        if api is not None and not api.isEmpty():
             self.lexer_.setAPIs(api.getQsciAPIs())
             self.acAPI = True
         else:
@@ -4627,6 +4627,23 @@
         """
         return self.__ctHookFunction
     
+    def canProvideCallTipps(self):
+        """
+        Public method to test the calltips availability.
+        
+        @return flag indicating the availability of calltips (boolean)
+        """
+        return self.acAPI or self.__ctHookFunction is not None
+    
+    def canProvideDynamicAutoCompletion(self):
+        """
+        Public method to test the dynamic auto-completion availability.
+        
+        @return flag indicating the availability of dynamic auto-completion
+            (boolean)
+        """
+        return self.acAPI or self.__acHookFunction is not None
+    
     #################################################################
     ## Methods needed by the context menu
     #################################################################
@@ -4749,10 +4766,10 @@
         Private slot called before the autocompletion menu is shown.
         """
         self.menuActs["acDynamic"].setEnabled(
-            self.acAPI or self.__acHookFunction is not None)
+            self.canProvideDynamicAutoCompletion())
         self.menuActs["acAPI"].setEnabled(self.acAPI)
         self.menuActs["acAPIDocument"].setEnabled(self.acAPI)
-        self.menuActs["calltip"].setEnabled(self.acAPI)
+        self.menuActs["calltip"].setEnabled(self.canProvideCallTipps())
         
         self.showMenu.emit("Autocompletion", self.autocompletionMenu, self)
         
--- a/ViewManager/ViewManager.py	Tue Feb 24 18:31:14 2015 +0100
+++ b/ViewManager/ViewManager.py	Fri Feb 27 19:43:04 2015 +0100
@@ -5283,7 +5283,12 @@
         @param available flag indicating the availability of API
         autocompletion (boolean)
         """
+        editor = self.sender()
+        self.autoCompleteAct.setEnabled(
+            editor.canProvideDynamicAutoCompletion())
         self.autoCompleteFromAPIsAct.setEnabled(available)
+        self.autoCompleteFromAllAct.setEnabled(available)
+        self.calltipsAct.setEnabled(editor.canProvideCallTipps())
         
     def __editShowCallTips(self):
         """
@@ -6407,8 +6412,13 @@
             
             if editor.canAutoCompleteFromAPIs():
                 self.autoCompleteFromAPIsAct.setEnabled(True)
+                self.autoCompleteFromAllAct.setEnabled(True)
             else:
                 self.autoCompleteFromAPIsAct.setEnabled(False)
+                self.autoCompleteFromAllAct.setEnabled(False)
+            self.autoCompleteAct.setEnabled(
+                editor.canProvideDynamicAutoCompletion())
+            self.calltipsAct.setEnabled(editor.canProvideCallTipps())
             
             if editor.isPyFile() or editor.isRubyFile():
                 self.gotoPreviousDefAct.setEnabled(True)

eric ide

mercurial