Preferences/ConfigurationPages/EditorAPIsPage.py

branch
Py2 comp.
changeset 3142
55030c09e142
parent 3060
5883ce99ee12
parent 3098
02ee75d31584
child 3145
a9de05d4a22f
equal deleted inserted replaced
3141:72f3bde98c58 3142:55030c09e142
90 if not language: 90 if not language:
91 self.apiGroup.setEnabled(False) 91 self.apiGroup.setEnabled(False)
92 return 92 return
93 93
94 self.apiGroup.setEnabled(True) 94 self.apiGroup.setEnabled(True)
95 self.deleteApiFileButton.setEnabled(False)
96 self.addApiFileButton.setEnabled(False)
97 self.apiFileEdit.clear()
98
95 for api in self.apis[self.currentApiLanguage]: 99 for api in self.apis[self.currentApiLanguage]:
96 if api: 100 if api:
97 self.apiList.addItem(api) 101 self.apiList.addItem(api)
102 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
98 103
99 from QScintilla.APIsManager import APIsManager 104 from QScintilla.APIsManager import APIsManager
100 self.__currentAPI = APIsManager().getAPIs(self.currentApiLanguage) 105 self.__currentAPI = APIsManager().getAPIs(self.currentApiLanguage)
101 if self.__currentAPI is not None: 106 if self.__currentAPI is not None:
102 self.__currentAPI.apiPreparationFinished.connect( 107 self.__currentAPI.apiPreparationFinished.connect(
104 self.__currentAPI.apiPreparationCancelled.connect( 109 self.__currentAPI.apiPreparationCancelled.connect(
105 self.__apiPreparationCancelled) 110 self.__apiPreparationCancelled)
106 self.__currentAPI.apiPreparationStarted.connect( 111 self.__currentAPI.apiPreparationStarted.connect(
107 self.__apiPreparationStarted) 112 self.__apiPreparationStarted)
108 self.addInstalledApiFileButton.setEnabled( 113 self.addInstalledApiFileButton.setEnabled(
109 self.__currentAPI.installedAPIFiles() != "") 114 len(self.__currentAPI.installedAPIFiles()) > 0)
110 else: 115 else:
111 self.addInstalledApiFileButton.setEnabled(False) 116 self.addInstalledApiFileButton.setEnabled(False)
112 117
113 self.addPluginApiFileButton.setEnabled( 118 self.addPluginApiFileButton.setEnabled(
114 len(self.pluginManager.getPluginApiFiles(self.currentApiLanguage)) 119 len(self.pluginManager.getPluginApiFiles(self.currentApiLanguage))
146 """ 151 """
147 file = self.apiFileEdit.text() 152 file = self.apiFileEdit.text()
148 if file: 153 if file:
149 self.apiList.addItem(Utilities.toNativeSeparators(file)) 154 self.apiList.addItem(Utilities.toNativeSeparators(file))
150 self.apiFileEdit.clear() 155 self.apiFileEdit.clear()
156 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
151 157
152 @pyqtSlot() 158 @pyqtSlot()
153 def on_deleteApiFileButton_clicked(self): 159 def on_deleteApiFileButton_clicked(self):
154 """ 160 """
155 Private slot to delete the currently selected file of the listbox. 161 Private slot to delete the currently selected file of the listbox.
156 """ 162 """
157 crow = self.apiList.currentRow() 163 crow = self.apiList.currentRow()
158 if crow >= 0: 164 if crow >= 0:
159 itm = self.apiList.takeItem(crow) 165 itm = self.apiList.takeItem(crow)
160 del itm 166 del itm
167 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
161 168
162 @pyqtSlot() 169 @pyqtSlot()
163 def on_addInstalledApiFileButton_clicked(self): 170 def on_addInstalledApiFileButton_clicked(self):
164 """ 171 """
165 Private slot to add an API file from the list of installed API files 172 Private slot to add an API file from the list of installed API files
187 self, 194 self,
188 self.trUtf8("Add from installed APIs"), 195 self.trUtf8("Add from installed APIs"),
189 self.trUtf8("""There are no APIs installed yet.""" 196 self.trUtf8("""There are no APIs installed yet."""
190 """ Selection is not available.""")) 197 """ Selection is not available."""))
191 self.addInstalledApiFileButton.setEnabled(False) 198 self.addInstalledApiFileButton.setEnabled(False)
199 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
192 200
193 @pyqtSlot() 201 @pyqtSlot()
194 def on_addPluginApiFileButton_clicked(self): 202 def on_addPluginApiFileButton_clicked(self):
195 """ 203 """
196 Private slot to add an API file from the list of API files installed 204 Private slot to add an API file from the list of API files installed
209 sorted(pluginAPIFilesDict.keys()), 217 sorted(pluginAPIFilesDict.keys()),
210 0, False) 218 0, False)
211 if ok: 219 if ok:
212 self.apiList.addItem(Utilities.toNativeSeparators( 220 self.apiList.addItem(Utilities.toNativeSeparators(
213 pluginAPIFilesDict[file])) 221 pluginAPIFilesDict[file]))
222 self.prepareApiButton.setEnabled(self.apiList.count() > 0)
214 223
215 @pyqtSlot() 224 @pyqtSlot()
216 def on_prepareApiButton_clicked(self): 225 def on_prepareApiButton_clicked(self):
217 """ 226 """
218 Private slot to prepare the API file for the currently selected 227 Private slot to prepare the API file for the currently selected
267 """ 276 """
268 self.apiLanguageComboBox.setCurrentIndex(state) 277 self.apiLanguageComboBox.setCurrentIndex(state)
269 self.on_apiLanguageComboBox_activated( 278 self.on_apiLanguageComboBox_activated(
270 self.apiLanguageComboBox.currentText()) 279 self.apiLanguageComboBox.currentText())
271 280
281 @pyqtSlot()
282 def on_apiList_itemSelectionChanged(self):
283 """
284 Private slot to react on changes of API selections.
285 """
286 self.deleteApiFileButton.setEnabled(
287 len(self.apiList.selectedItems()) > 0)
288
289 @pyqtSlot(str)
290 def on_apiFileEdit_textChanged(self, txt):
291 """
292 Private slot to handle the entering of an API file name.
293
294 @param txt text of the line edit (string)
295 """
296 enable = txt != ""
297
298 if enable:
299 # check for already added file
300 for row in range(self.apiList.count()):
301 if txt == self.apiList.item(row).text():
302 enable = False
303 break
304
305 self.addApiFileButton.setEnabled(enable)
306
272 307
273 def create(dlg): 308 def create(dlg):
274 """ 309 """
275 Module function to create the configuration page. 310 Module function to create the configuration page.
276 311

eric ide

mercurial