diff -r 9986ec0e559a -r 10516539f238 UI/Browser.py --- a/UI/Browser.py Tue Oct 15 22:03:54 2013 +0200 +++ b/UI/Browser.py Fri Oct 18 23:00:41 2013 +0200 @@ -13,14 +13,14 @@ import mimetypes from PyQt4.QtCore import QModelIndex, pyqtSignal, QUrl, Qt, qVersion -from PyQt4.QtGui import QTreeView, QDesktopServices, QItemSelectionModel, QApplication, \ - QMenu, QAbstractItemView +from PyQt4.QtGui import QTreeView, QDesktopServices, QItemSelectionModel, \ + QApplication, QMenu, QAbstractItemView from E5Gui.E5Application import e5App from E5Gui import E5FileDialog -from .BrowserModel import BrowserModel, \ - BrowserDirectoryItem, BrowserFileItem, BrowserClassItem, BrowserMethodItem, \ +from .BrowserModel import BrowserModel, BrowserDirectoryItem, \ + BrowserFileItem, BrowserClassItem, BrowserMethodItem, \ BrowserClassAttributeItem from .BrowserSortFilterProxyModel import BrowserSortFilterProxyModel @@ -37,11 +37,12 @@ is displayed by a right click the user can select various actions on the selected file. - @signal sourceFile(str, int = 0, str = "") emitted to open a Python file at a line + @signal sourceFile(str, int = 0, str = "") emitted to open a Python file + at a line @signal designerFile(str) emitted to open a Qt-Designer file @signal linguistFile(str) emitted to open a Qt-Linguist (*.ts) file - @signal trpreview(list of str, bool = False) emitted to preview a Qt-Linguist - (*.qm) file + @signal trpreview(list of str, bool = False) emitted to preview a + Qt-Linguist (*.qm) file @signal projectFile(str) emitted to open an eric4/5 project file @signal multiProjectFile(str) emitted to open an eric4/5 multi project file @signal pixmapFile(str) emitted to open a pixmap file @@ -88,38 +89,44 @@ self.expanded.connect(self._resizeColumns) self.collapsed.connect(self._resizeColumns) - self.setWhatsThis(QApplication.translate('Browser', + self.setWhatsThis(QApplication.translate( + 'Browser', """<b>The Browser Window</b>""" - """<p>This allows you to easily navigate the hierachy of directories and""" - """ files on your system, identify the Python programs and open them up in""" - """ a Source Viewer window. The window displays several separate""" - """ hierachies.</p>""" - """<p>The first hierachy is only shown if you have opened a program for""" - """ debugging and its root is the directory containing that program.""" - """ Usually all of the separate files that make up a Python application are""" - """ held in the same directory, so this hierachy gives you easy access to""" - """ most of what you will need.</p>""" - """<p>The next hierachy is used to easily navigate the directories that are""" - """ specified in the Python <tt>sys.path</tt> variable.</p>""" - """<p>The remaining hierachies allow you navigate your system as a whole.""" - """ On a UNIX system there will be a hierachy with <tt>/</tt> at its""" - """ root and another with the user home directory.""" - """ On a Windows system there will be a hierachy for each drive on the""" + """<p>This allows you to easily navigate the hierarchy of""" + """ directories and files on your system, identify the Python""" + """ programs and open them up in a Source Viewer window. The""" + """ window displays several separate hierarchies.</p>""" + """<p>The first hierarchy is only shown if you have opened a""" + """ program for debugging and its root is the directory""" + """ containing that program. Usually all of the separate files""" + """ that make up a Python application are held in the same""" + """ directory, so this hierarchy gives you easy access to most""" + """ of what you will need.</p>""" + """<p>The next hierarchy is used to easily navigate the""" + """ directories that are specified in the Python""" + """ <tt>sys.path</tt> variable.</p>""" + """<p>The remaining hierarchies allow you navigate your system""" + """ as a whole. On a UNIX system there will be a hierarchy with""" + """ <tt>/</tt> at its root and another with the user home""" + """ directory. On a Windows system there will be a hierarchy for""" + """ each drive on the""" """ system.</p>""" - """<p>Python programs (i.e. those with a <tt>.py</tt> file name suffix)""" - """ are identified in the hierachies with a Python icon.""" - """ The right mouse button will popup a menu which lets you""" - """ open the file in a Source Viewer window,""" - """ open the file for debugging or use it for a unittest run.</p>""" - """<p>The context menu of a class, function or method allows you to open""" - """ the file defining this class, function or method and will ensure, that""" - """ the correct source line is visible.</p>""" - """<p>Qt-Designer files (i.e. those with a <tt>.ui</tt> file name suffix)""" - """ are shown with a Designer icon. The context menu of these files""" - """ allows you to start Qt-Designer with that file.</p>""" - """<p>Qt-Linguist files (i.e. those with a <tt>.ts</tt> file name suffix)""" - """ are shown with a Linguist icon. The context menu of these files""" - """ allows you to start Qt-Linguist with that file.</p>""" + """<p>Python programs (i.e. those with a <tt>.py</tt> file name""" + """ suffix) are identified in the hierarchies with a Python""" + """ icon. The right mouse button will popup a menu which lets""" + """ you open the file in a Source Viewer window, open the file""" + """ for debugging or use it for a unittest run.</p>""" + """<p>The context menu of a class, function or method allows you""" + """ to open the file defining this class, function or method and""" + """ will ensure, that the correct source line is visible.</p>""" + """<p>Qt-Designer files (i.e. those with a <tt>.ui</tt> file""" + """ name suffix) are shown with a Designer icon. The context""" + """ menu of these files allows you to start Qt-Designer with""" + """ that file.</p>""" + """<p>Qt-Linguist files (i.e. those with a <tt>.ts</tt> file""" + """ name suffix) are shown with a Linguist icon. The context""" + """ menu of these files allows you to start Qt-Linguist with""" + """ that file.</p>""" )) self.__createPopupMenus() @@ -185,24 +192,27 @@ self.sourceMenu.addAction(QApplication.translate('Browser', 'Open'), self._openItem) self.unittestAct = self.sourceMenu.addAction( - QApplication.translate('Browser', 'Run unittest...'), self.handleUnittest) + QApplication.translate('Browser', 'Run unittest...'), + self.handleUnittest) self.sourceMenu.addAction( QApplication.translate('Browser', 'Copy Path to Clipboard'), self._copyToClipboard) # create the popup menu for general use self.menu = QMenu(self) - self.menu.addAction(QApplication.translate('Browser', 'Open'), self._openItem) - self.editPixmapAct = \ - self.menu.addAction(QApplication.translate('Browser', 'Open in Icon Editor'), + self.menu.addAction( + QApplication.translate('Browser', 'Open'), self._openItem) + self.editPixmapAct = self.menu.addAction( + QApplication.translate('Browser', 'Open in Icon Editor'), self._editPixmap) self.menu.addAction( QApplication.translate('Browser', 'Copy Path to Clipboard'), self._copyToClipboard) if self.__embeddedBrowser in [1, 2]: self.menu.addSeparator() - self.menu.addAction(QApplication.translate('Browser', 'Configure...'), - self.__configure) + self.menu.addAction( + QApplication.translate('Browser', 'Configure...'), + self.__configure) # create the menu for multiple selected files self.multiMenu = QMenu(self) @@ -210,8 +220,9 @@ self._openItem) if self.__embeddedBrowser in [1, 2]: self.multiMenu.addSeparator() - self.multiMenu.addAction(QApplication.translate('Browser', 'Configure...'), - self.__configure) + self.multiMenu.addAction( + QApplication.translate('Browser', 'Configure...'), + self.__configure) # create the directory menu self.dirMenu = QMenu(self) @@ -240,8 +251,9 @@ self._copyToClipboard) if self.__embeddedBrowser in [1, 2]: self.dirMenu.addSeparator() - self.dirMenu.addAction(QApplication.translate('Browser', 'Configure...'), - self.__configure) + self.dirMenu.addAction( + QApplication.translate('Browser', 'Configure...'), + self.__configure) # create the attribute menu self.gotoMenu = QMenu(self.trUtf8("Goto"), self) @@ -267,15 +279,16 @@ self.__newToplevelDir) if self.__embeddedBrowser in [1, 2]: self.backMenu.addSeparator() - self.backMenu.addAction(QApplication.translate('Browser', 'Configure...'), - self.__configure) + self.backMenu.addAction( + QApplication.translate('Browser', 'Configure...'), + self.__configure) def mouseDoubleClickEvent(self, mouseEvent): """ Protected method of QAbstractItemView. - Reimplemented to disable expanding/collapsing - of items when double-clicking. Instead the double-clicked entry is opened. + Reimplemented to disable expanding/collapsing of items when + double-clicking. Instead the double-clicked entry is opened. @param mouseEvent the mouse event (QMouseEvent) """ @@ -302,7 +315,8 @@ if index.isValid(): self.setCurrentIndex(index) flags = QItemSelectionModel.SelectionFlags( - QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows) + QItemSelectionModel.ClearAndSelect | + QItemSelectionModel.Rows) self.selectionModel().select(index, flags) itm = self.model().item(index) @@ -346,12 +360,15 @@ fileName = itm.fileName() for lineno in sorted(linenos): - act = self.gotoMenu.addAction(self.trUtf8("Line {0}".format(lineno))) + act = self.gotoMenu.addAction( + self.trUtf8("Line {0}".format(lineno))) act.setData([fileName, lineno]) def _gotoAttribute(self, act): """ Protected slot to handle the selection of the goto menu. + + @param act reference to the action (E5Action) """ fileName, lineno = act.data() self.sourceFile[str, int].emit(fileName, lineno) @@ -380,9 +397,11 @@ elif itm.isPython3File(): self.sourceFile[str].emit(itm.fileName()) elif itm.isRubyFile(): - self.sourceFile[str, int, str].emit(itm.fileName(), -1, "Ruby") + self.sourceFile[str, int, str].emit( + itm.fileName(), -1, "Ruby") elif itm.isDFile(): - self.sourceFile[str, int, str].emit(itm.fileName(), -1, "D") + self.sourceFile[str, int, str].emit( + itm.fileName(), -1, "D") elif itm.isDesignerFile(): self.designerFile.emit(itm.fileName()) elif itm.isLinguistFile(): @@ -505,7 +524,8 @@ index = self.currentIndex() searchDir = self.model().item(index).dirName() - e5App().getObject("UserInterface").showFindFilesDialog(searchDir=searchDir) + e5App().getObject("UserInterface")\ + .showFindFilesDialog(searchDir=searchDir) def __replaceInDirectory(self): """ @@ -514,11 +534,14 @@ index = self.currentIndex() searchDir = self.model().item(index).dirName() - e5App().getObject("UserInterface").showReplaceFilesDialog(searchDir=searchDir) + e5App().getObject("UserInterface")\ + .showReplaceFilesDialog(searchDir=searchDir) def handleProgramChange(self, fn): """ Public slot to handle the programChange signal. + + @param fn file name (string) """ self.__model.programChange(os.path.dirname(fn)) @@ -610,6 +633,8 @@ Private method to open the configuration dialog. """ if self.__embeddedBrowser == 1: - e5App().getObject("UserInterface").showPreferences("debuggerGeneralPage") + e5App().getObject("UserInterface")\ + .showPreferences("debuggerGeneralPage") elif self.__embeddedBrowser == 2: - e5App().getObject("UserInterface").showPreferences("projectBrowserPage") + e5App().getObject("UserInterface")\ + .showPreferences("projectBrowserPage")