Project/ProjectInterfacesBrowser.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2791
a9577f248f04
parent 2995
63d874899b8b
child 3058
0a02c433f52d
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
2 2
3 # Copyright (c) 2002 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2002 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the a class used to display the interfaces (IDL) part of the project. 7 Module implementing the a class used to display the interfaces (IDL) part
8 of the project.
8 """ 9 """
9 10
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 11 from __future__ import unicode_literals # __IGNORE_WARNING__
11 try: 12 try:
12 str = unicode 13 str = unicode
25 from .ProjectBrowserModel import ProjectBrowserFileItem, \ 26 from .ProjectBrowserModel import ProjectBrowserFileItem, \
26 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, \ 27 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, \
27 ProjectBrowserInterfaceType 28 ProjectBrowserInterfaceType
28 from .ProjectBaseBrowser import ProjectBaseBrowser 29 from .ProjectBaseBrowser import ProjectBaseBrowser
29 30
30 from UI.BrowserModel import BrowserFileItem, BrowserClassItem, BrowserMethodItem, \ 31 from UI.BrowserModel import BrowserFileItem, BrowserClassItem, \
31 BrowserClassAttributeItem 32 BrowserMethodItem, BrowserClassAttributeItem
32 import UI.PixmapCache 33 import UI.PixmapCache
33 34
34 import Preferences 35 import Preferences
35 import Utilities 36 import Utilities
36 37
38 class ProjectInterfacesBrowser(ProjectBaseBrowser): 39 class ProjectInterfacesBrowser(ProjectBaseBrowser):
39 """ 40 """
40 A class used to display the interfaces (IDL) part of the project. 41 A class used to display the interfaces (IDL) part of the project.
41 42
42 @signal sourceFile(str, int = 0) emitted to open a file 43 @signal sourceFile(str, int = 0) emitted to open a file
43 @signal closeSourceWindow(str) emitted after a file has been removed/deleted 44 @signal closeSourceWindow(str) emitted after a file has been
44 from the project 45 removed/deleted from the project
45 @signal appendStdout(str) emitted after something was received from 46 @signal appendStdout(str) emitted after something was received from
46 a QProcess on stdout 47 a QProcess on stdout
47 @signal appendStderr(str) emitted after something was received from 48 @signal appendStderr(str) emitted after something was received from
48 a QProcess on stderr 49 a QProcess on stderr
49 @signal showMenu(str, QMenu) emitted when a menu is about to be shown. The name 50 @signal showMenu(str, QMenu) emitted when a menu is about to be shown.
50 of the menu and a reference to the menu are given. 51 The name of the menu and a reference to the menu are given.
51 """ 52 """
52 appendStdout = pyqtSignal(str) 53 appendStdout = pyqtSignal(str)
53 appendStderr = pyqtSignal(str) 54 appendStderr = pyqtSignal(str)
54 showMenu = pyqtSignal(str, QMenu) 55 showMenu = pyqtSignal(str, QMenu)
55 56
60 @param project reference to the project object 61 @param project reference to the project object
61 @param parent parent widget of this browser (QWidget) 62 @param parent parent widget of this browser (QWidget)
62 """ 63 """
63 self.omniidl = Preferences.getCorba("omniidl") 64 self.omniidl = Preferences.getCorba("omniidl")
64 if self.omniidl == "": 65 if self.omniidl == "":
65 self.omniidl = Utilities.isWindowsPlatform() and "omniidl.exe" or "omniidl" 66 self.omniidl = Utilities.isWindowsPlatform() and \
67 "omniidl.exe" or "omniidl"
66 if not Utilities.isinpath(self.omniidl): 68 if not Utilities.isinpath(self.omniidl):
67 self.omniidl = None 69 self.omniidl = None
68 70
69 ProjectBaseBrowser.__init__(self, project, ProjectBrowserInterfaceType, parent) 71 ProjectBaseBrowser.__init__(self, project,
72 ProjectBrowserInterfaceType, parent)
70 73
71 self.selectedItemsFilter = \ 74 self.selectedItemsFilter = \
72 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem] 75 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]
73 76
74 self.setWindowTitle(self.trUtf8('Interfaces (IDL)')) 77 self.setWindowTitle(self.trUtf8('Interfaces (IDL)'))
75 78
76 self.setWhatsThis(self.trUtf8( 79 self.setWhatsThis(self.trUtf8(
77 """<b>Project Interfaces Browser</b>""" 80 """<b>Project Interfaces Browser</b>"""
78 """<p>This allows to easily see all interfaces (CORBA IDL files)""" 81 """<p>This allows to easily see all interfaces (CORBA IDL files)"""
79 """ contained in the current project. Several actions can be executed""" 82 """ contained in the current project. Several actions can be"""
80 """ via the context menu.</p>""" 83 """ executed via the context menu.</p>"""
81 )) 84 ))
82 85
83 project.prepareRepopulateItem.connect(self._prepareRepopulateItem) 86 project.prepareRepopulateItem.connect(self._prepareRepopulateItem)
84 project.completeRepopulateItem.connect(self._completeRepopulateItem) 87 project.completeRepopulateItem.connect(self._completeRepopulateItem)
85 88
98 self.__compileInterface) 101 self.__compileInterface)
99 self.sourceMenu.addAction(self.trUtf8('Compile all interfaces'), 102 self.sourceMenu.addAction(self.trUtf8('Compile all interfaces'),
100 self.__compileAllInterfaces) 103 self.__compileAllInterfaces)
101 self.sourceMenu.addAction(self.trUtf8('Open'), self._openItem) 104 self.sourceMenu.addAction(self.trUtf8('Open'), self._openItem)
102 self.sourceMenu.addSeparator() 105 self.sourceMenu.addSeparator()
103 act = self.sourceMenu.addAction(self.trUtf8('Rename file'), self._renameFile) 106 act = self.sourceMenu.addAction(
107 self.trUtf8('Rename file'), self._renameFile)
104 self.menuActions.append(act) 108 self.menuActions.append(act)
105 act = self.sourceMenu.addAction(self.trUtf8('Remove from project'), 109 act = self.sourceMenu.addAction(self.trUtf8('Remove from project'),
106 self._removeFile) 110 self._removeFile)
107 self.menuActions.append(act) 111 self.menuActions.append(act)
108 act = self.sourceMenu.addAction(self.trUtf8('Delete'), self.__deleteFile) 112 act = self.sourceMenu.addAction(
113 self.trUtf8('Delete'), self.__deleteFile)
109 self.menuActions.append(act) 114 self.menuActions.append(act)
110 self.sourceMenu.addSeparator() 115 self.sourceMenu.addSeparator()
111 self.sourceMenu.addAction(self.trUtf8('Add interfaces...'), 116 self.sourceMenu.addAction(self.trUtf8('Add interfaces...'),
112 self.__addInterfaceFiles) 117 self.__addInterfaceFiles)
113 self.sourceMenu.addAction(self.trUtf8('Add interfaces directory...'), 118 self.sourceMenu.addAction(self.trUtf8('Add interfaces directory...'),
120 self._expandAllDirs) 125 self._expandAllDirs)
121 self.sourceMenu.addAction(self.trUtf8('Collapse all directories'), 126 self.sourceMenu.addAction(self.trUtf8('Collapse all directories'),
122 self._collapseAllDirs) 127 self._collapseAllDirs)
123 self.sourceMenu.addSeparator() 128 self.sourceMenu.addSeparator()
124 self.sourceMenu.addAction(self.trUtf8('Configure...'), self._configure) 129 self.sourceMenu.addAction(self.trUtf8('Configure...'), self._configure)
125 self.sourceMenu.addAction(self.trUtf8('Configure CORBA...'), self.__configureCorba) 130 self.sourceMenu.addAction(
131 self.trUtf8('Configure CORBA...'), self.__configureCorba)
126 132
127 self.menu = QMenu(self) 133 self.menu = QMenu(self)
128 if self.omniidl is not None: 134 if self.omniidl is not None:
129 self.menu.addAction(self.trUtf8('Compile interface'), self.__compileInterface) 135 self.menu.addAction(
136 self.trUtf8('Compile interface'), self.__compileInterface)
130 self.menu.addAction(self.trUtf8('Compile all interfaces'), 137 self.menu.addAction(self.trUtf8('Compile all interfaces'),
131 self.__compileAllInterfaces) 138 self.__compileAllInterfaces)
132 self.menu.addAction(self.trUtf8('Open'), self._openItem) 139 self.menu.addAction(self.trUtf8('Open'), self._openItem)
133 self.menu.addSeparator() 140 self.menu.addSeparator()
134 self.menu.addAction(self.trUtf8('Add interfaces...'), self.__addInterfaceFiles) 141 self.menu.addAction(
142 self.trUtf8('Add interfaces...'), self.__addInterfaceFiles)
135 self.menu.addAction(self.trUtf8('Add interfaces directory...'), 143 self.menu.addAction(self.trUtf8('Add interfaces directory...'),
136 self.__addInterfacesDirectory) 144 self.__addInterfacesDirectory)
137 self.menu.addSeparator() 145 self.menu.addSeparator()
138 self.menu.addAction(self.trUtf8('Expand all directories'), 146 self.menu.addAction(self.trUtf8('Expand all directories'),
139 self._expandAllDirs) 147 self._expandAllDirs)
140 self.menu.addAction(self.trUtf8('Collapse all directories'), 148 self.menu.addAction(self.trUtf8('Collapse all directories'),
141 self._collapseAllDirs) 149 self._collapseAllDirs)
142 self.menu.addSeparator() 150 self.menu.addSeparator()
143 self.menu.addAction(self.trUtf8('Configure...'), self._configure) 151 self.menu.addAction(self.trUtf8('Configure...'), self._configure)
144 self.menu.addAction(self.trUtf8('Configure CORBA...'), self.__configureCorba) 152 self.menu.addAction(
153 self.trUtf8('Configure CORBA...'), self.__configureCorba)
145 154
146 self.backMenu = QMenu(self) 155 self.backMenu = QMenu(self)
147 if self.omniidl is not None: 156 if self.omniidl is not None:
148 self.backMenu.addAction(self.trUtf8('Compile all interfaces'), 157 self.backMenu.addAction(self.trUtf8('Compile all interfaces'),
149 self.__compileAllInterfaces) 158 self.__compileAllInterfaces)
157 self._expandAllDirs) 166 self._expandAllDirs)
158 self.backMenu.addAction(self.trUtf8('Collapse all directories'), 167 self.backMenu.addAction(self.trUtf8('Collapse all directories'),
159 self._collapseAllDirs) 168 self._collapseAllDirs)
160 self.backMenu.addSeparator() 169 self.backMenu.addSeparator()
161 self.backMenu.addAction(self.trUtf8('Configure...'), self._configure) 170 self.backMenu.addAction(self.trUtf8('Configure...'), self._configure)
162 self.backMenu.addAction(self.trUtf8('Configure CORBA...'), self.__configureCorba) 171 self.backMenu.addAction(
172 self.trUtf8('Configure CORBA...'), self.__configureCorba)
163 self.backMenu.setEnabled(False) 173 self.backMenu.setEnabled(False)
164 174
165 # create the menu for multiple selected files 175 # create the menu for multiple selected files
166 self.multiMenu = QMenu(self) 176 self.multiMenu = QMenu(self)
167 if self.omniidl is not None: 177 if self.omniidl is not None:
170 self.multiMenu.addAction(self.trUtf8('Open'), self._openItem) 180 self.multiMenu.addAction(self.trUtf8('Open'), self._openItem)
171 self.multiMenu.addSeparator() 181 self.multiMenu.addSeparator()
172 act = self.multiMenu.addAction(self.trUtf8('Remove from project'), 182 act = self.multiMenu.addAction(self.trUtf8('Remove from project'),
173 self._removeFile) 183 self._removeFile)
174 self.multiMenuActions.append(act) 184 self.multiMenuActions.append(act)
175 act = self.multiMenu.addAction(self.trUtf8('Delete'), self.__deleteFile) 185 act = self.multiMenu.addAction(
186 self.trUtf8('Delete'), self.__deleteFile)
176 self.multiMenuActions.append(act) 187 self.multiMenuActions.append(act)
177 self.multiMenu.addSeparator() 188 self.multiMenu.addSeparator()
178 self.multiMenu.addAction(self.trUtf8('Expand all directories'), 189 self.multiMenu.addAction(self.trUtf8('Expand all directories'),
179 self._expandAllDirs) 190 self._expandAllDirs)
180 self.multiMenu.addAction(self.trUtf8('Collapse all directories'), 191 self.multiMenu.addAction(self.trUtf8('Collapse all directories'),
181 self._collapseAllDirs) 192 self._collapseAllDirs)
182 self.multiMenu.addSeparator() 193 self.multiMenu.addSeparator()
183 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure) 194 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure)
184 self.multiMenu.addAction(self.trUtf8('Configure CORBA...'), self.__configureCorba) 195 self.multiMenu.addAction(
196 self.trUtf8('Configure CORBA...'), self.__configureCorba)
185 197
186 self.dirMenu = QMenu(self) 198 self.dirMenu = QMenu(self)
187 if self.omniidl is not None: 199 if self.omniidl is not None:
188 self.dirMenu.addAction(self.trUtf8('Compile all interfaces'), 200 self.dirMenu.addAction(self.trUtf8('Compile all interfaces'),
189 self.__compileAllInterfaces) 201 self.__compileAllInterfaces)
190 self.dirMenu.addSeparator() 202 self.dirMenu.addSeparator()
191 act = self.dirMenu.addAction(self.trUtf8('Remove from project'), self._removeFile) 203 act = self.dirMenu.addAction(
204 self.trUtf8('Remove from project'), self._removeFile)
192 self.dirMenuActions.append(act) 205 self.dirMenuActions.append(act)
193 act = self.dirMenu.addAction(self.trUtf8('Delete'), self._deleteDirectory) 206 act = self.dirMenu.addAction(
207 self.trUtf8('Delete'), self._deleteDirectory)
194 self.dirMenuActions.append(act) 208 self.dirMenuActions.append(act)
195 self.dirMenu.addSeparator() 209 self.dirMenu.addSeparator()
196 self.dirMenu.addAction(self.trUtf8('Add interfaces...'), self.__addInterfaceFiles) 210 self.dirMenu.addAction(
211 self.trUtf8('Add interfaces...'), self.__addInterfaceFiles)
197 self.dirMenu.addAction(self.trUtf8('Add interfaces directory...'), 212 self.dirMenu.addAction(self.trUtf8('Add interfaces directory...'),
198 self.__addInterfacesDirectory) 213 self.__addInterfacesDirectory)
199 self.dirMenu.addSeparator() 214 self.dirMenu.addSeparator()
200 self.dirMenu.addAction(self.trUtf8('Copy Path to Clipboard'), 215 self.dirMenu.addAction(self.trUtf8('Copy Path to Clipboard'),
201 self._copyToClipboard) 216 self._copyToClipboard)
204 self._expandAllDirs) 219 self._expandAllDirs)
205 self.dirMenu.addAction(self.trUtf8('Collapse all directories'), 220 self.dirMenu.addAction(self.trUtf8('Collapse all directories'),
206 self._collapseAllDirs) 221 self._collapseAllDirs)
207 self.dirMenu.addSeparator() 222 self.dirMenu.addSeparator()
208 self.dirMenu.addAction(self.trUtf8('Configure...'), self._configure) 223 self.dirMenu.addAction(self.trUtf8('Configure...'), self._configure)
209 self.dirMenu.addAction(self.trUtf8('Configure CORBA...'), self.__configureCorba) 224 self.dirMenu.addAction(
225 self.trUtf8('Configure CORBA...'), self.__configureCorba)
210 226
211 self.dirMultiMenu = QMenu(self) 227 self.dirMultiMenu = QMenu(self)
212 if self.omniidl is not None: 228 if self.omniidl is not None:
213 self.dirMultiMenu.addAction(self.trUtf8('Compile all interfaces'), 229 self.dirMultiMenu.addAction(self.trUtf8('Compile all interfaces'),
214 self.__compileAllInterfaces) 230 self.__compileAllInterfaces)
221 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'), 237 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'),
222 self._expandAllDirs) 238 self._expandAllDirs)
223 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'), 239 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'),
224 self._collapseAllDirs) 240 self._collapseAllDirs)
225 self.dirMultiMenu.addSeparator() 241 self.dirMultiMenu.addSeparator()
226 self.dirMultiMenu.addAction(self.trUtf8('Configure...'), self._configure) 242 self.dirMultiMenu.addAction(
243 self.trUtf8('Configure...'), self._configure)
227 self.dirMultiMenu.addAction(self.trUtf8('Configure CORBA...'), 244 self.dirMultiMenu.addAction(self.trUtf8('Configure CORBA...'),
228 self.__configureCorba) 245 self.__configureCorba)
229 246
230 self.sourceMenu.aboutToShow.connect(self.__showContextMenu) 247 self.sourceMenu.aboutToShow.connect(self.__showContextMenu)
231 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti) 248 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti)
391 fn2 = itm.fileName() 408 fn2 = itm.fileName()
392 fullNames.append(fn2) 409 fullNames.append(fn2)
393 fn = self.project.getRelativePath(fn2) 410 fn = self.project.getRelativePath(fn2)
394 files.append(fn) 411 files.append(fn)
395 412
396 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog 413 from UI.DeleteFilesConfirmationDialog import \
414 DeleteFilesConfirmationDialog
397 dlg = DeleteFilesConfirmationDialog(self.parent(), 415 dlg = DeleteFilesConfirmationDialog(self.parent(),
398 self.trUtf8("Delete interfaces"), 416 self.trUtf8("Delete interfaces"),
399 self.trUtf8("Do you really want to delete these interfaces from" 417 self.trUtf8("Do you really want to delete these interfaces from"
400 " the project?"), 418 " the project?"),
401 files) 419 files)
403 if dlg.exec_() == QDialog.Accepted: 421 if dlg.exec_() == QDialog.Accepted:
404 for fn2, fn in zip(fullNames, files): 422 for fn2, fn in zip(fullNames, files):
405 self.closeSourceWindow.emit(fn2) 423 self.closeSourceWindow.emit(fn2)
406 self.project.deleteFile(fn) 424 self.project.deleteFile(fn)
407 425
408 ############################################################################ 426 ###########################################################################
409 ## Methods to handle the various compile commands 427 ## Methods to handle the various compile commands
410 ############################################################################ 428 ###########################################################################
411 429
412 def __readStdout(self): 430 def __readStdout(self):
413 """ 431 """
414 Private slot to handle the readyReadStandardOutput signal of the omniidl process. 432 Private slot to handle the readyReadStandardOutput signal of the
433 omniidl process.
415 """ 434 """
416 if self.compileProc is None: 435 if self.compileProc is None:
417 return 436 return
418 437
419 ioEncoding = Preferences.getSystem("IOEncoding") 438 ioEncoding = Preferences.getSystem("IOEncoding")
425 s += output 444 s += output
426 self.appendStdout.emit(s) 445 self.appendStdout.emit(s)
427 446
428 def __readStderr(self): 447 def __readStderr(self):
429 """ 448 """
430 Private slot to handle the readyReadStandardError signal of the omniidl process. 449 Private slot to handle the readyReadStandardError signal of the
450 omniidl process.
431 """ 451 """
432 if self.compileProc is None: 452 if self.compileProc is None:
433 return 453 return
434 454
435 ioEncoding = Preferences.getSystem("IOEncoding") 455 ioEncoding = Preferences.getSystem("IOEncoding")
460 for file in fileList: 480 for file in fileList:
461 self.project.appendFile(file) 481 self.project.appendFile(file)
462 if not self.noDialog and not ui.notificationsEnabled(): 482 if not self.noDialog and not ui.notificationsEnabled():
463 E5MessageBox.information(self, 483 E5MessageBox.information(self,
464 self.trUtf8("Interface Compilation"), 484 self.trUtf8("Interface Compilation"),
465 self.trUtf8("The compilation of the interface file was successful.")) 485 self.trUtf8(
486 "The compilation of the interface file was"
487 " successful."))
466 else: 488 else:
467 ui.showNotification(UI.PixmapCache.getPixmap("corba48.png"), 489 ui.showNotification(UI.PixmapCache.getPixmap("corba48.png"),
468 self.trUtf8("Interface Compilation"), 490 self.trUtf8("Interface Compilation"),
469 self.trUtf8("The compilation of the interface file was successful.")) 491 self.trUtf8(
492 "The compilation of the interface file was"
493 " successful."))
470 else: 494 else:
471 if not self.noDialog: 495 if not self.noDialog:
472 E5MessageBox.information(self, 496 E5MessageBox.information(self,
473 self.trUtf8("Interface Compilation"), 497 self.trUtf8("Interface Compilation"),
474 self.trUtf8("The compilation of the interface file failed.")) 498 self.trUtf8(
499 "The compilation of the interface file failed."))
475 else: 500 else:
476 ui.showNotification(UI.PixmapCache.getPixmap("corba48.png"), 501 ui.showNotification(UI.PixmapCache.getPixmap("corba48.png"),
477 self.trUtf8("Interface Compilation"), 502 self.trUtf8("Interface Compilation"),
478 self.trUtf8("The compilation of the interface file failed.")) 503 self.trUtf8(
504 "The compilation of the interface file failed."))
479 self.compileProc = None 505 self.compileProc = None
480 506
481 def __compileIDL(self, fn, noDialog=False, progress=None): 507 def __compileIDL(self, fn, noDialog=False, progress=None):
482 """ 508 """
483 Privat method to compile a .idl file to python. 509 Privat method to compile a .idl file to python.

eric ide

mercurial