Sat, 22 May 2010 14:58:02 +0200
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
UI/FindFileDialog.py | file | annotate | diff | comparison | revisions | |
UI/FindFileDialog.ui | file | annotate | diff | comparison | revisions | |
changelog | file | annotate | diff | comparison | revisions |
--- a/UI/FindFileDialog.py Fri May 21 21:25:44 2010 +0200 +++ b/UI/FindFileDialog.py Sat May 22 14:58:02 2010 +0200 @@ -69,8 +69,16 @@ self.findProgressLabel.setMaximumWidth(550) - self.searchHistory = [] - self.replaceHistory = [] + self.searchHistory = Preferences.toList( + Preferences.Prefs.settings.value("FindFileDialog/SearchHistory")) + self.replaceHistory = Preferences.toList( + Preferences.Prefs.settings.value("FindFileDialog/ReplaceHistory")) + self.dirHistory = Preferences.toList( + Preferences.Prefs.settings.value("FindFileDialog/DirectoryHistory")) + self.findtextCombo.addItems(self.searchHistory) + self.replacetextCombo.addItems(self.replaceHistory) + self.dirCombo.addItems(self.dirHistory) + self.project = project self.findList.headerItem().setText(self.findList.columnCount(), "") @@ -158,6 +166,8 @@ self.findList.clear() self.replacetextCombo.setEditText("") + self.dirCombo.setEditText("") + QDialog.show(self) def on_findtextCombo_editTextChanged(self, text): @@ -176,9 +186,9 @@ """ self.__enableFindButton() - def on_dirEdit_textChanged(self, text): + def on_dirCombo_editTextChanged(self, text): """ - Private slot to handle the textChanged signal of the directory edit. + Private slot to handle the textChanged signal of the directory combo box. @param text (ignored) """ @@ -221,8 +231,8 @@ if self.findtextCombo.currentText() == "" or \ (self.__replaceMode and self.replacetextCombo.currentText() == "") or \ (self.dirButton.isChecked() and \ - (self.dirEdit.text() == "" or \ - not os.path.exists(os.path.abspath(self.dirEdit.text())))) or \ + (self.dirCombo.currentText() == "" or \ + not os.path.exists(os.path.abspath(self.dirCombo.currentText())))) or \ (self.filterCheckBox.isChecked() and self.filterEdit.text() == ""): self.findButton.setEnabled(False) self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) @@ -296,7 +306,7 @@ filters.append(self.filterResources) filterString = "|".join(filters) filterRe = re.compile(filterString) - files = self.__getFileList(os.path.abspath(self.dirEdit.text()), + files = self.__getFileList(os.path.abspath(self.dirCombo.currentText()), filterRe) elif self.openFilesButton.isChecked(): files = e5App().getObject("ViewManager").getOpenFilenames() @@ -339,6 +349,9 @@ self.searchHistory.insert(0, ct) self.findtextCombo.clear() self.findtextCombo.addItems(self.searchHistory) + Preferences.Prefs.settings.setValue("FindFileDialog/SearchHistory", + self.searchHistory[:30]) + if self.__replaceMode: replTxt = self.replacetextCombo.currentText() if replTxt in self.replaceHistory: @@ -346,6 +359,18 @@ self.replaceHistory.insert(0, replTxt) self.replacetextCombo.clear() self.replacetextCombo.addItems(self.replaceHistory) + Preferences.Prefs.settings.setValue("FindFileDialog/ReplaceHistory", + self.replaceHistory[:30]) + + if self.dirButton.isChecked(): + dir = self.dirCombo.currentText() + if dir in self.dirHistory: + self.dirHistory.remove(dir) + self.dirHistory.insert(0, dir) + self.dirCombo.clear() + self.dirCombo.addItems(self.dirHistory) + Preferences.Prefs.settings.setValue("FindFileDialog/DirectoryHistory", + self.dirHistory[:30]) # now go through all the files self.__populating = True @@ -467,11 +492,11 @@ directory = QFileDialog.getExistingDirectory(\ self, self.trUtf8("Select directory"), - self.dirEdit.text(), + self.dirCombo.currentText(), QFileDialog.Options(QFileDialog.ShowDirsOnly)) if directory: - self.dirEdit.setText(Utilities.toNativeSeparators(directory)) + self.dirCombo.setEditText(Utilities.toNativeSeparators(directory)) def __getFileList(self, path, filterRe): """ @@ -497,7 +522,7 @@ @param searchDir name of the directory to search in (string) """ self.dirButton.setChecked(True) - self.dirEdit.setText(Utilities.toNativeSeparators(searchDir)) + self.dirCombo.setEditText(Utilities.toNativeSeparators(searchDir)) @pyqtSlot() def on_replaceButton_clicked(self):
--- a/UI/FindFileDialog.ui Fri May 21 21:25:44 2010 +0200 +++ b/UI/FindFileDialog.ui Sat May 22 14:58:02 2010 +0200 @@ -1,7 +1,8 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>FindFileDialog</class> - <widget class="QWidget" name="FindFileDialog" > - <property name="geometry" > + <widget class="QWidget" name="FindFileDialog"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> @@ -9,78 +10,78 @@ <height>750</height> </rect> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>Find in Files</string> </property> - <layout class="QVBoxLayout" name="verticalLayout" > + <layout class="QVBoxLayout" name="verticalLayout"> <item> - <layout class="QGridLayout" name="gridLayout_3" > - <item row="0" column="0" > - <widget class="QLabel" name="TextLabel1" > - <property name="text" > + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> + <widget class="QLabel" name="TextLabel1"> + <property name="text"> <string>Find &text:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>findtextCombo</cstring> </property> </widget> </item> - <item row="0" column="1" > - <widget class="QComboBox" name="findtextCombo" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > + <item row="0" column="1"> + <widget class="QComboBox" name="findtextCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Enter the search text or regular expression</string> </property> - <property name="editable" > + <property name="editable"> <bool>true</bool> </property> - <property name="insertPolicy" > + <property name="insertPolicy"> <enum>QComboBox::InsertAtTop</enum> </property> - <property name="autoCompletion" > + <property name="autoCompletion"> <bool>false</bool> </property> - <property name="duplicatesEnabled" > + <property name="duplicatesEnabled"> <bool>false</bool> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QLabel" name="replaceLabel" > - <property name="text" > + <item row="1" column="0"> + <widget class="QLabel" name="replaceLabel"> + <property name="text"> <string>Replace te&xt:</string> </property> - <property name="buddy" > + <property name="buddy"> <cstring>findtextCombo</cstring> </property> </widget> </item> - <item row="1" column="1" > - <widget class="QComboBox" name="replacetextCombo" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > + <item row="1" column="1"> + <widget class="QComboBox" name="replacetextCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Enter the replacement text or regular expression</string> </property> - <property name="editable" > + <property name="editable"> <bool>true</bool> </property> - <property name="insertPolicy" > + <property name="insertPolicy"> <enum>QComboBox::InsertAtTop</enum> </property> - <property name="autoCompletion" > + <property name="autoCompletion"> <bool>false</bool> </property> - <property name="duplicatesEnabled" > + <property name="duplicatesEnabled"> <bool>false</bool> </property> </widget> @@ -88,43 +89,43 @@ </layout> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_2" > + <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> - <widget class="QCheckBox" name="caseCheckBox" > - <property name="toolTip" > + <widget class="QCheckBox" name="caseCheckBox"> + <property name="toolTip"> <string>Select to match case sensitive</string> </property> - <property name="text" > + <property name="text"> <string>&Match upper/lower case</string> </property> </widget> </item> <item> - <widget class="QCheckBox" name="wordCheckBox" > - <property name="toolTip" > + <widget class="QCheckBox" name="wordCheckBox"> + <property name="toolTip"> <string>Select to match whole words only</string> </property> - <property name="text" > + <property name="text"> <string>Whole &word</string> </property> </widget> </item> <item> - <widget class="QCheckBox" name="regexpCheckBox" > - <property name="toolTip" > + <widget class="QCheckBox" name="regexpCheckBox"> + <property name="toolTip"> <string>Select if the searchtext is a regular expression</string> </property> - <property name="text" > + <property name="text"> <string>Regular &Expression</string> </property> </widget> </item> <item> - <widget class="QCheckBox" name="feelLikeCheckBox" > - <property name="toolTip" > + <widget class="QCheckBox" name="feelLikeCheckBox"> + <property name="toolTip"> <string>Select to open the first occurence automatically</string> </property> - <property name="text" > + <property name="text"> <string>Feeling Like</string> </property> </widget> @@ -132,85 +133,85 @@ </layout> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout" > + <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QGroupBox" name="groupBox" > - <property name="title" > + <widget class="QGroupBox" name="groupBox"> + <property name="title"> <string>File type</string> </property> - <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" > - <widget class="QCheckBox" name="sourcesCheckBox" > - <property name="toolTip" > + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QCheckBox" name="sourcesCheckBox"> + <property name="toolTip"> <string>Search in source files</string> </property> - <property name="text" > + <property name="text"> <string>&Sources</string> </property> - <property name="checked" > + <property name="checked"> <bool>true</bool> </property> </widget> </item> - <item row="0" column="1" > - <widget class="QCheckBox" name="resourcesCheckBox" > - <property name="toolTip" > + <item row="0" column="1"> + <widget class="QCheckBox" name="resourcesCheckBox"> + <property name="toolTip"> <string>Search in resources</string> </property> - <property name="text" > + <property name="text"> <string>&Resources</string> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QCheckBox" name="formsCheckBox" > - <property name="toolTip" > + <item row="1" column="0"> + <widget class="QCheckBox" name="formsCheckBox"> + <property name="toolTip"> <string>Search in forms</string> </property> - <property name="text" > + <property name="text"> <string>&Forms</string> </property> </widget> </item> - <item row="1" column="1" > - <widget class="QCheckBox" name="interfacesCheckBox" > - <property name="toolTip" > + <item row="1" column="1"> + <widget class="QCheckBox" name="interfacesCheckBox"> + <property name="toolTip"> <string>Search in interfaces</string> </property> - <property name="text" > + <property name="text"> <string>&Interfaces</string> </property> </widget> </item> - <item row="2" column="0" colspan="2" > - <widget class="Line" name="line" > - <property name="orientation" > + <item row="2" column="0" colspan="2"> + <widget class="Line" name="line"> + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="3" column="0" > - <widget class="QCheckBox" name="filterCheckBox" > - <property name="toolTip" > + <item row="3" column="0"> + <widget class="QCheckBox" name="filterCheckBox"> + <property name="toolTip"> <string>Select to filter the files by a given filename pattern</string> </property> - <property name="text" > + <property name="text"> <string>Fi&lter</string> </property> </widget> </item> - <item row="3" column="1" > - <widget class="QLineEdit" name="filterEdit" > - <property name="enabled" > + <item row="3" column="1"> + <widget class="QLineEdit" name="filterEdit"> + <property name="enabled"> <bool>false</bool> </property> - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Minimum" > + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="toolTip" > + <property name="toolTip"> <string>Enter the filename wildcards separated by ';'</string> </property> </widget> @@ -219,75 +220,99 @@ </widget> </item> <item> - <widget class="QGroupBox" name="groupBox_2" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Preferred" hsizetype="Expanding" > + <widget class="QGroupBox" name="groupBox_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="title" > + <property name="title"> <string>Find in</string> </property> - <layout class="QGridLayout" name="gridLayout_2" > - <item row="0" column="0" > - <widget class="QRadioButton" name="projectButton" > - <property name="toolTip" > - <string>Search in files of the current project</string> - </property> - <property name="text" > - <string>&Project</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item row="0" column="1" colspan="2" > - <widget class="QRadioButton" name="dirButton" > - <property name="toolTip" > - <string>Search in files of a directory tree to be entered below</string> - </property> - <property name="text" > - <string>&Directory tree</string> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QRadioButton" name="projectButton"> + <property name="toolTip"> + <string>Search in files of the current project</string> + </property> + <property name="text"> + <string>&Project</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="dirButton"> + <property name="toolTip"> + <string>Search in files of a directory tree to be entered below</string> + </property> + <property name="text"> + <string>&Directory tree</string> + </property> + </widget> + </item> + </layout> </item> - <item row="1" column="0" colspan="2" > - <widget class="QLineEdit" name="dirEdit" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="toolTip" > - <string>Enter the directory to search in</string> - </property> - </widget> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QComboBox" name="dirCombo"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Enter the directory to search in</string> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="insertPolicy"> + <enum>QComboBox::InsertAtTop</enum> + </property> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToMinimumContentsLength</enum> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="dirSelectButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>Select the directory via a directory selection dialog</string> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> </item> - <item row="1" column="2" > - <widget class="QPushButton" name="dirSelectButton" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="focusPolicy" > - <enum>Qt::NoFocus</enum> - </property> - <property name="toolTip" > - <string>Select the directory via a directory selection dialog</string> - </property> - <property name="text" > - <string>...</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="3" > - <widget class="QRadioButton" name="openFilesButton" > - <property name="toolTip" > - <string>Search in open files only </string> - </property> - <property name="text" > - <string>&Open files only</string> - </property> - </widget> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QRadioButton" name="openFilesButton"> + <property name="toolTip"> + <string>Search in open files only </string> + </property> + <property name="text"> + <string>&Open files only</string> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> @@ -295,76 +320,76 @@ </layout> </item> <item> - <widget class="E5SqueezeLabelPath" name="findProgressLabel" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Preferred" hsizetype="Expanding" > + <widget class="E5SqueezeLabelPath" name="findProgressLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="text" > + <property name="text"> <string/> </property> </widget> </item> <item> - <widget class="QProgressBar" name="findProgress" > - <property name="toolTip" > + <widget class="QProgressBar" name="findProgress"> + <property name="toolTip"> <string>Shows the progress of the search action</string> </property> - <property name="value" > + <property name="value"> <number>0</number> </property> - <property name="orientation" > + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> <item> - <widget class="QTreeWidget" name="findList" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Expanding" hsizetype="Expanding" > + <widget class="QTreeWidget" name="findList"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>3</verstretch> </sizepolicy> </property> - <property name="alternatingRowColors" > + <property name="alternatingRowColors"> <bool>true</bool> </property> - <property name="sortingEnabled" > + <property name="sortingEnabled"> <bool>true</bool> </property> - <property name="columnCount" > + <property name="columnCount"> <number>2</number> </property> <column> - <property name="text" > + <property name="text"> <string>File/Line</string> </property> </column> <column> - <property name="text" > + <property name="text"> <string>Text</string> </property> </column> </widget> </item> <item> - <widget class="QPushButton" name="replaceButton" > - <property name="toolTip" > + <widget class="QPushButton" name="replaceButton"> + <property name="toolTip"> <string>Press to apply the selected replacements</string> </property> - <property name="text" > + <property name="text"> <string>Replace</string> </property> </widget> </item> <item> - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="standardButtons" > + <property name="standardButtons"> <set>QDialogButtonBox::Close</set> </property> </widget> @@ -393,7 +418,8 @@ <tabstop>filterEdit</tabstop> <tabstop>projectButton</tabstop> <tabstop>dirButton</tabstop> - <tabstop>dirEdit</tabstop> + <tabstop>dirCombo</tabstop> + <tabstop>dirSelectButton</tabstop> <tabstop>openFilesButton</tabstop> <tabstop>findList</tabstop> <tabstop>replaceButton</tabstop> @@ -404,32 +430,16 @@ <connection> <sender>dirButton</sender> <signal>toggled(bool)</signal> - <receiver>dirEdit</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>581</x> - <y>105</y> - </hint> - <hint type="destinationlabel" > - <x>466</x> - <y>161</y> - </hint> - </hints> - </connection> - <connection> - <sender>dirButton</sender> - <signal>toggled(bool)</signal> <receiver>dirSelectButton</receiver> <slot>setEnabled(bool)</slot> <hints> - <hint type="sourcelabel" > - <x>581</x> - <y>105</y> + <hint type="sourcelabel"> + <x>392</x> + <y>136</y> </hint> - <hint type="destinationlabel" > - <x>581</x> - <y>136</y> + <hint type="destinationlabel"> + <x>577</x> + <y>168</y> </hint> </hints> </connection> @@ -439,11 +449,11 @@ <receiver>FindFileDialog</receiver> <slot>close()</slot> <hints> - <hint type="sourcelabel" > - <x>40</x> - <y>693</y> + <hint type="sourcelabel"> + <x>49</x> + <y>740</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>34</x> <y>660</y> </hint> @@ -455,15 +465,31 @@ <receiver>filterEdit</receiver> <slot>setEnabled(bool)</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>53</x> <y>195</y> </hint> - <hint type="destinationlabel" > - <x>205</x> - <y>197</y> + <hint type="destinationlabel"> + <x>191</x> + <y>196</y> + </hint> + </hints> + </connection> + <connection> + <sender>dirButton</sender> + <signal>toggled(bool)</signal> + <receiver>dirCombo</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>302</x> + <y>125</y> + </hint> + <hint type="destinationlabel"> + <x>303</x> + <y>158</y> </hint> </hints> </connection> </connections> -</ui> \ No newline at end of file +</ui>
--- a/changelog Fri May 21 21:25:44 2010 +0200 +++ b/changelog Sat May 22 14:58:02 2010 +0200 @@ -10,6 +10,8 @@ aspects of a font only - changed code to improve development on multiple platforms - added code to show the keyboard shortcut to the tooltip of an action +- changed the Find in Files dialog to remember the history of the search string, + replace string and the search directory Version 5.0-snapshot-20100508: - bug fixes