Project/IdlCompilerOptionsDialog.py

branch
corba_options
changeset 6445
2b022e5ba54c
parent 6442
9d42b6c08a27
child 6466
dac80ad0de75
equal deleted inserted replaced
6444:7ce7a43aeeba 6445:2b022e5ba54c
14 14
15 import UI.PixmapCache 15 import UI.PixmapCache
16 16
17 from E5Gui import E5PathPickerDialog 17 from E5Gui import E5PathPickerDialog
18 from E5Gui.E5PathPicker import E5PathPickerModes 18 from E5Gui.E5PathPicker import E5PathPickerModes
19
20 from .IdlCompilerDefineNameDialog import IdlCompilerDefineNameDialog
19 21
20 22
21 class IdlCompilerOptionsDialog(QDialog, Ui_IdlCompilerOptionsDialog): 23 class IdlCompilerOptionsDialog(QDialog, Ui_IdlCompilerOptionsDialog):
22 """ 24 """
23 Class implementing a dialog to enter some IDL compiler options. 25 Class implementing a dialog to enter some IDL compiler options.
113 @param directory directory name to be tested 115 @param directory directory name to be tested
114 @type str 116 @type str
115 @return flag indicating that the given directory is already included 117 @return flag indicating that the given directory is already included
116 @rtype bool 118 @rtype bool
117 """ 119 """
118 for row in range(self.idList.count()): 120 return len(self.idList.findItems(directory, Qt.MatchExactly)) > 0
119 if self.idList.item(row).text() == directory:
120 return True
121
122 return False
123 121
124 @pyqtSlot() 122 @pyqtSlot()
125 def on_idList_itemSelectionChanged(self): 123 def on_idList_itemSelectionChanged(self):
126 """ 124 """
127 Private slot handling the selection of an 'Include Directory' entry. 125 Private slot handling the selection of an 'Include Directory' entry.
225 value = "" 223 value = ""
226 QTreeWidgetItem(self.dnList, [name, value]) 224 QTreeWidgetItem(self.dnList, [name, value])
227 225
228 self.dnList.sortItems(0, Qt.AscendingOrder) 226 self.dnList.sortItems(0, Qt.AscendingOrder)
229 227
228 def __generateDefinedNamesList(self):
229 """
230 Private method to prepare the list of 'Defined Names'.
231
232 @return list of 'Defined Names'
233 @rtype list of str
234 """
235 definedNames = []
236 for row in range(self.dnList.topLevelItemCount()):
237 itm = self.dnList.topLevelItem(row)
238 name = itm.text(0).strip()
239 value = itm.text(1).strip()
240 if value:
241 definedNames.append("{0}={1}".format(name, value))
242 else:
243 definedNames.append(name)
244
245 return definedNames
246
247 def __definedNamesContain(self, name):
248 """
249 Private method to test, if the currently defined 'Defined Names'
250 contain a given one.
251
252 @param name variable name to be tested
253 @type str
254 @return flag indicating that the given name is already included
255 @rtype bool
256 """
257 return len(self.dnList.findItems(name, Qt.MatchExactly, 0)) > 0
258
230 @pyqtSlot() 259 @pyqtSlot()
231 def on_dnList_itemSelectionChanged(self): 260 def on_dnList_itemSelectionChanged(self):
232 """ 261 """
233 Private slot handling the selection of a 'Define Name' entry. 262 Private slot handling the selection of a 'Define Name' entry.
234 """ 263 """
235 self.__updateDefineNameButtons() 264 self.__updateDefineNameButtons()
236 265
237 @pyqtSlot() 266 @pyqtSlot()
238 def on_dnAddButton_clicked(self): 267 def on_dnAddButton_clicked(self):
239 """ 268 """
240 Slot documentation goes here. 269 Private slot to add a 'Define Name' entry.
241 """ 270 """
242 # TODO: not implemented yet 271 dlg = IdlCompilerDefineNameDialog(parent=self)
243 raise NotImplementedError 272 if dlg.exec_() == QDialog.Accepted:
273 name, value = dlg.getData()
274 if not self.__definedNamesContain(name):
275 QTreeWidgetItem(self.dnList, [name, value])
276
277 self.dnList.sortItems(0, Qt.AscendingOrder)
244 278
245 @pyqtSlot() 279 @pyqtSlot()
246 def on_dnDeleteButton_clicked(self): 280 def on_dnDeleteButton_clicked(self):
247 """ 281 """
248 Slot documentation goes here. 282 Private slot to delete the selected 'Define Name' entry.
249 """ 283 """
250 # TODO: not implemented yet 284 itm = self.dnList.selectedItems()[0]
251 raise NotImplementedError 285 index = self.dnList.indexOfTopLevelItem(itm)
286 self.dnList.takeTopLevelItem(index)
287 del itm
252 288
253 @pyqtSlot() 289 @pyqtSlot()
254 def on_dnEditButton_clicked(self): 290 def on_dnEditButton_clicked(self):
255 """ 291 """
256 Slot documentation goes here. 292 Private slot to edit the selected 'Define Name' entry.
257 """ 293 """
258 # TODO: not implemented yet 294 itm = self.dnList.selectedItems()[0]
259 raise NotImplementedError 295
296 dlg = IdlCompilerDefineNameDialog(
297 name=itm.text(0), value=itm.text(1), parent=self)
298 if dlg.exec_() == QDialog.Accepted:
299 name, value = dlg.getData()
300 if self.__definedNamesContain(name) and itm.text(0) != name:
301 # the entry exists already, delete the edited one
302 index = self.dnList.indexOfTopLevelItem(itm)
303 self.dnList.takeTopLevelItem(index)
304 del itm
305
306 # change the named one
307 itm = self.dnList.findItems(name, Qt.MatchExactly, 0)[0]
308 itm.setText(1, value)
309 else:
310 itm.setText(0, name)
311 itm.setText(1, value)
312
313 self.dnList.sortItems(0, Qt.AscendingOrder)
260 314
261 ####################################################################### 315 #######################################################################
262 ## Methods implementing the 'Undefine Name' option 316 ## Methods implementing the 'Undefine Name' option
263 ####################################################################### 317 #######################################################################
264 318
290 @param name variable name to be tested 344 @param name variable name to be tested
291 @type str 345 @type str
292 @return flag indicating that the given name is already included 346 @return flag indicating that the given name is already included
293 @rtype bool 347 @rtype bool
294 """ 348 """
295 for row in range(self.unList.count()): 349 return len(self.unList.findItems(name, Qt.MatchExactly)) > 0
296 if self.unList.item(row).text() == name:
297 return True
298
299 return False
300 350
301 @pyqtSlot() 351 @pyqtSlot()
302 def on_unList_itemSelectionChanged(self): 352 def on_unList_itemSelectionChanged(self):
303 """ 353 """
304 Private slot handling the selection of a 'Undefine Name' entry. 354 Private slot handling the selection of a 'Undefine Name' entry.
363 defined names and list of undefined names 413 defined names and list of undefined names
364 @rtype tuple of (list of str, list of str, list of str) 414 @rtype tuple of (list of str, list of str, list of str)
365 """ 415 """
366 return ( 416 return (
367 self.__generateIncludeDirectoriesList(), 417 self.__generateIncludeDirectoriesList(),
368 [], 418 self.__generateDefinedNamesList(),
369 self.__generateUndefinedNamesList(), 419 self.__generateUndefinedNamesList(),
370 ) 420 )

eric ide

mercurial