eric6/Project/ProjectInterfacesBrowser.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7192
a22eee00b052
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the a class used to display the interfaces (IDL) part
8 of the project.
9 """
10
11 from __future__ import unicode_literals
12 try:
13 str = unicode
14 except NameError:
15 pass
16
17 import os
18 import glob
19
20 from PyQt5.QtCore import QThread, pyqtSignal, QProcess
21 from PyQt5.QtWidgets import QDialog, QApplication, QMenu
22
23 from E5Gui.E5Application import e5App
24 from E5Gui import E5MessageBox
25 from E5Gui.E5ProgressDialog import E5ProgressDialog
26
27 from .ProjectBrowserModel import ProjectBrowserFileItem, \
28 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, \
29 ProjectBrowserInterfaceType
30 from .ProjectBaseBrowser import ProjectBaseBrowser
31
32 from UI.BrowserModel import BrowserFileItem, BrowserClassItem, \
33 BrowserMethodItem, BrowserClassAttributeItem
34 import UI.PixmapCache
35
36 import Preferences
37 import Utilities
38
39
40 class ProjectInterfacesBrowser(ProjectBaseBrowser):
41 """
42 A class used to display the interfaces (IDL) part of the project.
43
44 @signal appendStdout(str) emitted after something was received from
45 a QProcess on stdout
46 @signal appendStderr(str) emitted after something was received from
47 a QProcess on stderr
48 @signal showMenu(str, QMenu) emitted when a menu is about to be shown.
49 The name of the menu and a reference to the menu are given.
50 """
51 appendStdout = pyqtSignal(str)
52 appendStderr = pyqtSignal(str)
53 showMenu = pyqtSignal(str, QMenu)
54
55 def __init__(self, project, parent=None):
56 """
57 Constructor
58
59 @param project reference to the project object
60 @param parent parent widget of this browser (QWidget)
61 """
62 self.omniidl = Preferences.getCorba("omniidl")
63 if self.omniidl == "":
64 self.omniidl = Utilities.isWindowsPlatform() and \
65 "omniidl.exe" or "omniidl"
66 if not Utilities.isinpath(self.omniidl):
67 self.omniidl = None
68
69 ProjectBaseBrowser.__init__(self, project,
70 ProjectBrowserInterfaceType, parent)
71
72 self.selectedItemsFilter = \
73 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]
74
75 self.setWindowTitle(self.tr('Interfaces (IDL)'))
76
77 self.setWhatsThis(self.tr(
78 """<b>Project Interfaces Browser</b>"""
79 """<p>This allows to easily see all interfaces (CORBA IDL files)"""
80 """ contained in the current project. Several actions can be"""
81 """ executed via the context menu.</p>"""
82 ))
83
84 project.prepareRepopulateItem.connect(self._prepareRepopulateItem)
85 project.completeRepopulateItem.connect(self._completeRepopulateItem)
86
87 def _createPopupMenus(self):
88 """
89 Protected overloaded method to generate the popup menu.
90 """
91 self.menuActions = []
92 self.multiMenuActions = []
93 self.dirMenuActions = []
94 self.dirMultiMenuActions = []
95
96 self.sourceMenu = QMenu(self)
97 if self.omniidl is not None:
98 self.sourceMenu.addAction(
99 self.tr('Compile interface'), self.__compileInterface)
100 self.sourceMenu.addAction(
101 self.tr('Compile all interfaces'),
102 self.__compileAllInterfaces)
103 self.sourceMenu.addSeparator()
104 self.sourceMenu.addAction(
105 self.tr('Configure IDL compiler'),
106 self.__configureIdlCompiler)
107 self.sourceMenu.addSeparator()
108 self.sourceMenu.addAction(self.tr('Open'), self._openItem)
109 self.sourceMenu.addSeparator()
110 act = self.sourceMenu.addAction(
111 self.tr('Rename file'), self._renameFile)
112 self.menuActions.append(act)
113 act = self.sourceMenu.addAction(
114 self.tr('Remove from project'), self._removeFile)
115 self.menuActions.append(act)
116 act = self.sourceMenu.addAction(
117 self.tr('Delete'), self.__deleteFile)
118 self.menuActions.append(act)
119 self.sourceMenu.addSeparator()
120 self.sourceMenu.addAction(
121 self.tr('Add interfaces...'), self.__addInterfaceFiles)
122 self.sourceMenu.addAction(
123 self.tr('Add interfaces directory...'),
124 self.__addInterfacesDirectory)
125 self.sourceMenu.addSeparator()
126 self.sourceMenu.addAction(
127 self.tr('Copy Path to Clipboard'), self._copyToClipboard)
128 self.sourceMenu.addSeparator()
129 self.sourceMenu.addAction(
130 self.tr('Expand all directories'), self._expandAllDirs)
131 self.sourceMenu.addAction(
132 self.tr('Collapse all directories'), self._collapseAllDirs)
133 self.sourceMenu.addSeparator()
134 self.sourceMenu.addAction(self.tr('Configure...'), self._configure)
135 self.sourceMenu.addAction(
136 self.tr('Configure CORBA...'), self.__configureCorba)
137
138 self.menu = QMenu(self)
139 if self.omniidl is not None:
140 self.menu.addAction(
141 self.tr('Compile interface'), self.__compileInterface)
142 self.menu.addAction(
143 self.tr('Compile all interfaces'),
144 self.__compileAllInterfaces)
145 self.menu.addSeparator()
146 self.menu.addAction(
147 self.tr('Configure IDL compiler'),
148 self.__configureIdlCompiler)
149 self.menu.addSeparator()
150 self.menu.addAction(self.tr('Open'), self._openItem)
151 self.menu.addSeparator()
152 self.menu.addAction(
153 self.tr('Add interfaces...'), self.__addInterfaceFiles)
154 self.menu.addAction(
155 self.tr('Add interfaces directory...'),
156 self.__addInterfacesDirectory)
157 self.menu.addSeparator()
158 self.menu.addAction(
159 self.tr('Expand all directories'), self._expandAllDirs)
160 self.menu.addAction(
161 self.tr('Collapse all directories'), self._collapseAllDirs)
162 self.menu.addSeparator()
163 self.menu.addAction(self.tr('Configure...'), self._configure)
164 self.menu.addAction(
165 self.tr('Configure CORBA...'), self.__configureCorba)
166
167 self.backMenu = QMenu(self)
168 if self.omniidl is not None:
169 self.backMenu.addAction(
170 self.tr('Compile all interfaces'),
171 self.__compileAllInterfaces)
172 self.backMenu.addSeparator()
173 self.backMenu.addAction(
174 self.tr('Configure IDL compiler'),
175 self.__configureIdlCompiler)
176 self.backMenu.addSeparator()
177 self.backMenu.addAction(
178 self.tr('Add interfaces...'), self.project.addIdlFiles)
179 self.backMenu.addAction(
180 self.tr('Add interfaces directory...'), self.project.addIdlDir)
181 self.backMenu.addSeparator()
182 self.backMenu.addAction(
183 self.tr('Expand all directories'), self._expandAllDirs)
184 self.backMenu.addAction(
185 self.tr('Collapse all directories'), self._collapseAllDirs)
186 self.backMenu.addSeparator()
187 self.backMenu.addAction(self.tr('Configure...'), self._configure)
188 self.backMenu.addAction(
189 self.tr('Configure CORBA...'), self.__configureCorba)
190 self.backMenu.setEnabled(False)
191
192 # create the menu for multiple selected files
193 self.multiMenu = QMenu(self)
194 if self.omniidl is not None:
195 self.multiMenu.addAction(
196 self.tr('Compile interfaces'),
197 self.__compileSelectedInterfaces)
198 self.multiMenu.addSeparator()
199 self.multiMenu.addAction(
200 self.tr('Configure IDL compiler'),
201 self.__configureIdlCompiler)
202 self.multiMenu.addSeparator()
203 self.multiMenu.addAction(self.tr('Open'), self._openItem)
204 self.multiMenu.addSeparator()
205 act = self.multiMenu.addAction(
206 self.tr('Remove from project'), self._removeFile)
207 self.multiMenuActions.append(act)
208 act = self.multiMenu.addAction(
209 self.tr('Delete'), self.__deleteFile)
210 self.multiMenuActions.append(act)
211 self.multiMenu.addSeparator()
212 self.multiMenu.addAction(
213 self.tr('Expand all directories'), self._expandAllDirs)
214 self.multiMenu.addAction(
215 self.tr('Collapse all directories'), self._collapseAllDirs)
216 self.multiMenu.addSeparator()
217 self.multiMenu.addAction(self.tr('Configure...'), self._configure)
218 self.multiMenu.addAction(
219 self.tr('Configure CORBA...'), self.__configureCorba)
220
221 self.dirMenu = QMenu(self)
222 if self.omniidl is not None:
223 self.dirMenu.addAction(
224 self.tr('Compile all interfaces'),
225 self.__compileAllInterfaces)
226 self.dirMenu.addSeparator()
227 self.dirMenu.addAction(
228 self.tr('Configure IDL compiler'),
229 self.__configureIdlCompiler)
230 self.dirMenu.addSeparator()
231 act = self.dirMenu.addAction(
232 self.tr('Remove from project'), self._removeFile)
233 self.dirMenuActions.append(act)
234 act = self.dirMenu.addAction(
235 self.tr('Delete'), self._deleteDirectory)
236 self.dirMenuActions.append(act)
237 self.dirMenu.addSeparator()
238 self.dirMenu.addAction(
239 self.tr('Add interfaces...'), self.__addInterfaceFiles)
240 self.dirMenu.addAction(
241 self.tr('Add interfaces directory...'),
242 self.__addInterfacesDirectory)
243 self.dirMenu.addSeparator()
244 self.dirMenu.addAction(
245 self.tr('Copy Path to Clipboard'), self._copyToClipboard)
246 self.dirMenu.addSeparator()
247 self.dirMenu.addAction(
248 self.tr('Expand all directories'), self._expandAllDirs)
249 self.dirMenu.addAction(
250 self.tr('Collapse all directories'), self._collapseAllDirs)
251 self.dirMenu.addSeparator()
252 self.dirMenu.addAction(self.tr('Configure...'), self._configure)
253 self.dirMenu.addAction(
254 self.tr('Configure CORBA...'), self.__configureCorba)
255
256 self.dirMultiMenu = QMenu(self)
257 if self.omniidl is not None:
258 self.dirMultiMenu.addAction(
259 self.tr('Compile all interfaces'),
260 self.__compileAllInterfaces)
261 self.dirMultiMenu.addSeparator()
262 self.dirMultiMenu.addAction(
263 self.tr('Configure IDL compiler'),
264 self.__configureIdlCompiler)
265 self.dirMultiMenu.addSeparator()
266 self.dirMultiMenu.addAction(
267 self.tr('Add interfaces...'), self.project.addIdlFiles)
268 self.dirMultiMenu.addAction(
269 self.tr('Add interfaces directory...'), self.project.addIdlDir)
270 self.dirMultiMenu.addSeparator()
271 self.dirMultiMenu.addAction(
272 self.tr('Expand all directories'), self._expandAllDirs)
273 self.dirMultiMenu.addAction(
274 self.tr('Collapse all directories'), self._collapseAllDirs)
275 self.dirMultiMenu.addSeparator()
276 self.dirMultiMenu.addAction(
277 self.tr('Configure...'), self._configure)
278 self.dirMultiMenu.addAction(self.tr('Configure CORBA...'),
279 self.__configureCorba)
280
281 self.sourceMenu.aboutToShow.connect(self.__showContextMenu)
282 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti)
283 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir)
284 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti)
285 self.backMenu.aboutToShow.connect(self.__showContextMenuBack)
286 self.mainMenu = self.sourceMenu
287
288 def _contextMenuRequested(self, coord):
289 """
290 Protected slot to show the context menu.
291
292 @param coord the position of the mouse pointer (QPoint)
293 """
294 if not self.project.isOpen():
295 return
296
297 try:
298 categories = self.getSelectedItemsCountCategorized(
299 [ProjectBrowserFileItem, BrowserClassItem,
300 BrowserMethodItem, ProjectBrowserSimpleDirectoryItem])
301 cnt = categories["sum"]
302 if cnt <= 1:
303 index = self.indexAt(coord)
304 if index.isValid():
305 self._selectSingleItem(index)
306 categories = self.getSelectedItemsCountCategorized(
307 [ProjectBrowserFileItem, BrowserClassItem,
308 BrowserMethodItem, ProjectBrowserSimpleDirectoryItem])
309 cnt = categories["sum"]
310
311 bfcnt = categories[str(ProjectBrowserFileItem)]
312 cmcnt = categories[str(BrowserClassItem)] + \
313 categories[str(BrowserMethodItem)]
314 sdcnt = categories[str(ProjectBrowserSimpleDirectoryItem)]
315 if cnt > 1 and cnt == bfcnt:
316 self.multiMenu.popup(self.mapToGlobal(coord))
317 elif cnt > 1 and cnt == sdcnt:
318 self.dirMultiMenu.popup(self.mapToGlobal(coord))
319 else:
320 index = self.indexAt(coord)
321 if cnt == 1 and index.isValid():
322 if bfcnt == 1 or cmcnt == 1:
323 itm = self.model().item(index)
324 if isinstance(itm, ProjectBrowserFileItem):
325 self.sourceMenu.popup(self.mapToGlobal(coord))
326 elif isinstance(itm, BrowserClassItem) or \
327 isinstance(itm, BrowserMethodItem):
328 self.menu.popup(self.mapToGlobal(coord))
329 else:
330 self.backMenu.popup(self.mapToGlobal(coord))
331 elif sdcnt == 1:
332 self.dirMenu.popup(self.mapToGlobal(coord))
333 else:
334 self.backMenu.popup(self.mapToGlobal(coord))
335 else:
336 self.backMenu.popup(self.mapToGlobal(coord))
337 except Exception:
338 pass
339
340 def __showContextMenu(self):
341 """
342 Private slot called by the menu aboutToShow signal.
343 """
344 ProjectBaseBrowser._showContextMenu(self, self.menu)
345
346 self.showMenu.emit("Main", self.menu)
347
348 def __showContextMenuMulti(self):
349 """
350 Private slot called by the multiMenu aboutToShow signal.
351 """
352 ProjectBaseBrowser._showContextMenuMulti(self, self.multiMenu)
353
354 self.showMenu.emit("MainMulti", self.multiMenu)
355
356 def __showContextMenuDir(self):
357 """
358 Private slot called by the dirMenu aboutToShow signal.
359 """
360 ProjectBaseBrowser._showContextMenuDir(self, self.dirMenu)
361
362 self.showMenu.emit("MainDir", self.dirMenu)
363
364 def __showContextMenuDirMulti(self):
365 """
366 Private slot called by the dirMultiMenu aboutToShow signal.
367 """
368 ProjectBaseBrowser._showContextMenuDirMulti(self, self.dirMultiMenu)
369
370 self.showMenu.emit("MainDirMulti", self.dirMultiMenu)
371
372 def __showContextMenuBack(self):
373 """
374 Private slot called by the backMenu aboutToShow signal.
375 """
376 ProjectBaseBrowser._showContextMenuBack(self, self.backMenu)
377
378 self.showMenu.emit("MainBack", self.backMenu)
379
380 def _openItem(self):
381 """
382 Protected slot to handle the open popup menu entry.
383 """
384 itmList = self.getSelectedItems(
385 [BrowserFileItem, BrowserClassItem, BrowserMethodItem,
386 BrowserClassAttributeItem])
387
388 for itm in itmList:
389 if isinstance(itm, BrowserFileItem):
390 self.sourceFile[str].emit(itm.fileName())
391 elif isinstance(itm, BrowserClassItem):
392 self.sourceFile[str, int].emit(
393 itm.fileName(), itm.classObject().lineno)
394 elif isinstance(itm, BrowserMethodItem):
395 self.sourceFile[str, int].emit(
396 itm.fileName(), itm.functionObject().lineno)
397 elif isinstance(itm, BrowserClassAttributeItem):
398 self.sourceFile[str, int].emit(
399 itm.fileName(), itm.attributeObject().lineno)
400
401 def __addInterfaceFiles(self):
402 """
403 Private method to add interface files to the project.
404 """
405 itm = self.model().item(self.currentIndex())
406 if isinstance(itm, ProjectBrowserFileItem) or \
407 isinstance(itm, BrowserClassItem) or \
408 isinstance(itm, BrowserMethodItem):
409 dn = os.path.dirname(itm.fileName())
410 elif isinstance(itm, ProjectBrowserSimpleDirectoryItem) or \
411 isinstance(itm, ProjectBrowserDirectoryItem):
412 dn = itm.dirName()
413 else:
414 dn = None
415 self.project.addFiles('interface', dn)
416
417 def __addInterfacesDirectory(self):
418 """
419 Private method to add interface files of a directory to the project.
420 """
421 itm = self.model().item(self.currentIndex())
422 if isinstance(itm, ProjectBrowserFileItem) or \
423 isinstance(itm, BrowserClassItem) or \
424 isinstance(itm, BrowserMethodItem):
425 dn = os.path.dirname(itm.fileName())
426 elif isinstance(itm, ProjectBrowserSimpleDirectoryItem) or \
427 isinstance(itm, ProjectBrowserDirectoryItem):
428 dn = itm.dirName()
429 else:
430 dn = None
431 self.project.addDirectory('interface', dn)
432
433 def __deleteFile(self):
434 """
435 Private method to delete files from the project.
436 """
437 itmList = self.getSelectedItems()
438
439 files = []
440 fullNames = []
441 for itm in itmList:
442 fn2 = itm.fileName()
443 fullNames.append(fn2)
444 fn = self.project.getRelativePath(fn2)
445 files.append(fn)
446
447 from UI.DeleteFilesConfirmationDialog import \
448 DeleteFilesConfirmationDialog
449 dlg = DeleteFilesConfirmationDialog(
450 self.parent(),
451 self.tr("Delete interfaces"),
452 self.tr("Do you really want to delete these interfaces from"
453 " the project?"),
454 files)
455
456 if dlg.exec_() == QDialog.Accepted:
457 for fn2, fn in zip(fullNames, files):
458 self.closeSourceWindow.emit(fn2)
459 self.project.deleteFile(fn)
460
461 ###########################################################################
462 ## Methods to handle the various compile commands
463 ###########################################################################
464
465 def __readStdout(self):
466 """
467 Private slot to handle the readyReadStandardOutput signal of the
468 omniidl process.
469 """
470 if self.compileProc is None:
471 return
472
473 ioEncoding = Preferences.getSystem("IOEncoding")
474
475 self.compileProc.setReadChannel(QProcess.StandardOutput)
476 while self.compileProc and self.compileProc.canReadLine():
477 s = 'omniidl: '
478 output = str(self.compileProc.readLine(), ioEncoding, 'replace')
479 s += output
480 self.appendStdout.emit(s)
481
482 def __readStderr(self):
483 """
484 Private slot to handle the readyReadStandardError signal of the
485 omniidl process.
486 """
487 if self.compileProc is None:
488 return
489
490 ioEncoding = Preferences.getSystem("IOEncoding")
491
492 self.compileProc.setReadChannel(QProcess.StandardError)
493 while self.compileProc and self.compileProc.canReadLine():
494 s = 'omniidl: '
495 error = str(self.compileProc.readLine(), ioEncoding, 'replace')
496 s += error
497 self.appendStderr.emit(s)
498
499 def __compileIDLDone(self, exitCode, exitStatus):
500 """
501 Private slot to handle the finished signal of the omniidl process.
502
503 @param exitCode exit code of the process (integer)
504 @param exitStatus exit status of the process (QProcess.ExitStatus)
505 """
506 self.compileRunning = False
507 ui = e5App().getObject("UserInterface")
508 if exitStatus == QProcess.NormalExit and exitCode == 0:
509 path = os.path.dirname(self.idlFile)
510 poaList = glob.glob(os.path.join(path, "*__POA"))
511 npoaList = [f.replace("__POA", "") for f in poaList]
512 fileList = glob.glob(os.path.join(path, "*_idl.py"))
513 for directory in poaList + npoaList:
514 fileList += Utilities.direntries(directory, True, "*.py")
515 for file in fileList:
516 self.project.appendFile(file)
517 if not self.noDialog and not ui.notificationsEnabled():
518 E5MessageBox.information(
519 self,
520 self.tr("Interface Compilation"),
521 self.tr(
522 "The compilation of the interface file was"
523 " successful."))
524 else:
525 ui.showNotification(
526 UI.PixmapCache.getPixmap("corba48.png"),
527 self.tr("Interface Compilation"),
528 self.tr(
529 "The compilation of the interface file was"
530 " successful."))
531 else:
532 if not self.noDialog:
533 E5MessageBox.information(
534 self,
535 self.tr("Interface Compilation"),
536 self.tr(
537 "The compilation of the interface file failed."))
538 else:
539 ui.showNotification(
540 UI.PixmapCache.getPixmap("corba48.png"),
541 self.tr("Interface Compilation"),
542 self.tr(
543 "The compilation of the interface file failed."))
544 self.compileProc = None
545
546 def __compileIDL(self, fn, noDialog=False, progress=None):
547 """
548 Private method to compile a .idl file to python.
549
550 @param fn filename of the .idl file to be compiled (string)
551 @param noDialog flag indicating silent operations (boolean)
552 @param progress reference to the progress dialog (E5ProgressDialog)
553 @return reference to the compile process (QProcess)
554 """
555 params = self.project.pdata["IDLPARAMS"]
556
557 self.compileProc = QProcess()
558 args = []
559
560 args.append("-bpython")
561 args.append("-I.")
562 for directory in params["IncludeDirs"]:
563 args.append("-I{0}".format(
564 self.project.getAbsoluteUniversalPath(directory)))
565 for name in params["DefinedNames"]:
566 args.append("-D{0}".format(name))
567 for name in params["UndefinedNames"]:
568 args.append("-U{0}".format(name))
569
570 fn = self.project.getAbsoluteUniversalPath(fn)
571 self.idlFile = fn
572 args.append("-C{0}".format(os.path.dirname(fn)))
573 args.append(fn)
574
575 self.compileProc.finished.connect(self.__compileIDLDone)
576 self.compileProc.readyReadStandardOutput.connect(self.__readStdout)
577 self.compileProc.readyReadStandardError.connect(self.__readStderr)
578
579 self.noDialog = noDialog
580 self.compileProc.start(self.omniidl, args)
581 procStarted = self.compileProc.waitForStarted(5000)
582 if procStarted:
583 self.compileRunning = True
584 return self.compileProc
585 else:
586 self.compileRunning = False
587 if progress is not None:
588 progress.cancel()
589 E5MessageBox.critical(
590 self,
591 self.tr('Process Generation Error'),
592 self.tr(
593 '<p>Could not start {0}.<br>'
594 'Ensure that it is in the search path.</p>'
595 ).format(self.omniidl))
596 return None
597
598 def __compileInterface(self):
599 """
600 Private method to compile an interface to python.
601 """
602 if self.omniidl is not None:
603 itm = self.model().item(self.currentIndex())
604 fn2 = itm.fileName()
605 fn = self.project.getRelativePath(fn2)
606 self.__compileIDL(fn)
607
608 def __compileAllInterfaces(self):
609 """
610 Private method to compile all interfaces to python.
611 """
612 if self.omniidl is not None:
613 numIDLs = len(self.project.pdata["INTERFACES"])
614 progress = E5ProgressDialog(
615 self.tr("Compiling interfaces..."),
616 self.tr("Abort"), 0, numIDLs,
617 self.tr("%v/%m Interfaces"), self)
618 progress.setModal(True)
619 progress.setMinimumDuration(0)
620 progress.setWindowTitle(self.tr("Interfaces"))
621 i = 0
622
623 for fn in self.project.pdata["INTERFACES"]:
624 progress.setValue(i)
625 if progress.wasCanceled():
626 break
627 proc = self.__compileIDL(fn, True, progress)
628 if proc is not None:
629 while proc.state() == QProcess.Running:
630 QApplication.processEvents()
631 QThread.msleep(300)
632 QApplication.processEvents()
633 else:
634 break
635 i += 1
636
637 progress.setValue(numIDLs)
638
639 def __compileSelectedInterfaces(self):
640 """
641 Private method to compile selected interfaces to python.
642 """
643 if self.omniidl is not None:
644 items = self.getSelectedItems()
645
646 files = [self.project.getRelativePath(itm.fileName())
647 for itm in items]
648 numIDLs = len(files)
649 progress = E5ProgressDialog(
650 self.tr("Compiling interfaces..."),
651 self.tr("Abort"), 0, numIDLs,
652 self.tr("%v/%m Interfaces"), self)
653 progress.setModal(True)
654 progress.setMinimumDuration(0)
655 progress.setWindowTitle(self.tr("Interfaces"))
656 i = 0
657
658 for fn in files:
659 progress.setValue(i)
660 if progress.wasCanceled():
661 break
662 proc = self.__compileIDL(fn, True, progress)
663 if proc is not None:
664 while proc.state() == QProcess.Running:
665 QApplication.processEvents()
666 QThread.msleep(300)
667 QApplication.processEvents()
668 else:
669 break
670 i += 1
671
672 progress.setValue(numIDLs)
673
674 def __configureIdlCompiler(self):
675 """
676 Private method to show a dialog to configure some options for the
677 IDL compiler.
678 """
679 params = self.project.pdata["IDLPARAMS"]
680
681 from .IdlCompilerOptionsDialog import IdlCompilerOptionsDialog
682 dlg = IdlCompilerOptionsDialog(
683 params["IncludeDirs"][:], params["DefinedNames"][:],
684 params["UndefinedNames"][:], self.project, self)
685 if dlg.exec_() == QDialog.Accepted:
686 include, defined, undefined = dlg.getData()
687 if include != params["IncludeDirs"]:
688 params["IncludeDirs"] = include[:]
689 self.project.setDirty(True)
690 if defined != params["DefinedNames"]:
691 params["DefinedNames"] = defined[:]
692 self.project.setDirty(True)
693 if undefined != params["UndefinedNames"]:
694 params["UndefinedNames"] = undefined[:]
695 self.project.setDirty(True)
696
697 def __configureCorba(self):
698 """
699 Private method to open the configuration dialog.
700 """
701 e5App().getObject("UserInterface").showPreferences("corbaPage")

eric ide

mercurial