--- a/Preferences/ConfigurationPages/EditorAPIsPage.py Wed Nov 30 18:54:04 2016 +0100 +++ b/Preferences/ConfigurationPages/EditorAPIsPage.py Wed Nov 30 19:59:57 2016 +0100 @@ -23,6 +23,8 @@ import Utilities +# TODO: add combo box to select project type +# getEditorAPI und setEditorAPI class EditorAPIsPage(ConfigurationPageBase, Ui_EditorAPIsPage): """ Class implementing the Editor APIs configuration page. @@ -57,12 +59,37 @@ for lang in apiLanguages: if lang != "Guessed": self.apiLanguageComboBox.addItem(lang) - self.currentApiLanguage = '' - self.on_apiLanguageComboBox_activated(self.currentApiLanguage) + apiProjectTypes = sorted( + [("", "")] + [(trans, ptype) for ptype, trans in + e5App().getObject("Project").getProjectTypes().items()] + ) + for projectTypeStr, projectType in apiProjectTypes: + self.projectTypeComboBox.addItem(projectTypeStr, projectType) + self.__currentApiLanguage = "" + self.__currentApiProjectType = "" + self.on_apiLanguageComboBox_activated(self.__currentApiLanguage) +## self.on_projectTypeComboBox_activated(self.__currentApiProjectType) +## +## for lang in apiLanguages[1:]: +## self.apis[lang] = Preferences.getEditorAPI(lang)[:] + + def __apiKey(self, language, projectType): + """ + Private method to generate a key for the apis dictionary. - for lang in apiLanguages[1:]: - self.apis[lang] = Preferences.getEditorAPI(lang)[:] - + @param language programming language of the API + @type str + @param projectType project type of the API + @type str + @return key to be used + @rtype str + """ + if projectType: + key = (language, projectType) + else: + key = (language, "") + return key + def save(self): """ Public slot to save the Editor APIs configuration. @@ -72,10 +99,23 @@ self.apiAutoPrepareCheckBox.isChecked()) lang = self.apiLanguageComboBox.currentText() - self.apis[lang] = self.__editorGetApisFromApiList() + self.apis[self.__apiKey()] = self.__editorGetApisFromApiList() - for lang, apis in list(self.apis.items()): - Preferences.setEditorAPI(lang, apis) + for (language, projectType), apis in self.apis.items(): + Preferences.setEditorAPI(lang, projectType, apis) + + # TODO: carry on from here + @pyqtSlot(str) + def on_projectTypeComboBox_activated(self, p0): + """ + Slot documentation goes here. + + @param p0 DESCRIPTION + @type str + """ + return + # TODO: not implemented yet + raise NotImplementedError @pyqtSlot(str) def on_apiLanguageComboBox_activated(self, language): @@ -84,11 +124,11 @@ @param language selected API language (string) """ - if self.currentApiLanguage == language: + if self.__currentApiLanguage == language: return - self.apis[self.currentApiLanguage] = self.__editorGetApisFromApiList() - self.currentApiLanguage = language + self.apis[self.__currentApiLanguage] = self.__editorGetApisFromApiList() + self.__currentApiLanguage = language self.apiList.clear() if not language: @@ -100,13 +140,14 @@ self.addApiFileButton.setEnabled(False) self.apiFilePicker.clear() - for api in self.apis[self.currentApiLanguage]: + for api in self.apis[self.__currentApiLanguage]: if api: self.apiList.addItem(api) self.prepareApiButton.setEnabled(self.apiList.count() > 0) + # TODO: add project type from QScintilla.APIsManager import APIsManager - self.__currentAPI = APIsManager().getAPIs(self.currentApiLanguage) + self.__currentAPI = APIsManager().getAPIs(self.__currentApiLanguage) if self.__currentAPI is not None: self.__currentAPI.apiPreparationFinished.connect( self.__apiPreparationFinished) @@ -121,7 +162,7 @@ self.addPluginApiFileButton.setEnabled( len(self.pluginManager.getPluginApiFiles( - self.currentApiLanguage)) > 0) + self.__currentApiLanguage)) > 0) def __editorGetApisFromApiList(self): """ @@ -195,7 +236,7 @@ by plugins for the selected lexer language. """ pluginAPIFiles = self.pluginManager.getPluginApiFiles( - self.currentApiLanguage) + self.__currentApiLanguage) pluginAPIFilesDict = {} for apiFile in pluginAPIFiles: pluginAPIFilesDict[QFileInfo(apiFile).fileName()] = apiFile