41 |
41 |
42 self.apiFileCompleter = E5FileCompleter(self.apiFileEdit) |
42 self.apiFileCompleter = E5FileCompleter(self.apiFileEdit) |
43 |
43 |
44 # set initial values |
44 # set initial values |
45 self.pluginManager = e5App().getObject("PluginManager") |
45 self.pluginManager = e5App().getObject("PluginManager") |
46 self.apiAutoPrepareCheckBox.setChecked(\ |
46 self.apiAutoPrepareCheckBox.setChecked( |
47 Preferences.getEditor("AutoPrepareAPIs")) |
47 Preferences.getEditor("AutoPrepareAPIs")) |
48 |
48 |
49 self.apis = {} |
49 self.apis = {} |
50 apiLanguages = sorted([''] + \ |
50 apiLanguages = sorted([''] + \ |
51 list(QScintilla.Lexers.getSupportedLanguages().keys())) |
51 list(QScintilla.Lexers.getSupportedLanguages().keys())) |
99 self.__apiPreparationFinished) |
99 self.__apiPreparationFinished) |
100 self.__currentAPI.apiPreparationCancelled.connect( |
100 self.__currentAPI.apiPreparationCancelled.connect( |
101 self.__apiPreparationCancelled) |
101 self.__apiPreparationCancelled) |
102 self.__currentAPI.apiPreparationStarted.connect( |
102 self.__currentAPI.apiPreparationStarted.connect( |
103 self.__apiPreparationStarted) |
103 self.__apiPreparationStarted) |
104 self.addInstalledApiFileButton.setEnabled(\ |
104 self.addInstalledApiFileButton.setEnabled( |
105 self.__currentAPI.installedAPIFiles() != "") |
105 self.__currentAPI.installedAPIFiles() != "") |
106 else: |
106 else: |
107 self.addInstalledApiFileButton.setEnabled(False) |
107 self.addInstalledApiFileButton.setEnabled(False) |
108 |
108 |
109 self.addPluginApiFileButton.setEnabled( |
109 self.addPluginApiFileButton.setEnabled( |
123 @pyqtSlot() |
123 @pyqtSlot() |
124 def on_apiFileButton_clicked(self): |
124 def on_apiFileButton_clicked(self): |
125 """ |
125 """ |
126 Private method to select an api file. |
126 Private method to select an api file. |
127 """ |
127 """ |
128 file = QFileDialog.getOpenFileName(\ |
128 file = QFileDialog.getOpenFileName( |
129 self, |
129 self, |
130 self.trUtf8("Select API file"), |
130 self.trUtf8("Select API file"), |
131 self.apiFileEdit.text(), |
131 self.apiFileEdit.text(), |
132 self.trUtf8("API File (*.api);;All Files (*)")) |
132 self.trUtf8("API File (*.api);;All Files (*)")) |
133 |
133 |
163 installedAPIFiles = self.__currentAPI.installedAPIFiles() |
163 installedAPIFiles = self.__currentAPI.installedAPIFiles() |
164 installedAPIFilesPath = QFileInfo(installedAPIFiles[0]).path() |
164 installedAPIFilesPath = QFileInfo(installedAPIFiles[0]).path() |
165 installedAPIFilesShort = [] |
165 installedAPIFilesShort = [] |
166 for installedAPIFile in installedAPIFiles: |
166 for installedAPIFile in installedAPIFiles: |
167 installedAPIFilesShort.append(QFileInfo(installedAPIFile).fileName()) |
167 installedAPIFilesShort.append(QFileInfo(installedAPIFile).fileName()) |
168 file, ok = QInputDialog.getItem(\ |
168 file, ok = QInputDialog.getItem( |
169 self, |
169 self, |
170 self.trUtf8("Add from installed APIs"), |
170 self.trUtf8("Add from installed APIs"), |
171 self.trUtf8("Select from the list of installed API files"), |
171 self.trUtf8("Select from the list of installed API files"), |
172 installedAPIFilesShort, |
172 installedAPIFilesShort, |
173 0, False) |
173 0, False) |
174 if ok: |
174 if ok: |
175 self.apiList.addItem(Utilities.toNativeSeparators(\ |
175 self.apiList.addItem(Utilities.toNativeSeparators( |
176 QFileInfo(QDir(installedAPIFilesPath), file).absoluteFilePath())) |
176 QFileInfo(QDir(installedAPIFilesPath), file).absoluteFilePath())) |
177 |
177 |
178 @pyqtSlot() |
178 @pyqtSlot() |
179 def on_addPluginApiFileButton_clicked(self): |
179 def on_addPluginApiFileButton_clicked(self): |
180 """ |
180 """ |
183 """ |
183 """ |
184 pluginAPIFiles = self.pluginManager.getPluginApiFiles(self.currentApiLanguage) |
184 pluginAPIFiles = self.pluginManager.getPluginApiFiles(self.currentApiLanguage) |
185 pluginAPIFilesDict = {} |
185 pluginAPIFilesDict = {} |
186 for apiFile in pluginAPIFiles: |
186 for apiFile in pluginAPIFiles: |
187 pluginAPIFilesDict[QFileInfo(apiFile).fileName()] = apiFile |
187 pluginAPIFilesDict[QFileInfo(apiFile).fileName()] = apiFile |
188 file, ok = QInputDialog.getItem(\ |
188 file, ok = QInputDialog.getItem( |
189 self, |
189 self, |
190 self.trUtf8("Add from Plugin APIs"), |
190 self.trUtf8("Add from Plugin APIs"), |
191 self.trUtf8( |
191 self.trUtf8( |
192 "Select from the list of API files installed by plugins"), |
192 "Select from the list of API files installed by plugins"), |
193 sorted(pluginAPIFilesDict.keys()), |
193 sorted(pluginAPIFilesDict.keys()), |
194 0, False) |
194 0, False) |
195 if ok: |
195 if ok: |
196 self.apiList.addItem(Utilities.toNativeSeparators(\ |
196 self.apiList.addItem(Utilities.toNativeSeparators( |
197 pluginAPIFilesDict[file])) |
197 pluginAPIFilesDict[file])) |
198 |
198 |
199 @pyqtSlot() |
199 @pyqtSlot() |
200 def on_prepareApiButton_clicked(self): |
200 def on_prepareApiButton_clicked(self): |
201 """ |
201 """ |
203 """ |
203 """ |
204 if self.__inPreparation: |
204 if self.__inPreparation: |
205 self.__currentAPI and self.__currentAPI.cancelPreparation() |
205 self.__currentAPI and self.__currentAPI.cancelPreparation() |
206 else: |
206 else: |
207 if self.__currentAPI is not None: |
207 if self.__currentAPI is not None: |
208 self.__currentAPI.prepareAPIs(\ |
208 self.__currentAPI.prepareAPIs( |
209 ondemand = True, |
209 ondemand = True, |
210 rawList = self.__editorGetApisFromApiList()) |
210 rawList = self.__editorGetApisFromApiList()) |
211 |
211 |
212 def __apiPreparationFinished(self): |
212 def __apiPreparationFinished(self): |
213 """ |
213 """ |