Thu, 12 Aug 2010 19:06:24 +0200
Added code to use the new style signal API depending upon the eric5 version.
--- a/AssistantEric/APIsManager.py Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/APIsManager.py Thu Aug 12 19:06:24 2010 +0200 @@ -331,6 +331,10 @@ @signal apiPreparationCancelled() emitted after the API preparation has been cancelled """ + apiPreparationFinished = pyqtSignal() + apiPreparationStarted = pyqtSignal() + apiPreparationCancelled = pyqtSignal() + DB_VERSION = 3 create_mgmt_stmt = """ @@ -408,16 +412,18 @@ INSERT INTO mgmt (format) VALUES ({0:d}) """.format(DB_VERSION) - def __init__(self, language, parent = None): + def __init__(self, language, newStyle, parent = None): """ Constructor @param language language of the APIs object (string) + @param newStyle flag indicating usage of new style signals (bool) @param parent reference to the parent object (QObject) """ QObject.__init__(self, parent) self.setObjectName("DbAPIs_{0}".format(language)) + self.__newStyle = newStyle self.__inPreparation = False self.__worker = None self.__workerQueue = [] @@ -435,9 +441,14 @@ self.__lexer = None self.__project = e5App().getObject("Project") - self.connect(self.__project, SIGNAL("projectOpened"), self.__projectOpened) - self.connect(self.__project, SIGNAL("newProject"), self.__projectOpened) - self.connect(self.__project, SIGNAL("projectClosed"), self.__projectClosed) + if self.__newStyle: + self.__project.projectOpened.connect(self.__projectOpened) + self.__project.newProject.connect(self.__projectOpened) + self.__project.projectClosed.connect(self.__projectClosed) + else: + self.connect(self.__project, SIGNAL("projectOpened"), self.__projectOpened) + self.connect(self.__project, SIGNAL("newProject"), self.__projectOpened) + self.connect(self.__project, SIGNAL("projectClosed"), self.__projectClosed) if self.__project.isOpen(): self.__projectOpened() @@ -766,18 +777,27 @@ """ if evt.type() == WorkerStarted: self.__inPreparation = True - self.emit(SIGNAL('apiPreparationStarted()')) + if self.__newStyle: + self.apiPreparationStarted.emit() + else: + self.emit(SIGNAL('apiPreparationStarted()')) return True elif evt.type() == WorkerFinished: self.__inPreparation = False - self.emit(SIGNAL('apiPreparationFinished()')) + if self.__newStyle: + self.apiPreparationFinished.emit() + else: + self.emit(SIGNAL('apiPreparationFinished()')) QTimer.singleShot(0, self.__processQueue) return True elif evt.type() == WorkerAborted: self.__inPreparation = False - self.emit(SIGNAL('apiPreparationCancelled()')) + if self.__newStyle: + self.apiPreparationCancelled.emit() + else: + self.emit(SIGNAL('apiPreparationCancelled()')) QTimer.singleShot(0, self.__processQueue) return True @@ -820,15 +840,18 @@ Class implementing the APIsManager class, which is the central store for API information used by autocompletion and calltips. """ - def __init__(self, parent = None): + def __init__(self, newStyle, parent = None): """ Constructor + @param newStyle flag indicating usage of new style signals (bool) @param parent reference to the parent object (QObject) """ QObject.__init__(self, parent) self.setObjectName("APIsManager") + self.__newStyle = newStyle + # initialize the apis dictionary self.__apis = {} @@ -855,7 +878,7 @@ if language in QScintilla.Lexers.getSupportedLanguages() or \ language == ApisNameProject: # create the api object - self.__apis[language] = DbAPIs(language) + self.__apis[language] = DbAPIs(language, self.__newStyle) return self.__apis[language] else: return None
--- a/AssistantEric/Assistant.py Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Assistant.py Thu Aug 12 19:06:24 2010 +0200 @@ -29,22 +29,24 @@ """ Class implementing the autocompletion and calltips system. """ - def __init__(self, plugin, parent = None): + def __init__(self, plugin, newStyle, parent = None): """ Constructor @param plugin reference to the plugin object + @param newStyle flag indicating usage of new style signals (bool) @param parent parent (QObject) """ QObject.__init__(self, parent) self.__plugin = plugin + self.__newStyle = newStyle self.__ui = parent self.__project = e5App().getObject("Project") self.__viewmanager = e5App().getObject("ViewManager") self.__pluginManager = e5App().getObject("PluginManager") - self.__apisManager = APIsManager(self) + self.__apisManager = APIsManager(self.__newStyle, self) self.__editors = [] self.__completingContext = False @@ -57,16 +59,24 @@ """ Public method to perform actions upon activation. """ - self.connect(self.__pluginManager, SIGNAL("shutdown()"), - self.__shutdown) - - self.connect(self.__ui, SIGNAL('preferencesChanged'), - self.__preferencesChanged) - - self.connect(self.__viewmanager, SIGNAL("editorOpenedEd"), - self.__editorOpened) - self.connect(self.__viewmanager, SIGNAL("editorClosedEd"), - self.__editorClosed) + if self.__newStyle: + self.__pluginManager.shutdown.connect(self.__shutdown) + + self.__ui.preferencesChanged.connect(self.__preferencesChanged) + + self.__viewmanager.editorOpenedEd.connect(self.__editorOpened) + self.__viewmanager.editorClosedEd.connect(self.__editorClosed) + else: + self.connect(self.__pluginManager, SIGNAL("shutdown()"), + self.__shutdown) + + self.connect(self.__ui, SIGNAL('preferencesChanged'), + self.__preferencesChanged) + + self.connect(self.__viewmanager, SIGNAL("editorOpenedEd"), + self.__editorOpened) + self.connect(self.__viewmanager, SIGNAL("editorClosedEd"), + self.__editorClosed) # preload the project APIs object self.__apisManager.getAPIs(ApisNameProject) @@ -78,16 +88,24 @@ """ Public method to perform actions upon deactivation. """ - self.disconnect(self.__pluginManager, SIGNAL("shutdown()"), - self.__shutdown) - - self.disconnect(self.__ui, SIGNAL('preferencesChanged'), - self.__preferencesChanged) - - self.disconnect(self.__viewmanager, SIGNAL("editorOpenedEd"), - self.__editorOpened) - self.disconnect(self.__viewmanager, SIGNAL("editorClosedEd"), - self.__editorClosed) + if self.__newStyle: + self.__pluginManager.shutdown.disconnect(self.__shutdown) + + self.__ui.preferencesChanged.disconnect(self.__preferencesChanged) + + self.__viewmanager.editorOpenedEd.disconnect(self.__editorOpened) + self.__viewmanager.editorClosedEd.disconnect(self.__editorClosed) + else: + self.disconnect(self.__pluginManager, SIGNAL("shutdown()"), + self.__shutdown) + + self.disconnect(self.__ui, SIGNAL('preferencesChanged'), + self.__preferencesChanged) + + self.disconnect(self.__viewmanager, SIGNAL("editorOpenedEd"), + self.__editorOpened) + self.disconnect(self.__viewmanager, SIGNAL("editorClosedEd"), + self.__editorClosed) self.__shutdown() @@ -123,8 +141,12 @@ self.__setAutoCompletionHook(editor) if self.__plugin.getPreferences("CalltipsEnabled"): self.__setCalltipsHook(editor) - self.connect(editor, SIGNAL("editorSaved"), - self.__apisManager.getAPIs(ApisNameProject).editorSaved) + if self.__newStyle: + editor.editorSaved.connect( + self.__apisManager.getAPIs(ApisNameProject).editorSaved) + else: + self.connect(editor, SIGNAL("editorSaved"), + self.__apisManager.getAPIs(ApisNameProject).editorSaved) self.__editors.append(editor) # preload the api to give the manager a chance to prepare the database @@ -140,8 +162,12 @@ @param editor reference to the editor (QScintilla.Editor) """ if editor in self.__editors: - self.disconnect(editor, SIGNAL("editorSaved"), - self.__apisManager.getAPIs(ApisNameProject).editorSaved) + if self.__newStyle: + editor.editorSaved.disconnect( + self.__apisManager.getAPIs(ApisNameProject).editorSaved) + else: + self.disconnect(editor, SIGNAL("editorSaved"), + self.__apisManager.getAPIs(ApisNameProject).editorSaved) self.__editors.remove(editor) if editor.autoCompletionHook() == self.autocomplete: self.__unsetAutoCompletionHook(editor) @@ -220,8 +246,11 @@ @param editor reference to the editor (QScintilla.Editor) """ - self.connect(editor, SIGNAL('userListActivated(int, const QString)'), - self.__completionListSelected) + if self.__newStyle: + editor.userListActivated.connect(self.__completionListSelected) + else: + self.connect(editor, SIGNAL('userListActivated(int, const QString)'), + self.__completionListSelected) editor.setAutoCompletionHook(self.autocomplete) def __unsetAutoCompletionHook(self, editor): @@ -231,8 +260,11 @@ @param editor reference to the editor (QScintilla.Editor) """ editor.unsetAutoCompletionHook() - self.disconnect(editor, SIGNAL('userListActivated(int, const QString)'), - self.__completionListSelected) + if self.__newStyle: + editor.userListActivated.disconnect(self.__completionListSelected) + else: + self.disconnect(editor, SIGNAL('userListActivated(int, const QString)'), + self.__completionListSelected) def autocomplete(self, editor, context): """
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.APIsManager.html Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.APIsManager.html Thu Aug 12 19:06:24 2010 +0200 @@ -5,17 +5,17 @@ <title>Plugin_Assistant_Eric.AssistantEric.APIsManager</title> <style> body { - background:white; + background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } -h1 { color: white; background: #4FA4FF; } -h2 { color: white; background: #4FA4FF; } -h3 { color: white; background: #00557F; } -h4 { color: white; background: #00557F; } +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } -a { color: #AA5500; } +a { color: #BA6D36; } </style> </head> @@ -76,11 +76,14 @@ </table> <a NAME="APIsManager.__init__" ID="APIsManager.__init__"></a> <h4>APIsManager (Constructor)</h4> -<b>APIsManager</b>(<i>parent = None</i>) +<b>APIsManager</b>(<i>newStyle, parent = None</i>) <p> Constructor </p><dl> -<dt><i>parent</i></dt> +<dt><i>newStyle</i></dt> +<dd> +flag indicating usage of new style signals (bool) +</dd><dt><i>parent</i></dt> <dd> reference to the parent object (QObject) </dd> @@ -137,7 +140,7 @@ QObject <h3>Class Attributes</h3> <table> -<tr><td>DB_VERSION</td></tr><tr><td>ac_context_stmt</td></tr><tr><td>ac_stmt</td></tr><tr><td>api_files_stmt</td></tr><tr><td>create_acWord_idx</td></tr><tr><td>create_api_stmt</td></tr><tr><td>create_context_idx</td></tr><tr><td>create_file_idx</td></tr><tr><td>create_file_stmt</td></tr><tr><td>create_fullContext_idx</td></tr><tr><td>create_mgmt_stmt</td></tr><tr><td>ct_context_stmt</td></tr><tr><td>ct_fullContext_stmt</td></tr><tr><td>ct_stmt</td></tr><tr><td>drop_acWord_idx</td></tr><tr><td>drop_api_stmt</td></tr><tr><td>drop_context_idx</td></tr><tr><td>drop_file_idx</td></tr><tr><td>drop_file_stmt</td></tr><tr><td>drop_fullContext_idx</td></tr><tr><td>drop_mgmt_stmt</td></tr><tr><td>format_select_stmt</td></tr><tr><td>mgmt_insert_stmt</td></tr> +<tr><td>DB_VERSION</td></tr><tr><td>ac_context_stmt</td></tr><tr><td>ac_stmt</td></tr><tr><td>apiPreparationCancelled</td></tr><tr><td>apiPreparationFinished</td></tr><tr><td>apiPreparationStarted</td></tr><tr><td>api_files_stmt</td></tr><tr><td>create_acWord_idx</td></tr><tr><td>create_api_stmt</td></tr><tr><td>create_context_idx</td></tr><tr><td>create_file_idx</td></tr><tr><td>create_file_stmt</td></tr><tr><td>create_fullContext_idx</td></tr><tr><td>create_mgmt_stmt</td></tr><tr><td>ct_context_stmt</td></tr><tr><td>ct_fullContext_stmt</td></tr><tr><td>ct_stmt</td></tr><tr><td>drop_acWord_idx</td></tr><tr><td>drop_api_stmt</td></tr><tr><td>drop_context_idx</td></tr><tr><td>drop_file_idx</td></tr><tr><td>drop_file_stmt</td></tr><tr><td>drop_fullContext_idx</td></tr><tr><td>drop_mgmt_stmt</td></tr><tr><td>format_select_stmt</td></tr><tr><td>mgmt_insert_stmt</td></tr> </table> <h3>Methods</h3> <table> @@ -208,13 +211,16 @@ </table> <a NAME="DbAPIs.__init__" ID="DbAPIs.__init__"></a> <h4>DbAPIs (Constructor)</h4> -<b>DbAPIs</b>(<i>language, parent = None</i>) +<b>DbAPIs</b>(<i>language, newStyle, parent = None</i>) <p> Constructor </p><dl> <dt><i>language</i></dt> <dd> language of the APIs object (string) +</dd><dt><i>newStyle</i></dt> +<dd> +flag indicating usage of new style signals (bool) </dd><dt><i>parent</i></dt> <dd> reference to the parent object (QObject)
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html Thu Aug 12 19:06:24 2010 +0200 @@ -5,17 +5,17 @@ <title>Plugin_Assistant_Eric.AssistantEric.Assistant</title> <style> body { - background:white; + background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } -h1 { color: white; background: #4FA4FF; } -h2 { color: white; background: #4FA4FF; } -h3 { color: white; background: #00557F; } -h4 { color: white; background: #00557F; } +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } -a { color: #AA5500; } +a { color: #BA6D36; } </style> </head> @@ -112,13 +112,16 @@ </table> <a NAME="Assistant.__init__" ID="Assistant.__init__"></a> <h4>Assistant (Constructor)</h4> -<b>Assistant</b>(<i>plugin, parent = None</i>) +<b>Assistant</b>(<i>plugin, newStyle, parent = None</i>) <p> Constructor </p><dl> <dt><i>plugin</i></dt> <dd> reference to the plugin object +</dd><dt><i>newStyle</i></dt> +<dd> +flag indicating usage of new style signals (bool) </dd><dt><i>parent</i></dt> <dd> parent (QObject)
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.ConfigurationPages.AutoCompletionEricPage.html Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.ConfigurationPages.AutoCompletionEricPage.html Thu Aug 12 19:06:24 2010 +0200 @@ -5,17 +5,17 @@ <title>Plugin_Assistant_Eric.AssistantEric.ConfigurationPages.AutoCompletionEricPage</title> <style> body { - background:white; + background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } -h1 { color: white; background: #4FA4FF; } -h2 { color: white; background: #4FA4FF; } -h3 { color: white; background: #00557F; } -h4 { color: white; background: #00557F; } +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } -a { color: #AA5500; } +a { color: #BA6D36; } </style> </head>
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.ConfigurationPages.CallTipsEricPage.html Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.ConfigurationPages.CallTipsEricPage.html Thu Aug 12 19:06:24 2010 +0200 @@ -5,17 +5,17 @@ <title>Plugin_Assistant_Eric.AssistantEric.ConfigurationPages.CallTipsEricPage</title> <style> body { - background:white; + background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } -h1 { color: white; background: #4FA4FF; } -h2 { color: white; background: #4FA4FF; } -h3 { color: white; background: #00557F; } -h4 { color: white; background: #00557F; } +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } -a { color: #AA5500; } +a { color: #BA6D36; } </style> </head>
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.PluginAssistantEric.html Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.PluginAssistantEric.html Thu Aug 12 19:06:24 2010 +0200 @@ -5,17 +5,17 @@ <title>Plugin_Assistant_Eric.PluginAssistantEric</title> <style> body { - background:white; + background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } -h1 { color: white; background: #4FA4FF; } -h2 { color: white; background: #4FA4FF; } -h3 { color: white; background: #00557F; } -h4 { color: white; background: #00557F; } +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } -a { color: #AA5500; } +a { color: #BA6D36; } </style> </head>
--- a/AssistantEric/Documentation/source/index-Plugin_Assistant_Eric.AssistantEric.ConfigurationPages.html Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Documentation/source/index-Plugin_Assistant_Eric.AssistantEric.ConfigurationPages.html Thu Aug 12 19:06:24 2010 +0200 @@ -5,17 +5,17 @@ <title>Plugin_Assistant_Eric.AssistantEric.ConfigurationPages</title> <style> body { - background:white; + background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } -h1 { color: white; background: #4FA4FF; } -h2 { color: white; background: #4FA4FF; } -h3 { color: white; background: #00557F; } -h4 { color: white; background: #00557F; } +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } -a { color: #AA5500; } +a { color: #BA6D36; } </style> </head>
--- a/AssistantEric/Documentation/source/index-Plugin_Assistant_Eric.AssistantEric.html Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Documentation/source/index-Plugin_Assistant_Eric.AssistantEric.html Thu Aug 12 19:06:24 2010 +0200 @@ -5,17 +5,17 @@ <title>Plugin_Assistant_Eric.AssistantEric</title> <style> body { - background:white; + background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } -h1 { color: white; background: #4FA4FF; } -h2 { color: white; background: #4FA4FF; } -h3 { color: white; background: #00557F; } -h4 { color: white; background: #00557F; } +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } -a { color: #AA5500; } +a { color: #BA6D36; } </style> </head>
--- a/AssistantEric/Documentation/source/index-Plugin_Assistant_Eric.html Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Documentation/source/index-Plugin_Assistant_Eric.html Thu Aug 12 19:06:24 2010 +0200 @@ -5,17 +5,17 @@ <title>Plugin_Assistant_Eric</title> <style> body { - background:white; + background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } -h1 { color: white; background: #4FA4FF; } -h2 { color: white; background: #4FA4FF; } -h3 { color: white; background: #00557F; } -h4 { color: white; background: #00557F; } +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } -a { color: #AA5500; } +a { color: #BA6D36; } </style> </head>
--- a/AssistantEric/Documentation/source/index.html Sun Aug 01 13:08:23 2010 +0200 +++ b/AssistantEric/Documentation/source/index.html Thu Aug 12 19:06:24 2010 +0200 @@ -5,17 +5,17 @@ <title>Table of contents</title> <style> body { - background:white; + background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } -h1 { color: white; background: #4FA4FF; } -h2 { color: white; background: #4FA4FF; } -h3 { color: white; background: #00557F; } -h4 { color: white; background: #00557F; } +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } -a { color: #AA5500; } +a { color: #BA6D36; } </style> </head>
--- a/ChangeLog Sun Aug 01 13:08:23 2010 +0200 +++ b/ChangeLog Thu Aug 12 19:06:24 2010 +0200 @@ -1,5 +1,10 @@ ChangeLog --------- +Version 2.1.0: +- bug fixes +- added code to use the new style signal API depending upon the + eric5 version + Version 2.0.1: - bug fixes
--- a/PluginAssistantEric.py Sun Aug 01 13:08:23 2010 +0200 +++ b/PluginAssistantEric.py Thu Aug 12 19:06:24 2010 +0200 @@ -23,7 +23,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "2.0.1" +version = "2.1.0" className = "AssistantEricPlugin" packageName = "AssistantEric" shortDescription = "Alternative autocompletion and calltips provider." @@ -101,6 +101,8 @@ self.__ui = ui self.__initialize() + self.__newStyle = ui.versionIsNewer("5.0.99", "20100811") + self.__defaults = { "AutoCompletionEnabled" : False, "AutoCompletionSource" : AcsAPIs | AcsProject, @@ -155,7 +157,7 @@ from AssistantEric.Assistant import Assistant - self.__object = Assistant(self, self.__ui) + self.__object = Assistant(self, self.__newStyle, self.__ui) e5App().registerPluginObject("AssistantEric", self.__object) self.__object.activate()