On Thu, Dec 17, 2009 at 1:33 PM, detlev <det...@die-offenbachs.de> wrote:
> On Mittwoch, 16. Dezember 2009, Mikhail Terekhov wrote: > > Detlev, > > > > It would be great if the File-Browser had some kind of filtering > > capability. I.e. for Python projects it would be very convenient to have > > even > > simple checkbox somewhere in settings or on the File-Browser itself > > saying 'do not show object files'. The reason is that when browsing > > say site-packages the *.pyc, *.pyo and *.so files are just a noise and > > make navigation more difficult most of the time (they comprise more > > than 60% of the content) > > Please give a little specification on how this function should work (e.g. > use > regexp or wildcards, what should happen to directories,...). After that I > might put it on the wish list. > > Please take a look at the patch attached. It adds an additional field to the Preferences->Interface->Browsers. May be something along these lines could make it into Eric. BTW the patch is against the trunk. Regards, -- Mikhail Terekhov
diff -r e997d2f41dea Preferences/ConfigurationPages/InterfacePage.py --- a/Preferences/ConfigurationPages/InterfacePage.py Sun Feb 06 18:42:06 2011 +0100 +++ b/Preferences/ConfigurationPages/InterfacePage.py Sun Feb 06 19:24:59 2011 -0500 @@ -48,6 +48,7 @@ Preferences.getUI("BrowsersListFoldersFirst")) self.uiBrowsersHideNonPublicCheckBox.setChecked( Preferences.getUI("BrowsersHideNonPublic")) + self.FileFilters.setText(Preferences.getUI("BrowsersFileFilters")) self.uiBrowsersSortByOccurrenceCheckBox.setChecked( Preferences.getUI("BrowsersListContentsByOccurrence")) self.uiBrowsersShowHiddenCheckBox.setChecked( @@ -128,6 +129,8 @@ self.uiBrowsersListFoldersFirstCheckBox.isChecked()) Preferences.setUI("BrowsersHideNonPublic", self.uiBrowsersHideNonPublicCheckBox.isChecked()) + Preferences.setUI("BrowsersFileFilters", + self.FileFilters.text()) Preferences.setUI("BrowsersListContentsByOccurrence", self.uiBrowsersSortByOccurrenceCheckBox.isChecked()) Preferences.setUI("BrowsersListHiddenFiles", diff -r e997d2f41dea Preferences/ConfigurationPages/InterfacePage.ui --- a/Preferences/ConfigurationPages/InterfacePage.ui Sun Feb 06 18:42:06 2011 +0100 +++ b/Preferences/ConfigurationPages/InterfacePage.ui Sun Feb 06 19:24:59 2011 -0500 @@ -77,6 +77,37 @@ </property> </widget> </item> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Filter out files</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="FileFilters"> + <property name="toolTip"> + <string>Glob style file patterns separated by semicolon. Files matching these patterns will be excluded from Browsers.</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="0"> + <spacer name="horizonOCtalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> </layout> </widget> </item> diff -r e997d2f41dea Preferences/__init__.py --- a/Preferences/__init__.py Sun Feb 06 18:42:06 2011 +0100 +++ b/Preferences/__init__.py Sun Feb 06 19:24:59 2011 -0500 @@ -103,6 +103,7 @@ "BrowsersHideNonPublic" : False, "BrowsersListContentsByOccurrence" : False, "BrowsersListHiddenFiles" : False, + "BrowsersFileFilters" : "*.py[co];*.so", "LogViewerAutoRaise" : True, "SingleApplicationMode" : False, "CaptionShowsFilename" : True, diff -r e997d2f41dea UI/BrowserModel.py --- a/UI/BrowserModel.py Sun Feb 06 18:42:06 2011 +0100 +++ b/UI/BrowserModel.py Sun Feb 06 19:24:59 2011 -0500 @@ -9,6 +9,7 @@ import sys import os +import fnmatch from PyQt4.QtCore import * from PyQt4.QtGui import * @@ -45,6 +46,8 @@ rootData = QApplication.translate("BrowserModel", "Name") self.rootItem = BrowserItem(None, rootData) + self.fileFilters = Preferences.getUI("BrowsersFileFilters").split(";") + self.progDir = None self.watchedItems = {} self.watcher = QFileSystemWatcher(self) @@ -487,6 +490,10 @@ Utilities.toNativeSeparators(f.absoluteFilePath()), False) else: + if self.fileFilters: + fn = f.fileName() + if any([fnmatch.fnmatch(fn, ff) for ff in self.fileFilters]): + continue node = BrowserFileItem(parentItem, Utilities.toNativeSeparators(f.absoluteFilePath())) self._addItem(node, parentItem)
_______________________________________________ Eric mailing list Eric@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/eric