67 @signal pixmapFile(filename) emitted to open a pixmap file (str) |
67 @signal pixmapFile(filename) emitted to open a pixmap file (str) |
68 @signal pixmapEditFile(filename) emitted to edit a pixmap file (str) |
68 @signal pixmapEditFile(filename) emitted to edit a pixmap file (str) |
69 @signal svgFile(filename) emitted to open a SVG file (str) |
69 @signal svgFile(filename) emitted to open a SVG file (str) |
70 @signal umlFile(filename) emitted to open an eric UML file (str) |
70 @signal umlFile(filename) emitted to open an eric UML file (str) |
71 @signal binaryFile(filename) emitted to open a file as binary (str) |
71 @signal binaryFile(filename) emitted to open a file as binary (str) |
72 @signal unittestOpen(filename) emitted to open a Python file for a |
72 @signal testFile(filename) emitted to open a Python file for a |
73 unit test (str) |
73 unit test (str) |
74 """ |
74 """ |
75 sourceFile = pyqtSignal((str, ), (str, int), (str, list), (str, int, str)) |
75 sourceFile = pyqtSignal((str, ), (str, int), (str, list), (str, int, str)) |
76 designerFile = pyqtSignal(str) |
76 designerFile = pyqtSignal(str) |
77 linguistFile = pyqtSignal(str) |
77 linguistFile = pyqtSignal(str) |
81 pixmapFile = pyqtSignal(str) |
81 pixmapFile = pyqtSignal(str) |
82 pixmapEditFile = pyqtSignal(str) |
82 pixmapEditFile = pyqtSignal(str) |
83 svgFile = pyqtSignal(str) |
83 svgFile = pyqtSignal(str) |
84 umlFile = pyqtSignal(str) |
84 umlFile = pyqtSignal(str) |
85 binaryFile = pyqtSignal(str) |
85 binaryFile = pyqtSignal(str) |
86 unittestOpen = pyqtSignal(str) |
86 testFile = pyqtSignal(str) |
87 |
87 |
88 def __init__(self, parent=None): |
88 def __init__(self, parent=None): |
89 """ |
89 """ |
90 Constructor |
90 Constructor |
91 |
91 |
136 """ system.</p>""" |
136 """ system.</p>""" |
137 """<p>Python programs (i.e. those with a <tt>.py</tt> file name""" |
137 """<p>Python programs (i.e. those with a <tt>.py</tt> file name""" |
138 """ suffix) are identified in the hierarchies with a Python""" |
138 """ suffix) are identified in the hierarchies with a Python""" |
139 """ icon. The right mouse button will popup a menu which lets""" |
139 """ icon. The right mouse button will popup a menu which lets""" |
140 """ you open the file in a Source Viewer window, open the file""" |
140 """ you open the file in a Source Viewer window, open the file""" |
141 """ for debugging or use it for a unittest run.</p>""" |
141 """ for debugging or use it for a test run.</p>""" |
142 """<p>The context menu of a class, function or method allows you""" |
142 """<p>The context menu of a class, function or method allows you""" |
143 """ to open the file defining this class, function or method and""" |
143 """ to open the file defining this class, function or method and""" |
144 """ will ensure, that the correct source line is visible.</p>""" |
144 """ will ensure, that the correct source line is visible.</p>""" |
145 """<p>Qt-Designer files (i.e. those with a <tt>.ui</tt> file""" |
145 """<p>Qt-Designer files (i.e. those with a <tt>.ui</tt> file""" |
146 """ name suffix) are shown with a Designer icon. The context""" |
146 """ name suffix) are shown with a Designer icon. The context""" |
230 |
230 |
231 # create the popup menu for source files |
231 # create the popup menu for source files |
232 self.sourceMenu = QMenu(self) |
232 self.sourceMenu = QMenu(self) |
233 self.sourceMenu.addAction( |
233 self.sourceMenu.addAction( |
234 QCoreApplication.translate('Browser', 'Open'), self._openItem) |
234 QCoreApplication.translate('Browser', 'Open'), self._openItem) |
235 self.unittestAct = self.sourceMenu.addAction( |
235 self.testingAct = self.sourceMenu.addAction( |
236 QCoreApplication.translate('Browser', 'Run unittest...'), |
236 QCoreApplication.translate('Browser', 'Run Test...'), |
237 self.handleUnittest) |
237 self.handleTesting) |
238 self.sourceMenu.addSeparator() |
238 self.sourceMenu.addSeparator() |
239 self.mimeTypeAct = self.sourceMenu.addAction( |
239 self.mimeTypeAct = self.sourceMenu.addAction( |
240 QCoreApplication.translate('Browser', 'Show Mime-Type'), |
240 QCoreApplication.translate('Browser', 'Show Mime-Type'), |
241 self.__showMimeType) |
241 self.__showMimeType) |
242 self.sourceMenu.addSeparator() |
242 self.sourceMenu.addSeparator() |
397 itm = self.model().item(index) |
397 itm = self.model().item(index) |
398 coord = self.mapToGlobal(coord) |
398 coord = self.mapToGlobal(coord) |
399 if isinstance(itm, BrowserFileItem): |
399 if isinstance(itm, BrowserFileItem): |
400 if itm.isPython3File(): |
400 if itm.isPython3File(): |
401 if itm.fileName().endswith('.py'): |
401 if itm.fileName().endswith('.py'): |
402 self.unittestAct.setEnabled(True) |
402 self.testingAct.setEnabled(True) |
403 else: |
403 else: |
404 self.unittestAct.setEnabled(False) |
404 self.testingAct.setEnabled(False) |
405 self.sourceMenu.popup(coord) |
405 self.sourceMenu.popup(coord) |
406 else: |
406 else: |
407 self.editPixmapAct.setVisible(itm.isPixmapFile()) |
407 self.editPixmapAct.setVisible(itm.isPixmapFile()) |
408 self.openInEditorAct.setVisible(itm.isSvgFile()) |
408 self.openInEditorAct.setVisible(itm.isSvgFile()) |
409 self.menu.popup(coord) |
409 self.menu.popup(coord) |
638 """ |
638 """ |
639 self.__sortModel.setShowHiddenFiles(checked) |
639 self.__sortModel.setShowHiddenFiles(checked) |
640 # remember the current state |
640 # remember the current state |
641 Preferences.setUI("BrowsersListHiddenFiles", checked) |
641 Preferences.setUI("BrowsersListHiddenFiles", checked) |
642 |
642 |
643 def handleUnittest(self): |
643 def handleTesting(self): |
644 """ |
644 """ |
645 Public slot to handle the unittest popup menu entry. |
645 Public slot to handle the testing popup menu entry. |
646 """ |
646 """ |
647 try: |
647 try: |
648 index = self.currentIndex() |
648 index = self.currentIndex() |
649 itm = self.model().item(index) |
649 itm = self.model().item(index) |
650 pyfn = itm.fileName() |
650 pyfn = itm.fileName() |
651 except AttributeError: |
651 except AttributeError: |
652 pyfn = None |
652 pyfn = None |
653 |
653 |
654 if pyfn is not None: |
654 if pyfn is not None: |
655 self.unittestOpen.emit(pyfn) |
655 self.testFile.emit(pyfn) |
656 |
656 |
657 def __newToplevelDir(self): |
657 def __newToplevelDir(self): |
658 """ |
658 """ |
659 Private slot to handle the New toplevel directory popup menu entry. |
659 Private slot to handle the New toplevel directory popup menu entry. |
660 """ |
660 """ |