UI/FindFileNameDialog.py

changeset 4589
b648ccbdbef9
parent 4021
195a471c327b
child 4631
5c1a96925da4
equal deleted inserted replaced
4586:9221c0c5c66f 4589:b648ccbdbef9
14 14
15 from PyQt5.QtCore import pyqtSignal, pyqtSlot 15 from PyQt5.QtCore import pyqtSignal, pyqtSlot
16 from PyQt5.QtWidgets import QWidget, QHeaderView, QApplication, \ 16 from PyQt5.QtWidgets import QWidget, QHeaderView, QApplication, \
17 QDialogButtonBox, QTreeWidgetItem 17 QDialogButtonBox, QTreeWidgetItem
18 18
19 from E5Gui.E5Completers import E5DirCompleter 19 from E5Gui.E5PathPicker import E5PathPickerModes
20 from E5Gui import E5FileDialog
21 20
22 from .Ui_FindFileNameDialog import Ui_FindFileNameDialog 21 from .Ui_FindFileNameDialog import Ui_FindFileNameDialog
23 22
24 from Utilities import direntries 23 from Utilities import direntries
25 import Utilities 24 import Utilities
26 import UI.PixmapCache
27 25
28 26
29 class FindFileNameDialog(QWidget, Ui_FindFileNameDialog): 27 class FindFileNameDialog(QWidget, Ui_FindFileNameDialog):
30 """ 28 """
31 Class implementing a dialog to search for files. 29 Class implementing a dialog to search for files.
48 @param parent parent widget of this dialog (QWidget) 46 @param parent parent widget of this dialog (QWidget)
49 """ 47 """
50 super(FindFileNameDialog, self).__init__(parent) 48 super(FindFileNameDialog, self).__init__(parent)
51 self.setupUi(self) 49 self.setupUi(self)
52 50
53 self.searchDirButton.setIcon(UI.PixmapCache.getIcon("open.png")) 51 self.searchDirPicker.setMode(E5PathPickerModes.DirectoryMode)
54
55 self.searchDirCompleter = E5DirCompleter(self.searchDirEdit)
56 52
57 self.fileList.headerItem().setText(self.fileList.columnCount(), "") 53 self.fileList.headerItem().setText(self.fileList.columnCount(), "")
58 54
59 self.stopButton = self.buttonBox.addButton( 55 self.stopButton = self.buttonBox.addButton(
60 self.tr("Stop"), QDialogButtonBox.ActionRole) 56 self.tr("Stop"), QDialogButtonBox.ActionRole)
117 fileNamePattern = patternFormat.format( 113 fileNamePattern = patternFormat.format(
118 fileName, os.extsep, fileExt and fileExt or '*') 114 fileName, os.extsep, fileExt and fileExt or '*')
119 115
120 searchPaths = [] 116 searchPaths = []
121 if self.searchDirCheckBox.isChecked() and \ 117 if self.searchDirCheckBox.isChecked() and \
122 self.searchDirEdit.text() != "": 118 self.searchDirPicker.text() != "":
123 searchPaths.append(self.searchDirEdit.text()) 119 searchPaths.append(self.searchDirPicker.text())
124 if self.projectCheckBox.isChecked(): 120 if self.projectCheckBox.isChecked():
125 searchPaths.append(self.project.ppath) 121 searchPaths.append(self.project.ppath)
126 if self.syspathCheckBox.isChecked(): 122 if self.syspathCheckBox.isChecked():
127 searchPaths.extend(sys.path) 123 searchPaths.extend(sys.path)
128 124
183 179
184 @param text (ignored) 180 @param text (ignored)
185 """ 181 """
186 self.__searchFile() 182 self.__searchFile()
187 183
188 def on_searchDirEdit_textChanged(self, text): 184 def on_searchDirPicker_textChanged(self, text):
189 """ 185 """
190 Private slot to handle the textChanged signal of the search directory 186 Private slot to handle the textChanged signal of the search directory
191 edit. 187 edit.
192 188
193 @param text text of the search dir edit (string) 189 @param text text of the search dir edit (string)
194 """ 190 """
195 self.searchDirCheckBox.setEnabled(text != "") 191 self.searchDirCheckBox.setEnabled(text != "")
196 if self.searchDirCheckBox.isChecked(): 192 if self.searchDirCheckBox.isChecked():
197 self.__searchFile() 193 self.__searchFile()
198 194
199 @pyqtSlot()
200 def on_searchDirButton_clicked(self):
201 """
202 Private slot to handle the clicked signal of the search directory
203 selection button.
204 """
205 searchDir = E5FileDialog.getExistingDirectory(
206 None,
207 self.tr("Select search directory"),
208 self.searchDirEdit.text(),
209 E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
210
211 if searchDir:
212 self.searchDirEdit.setText(Utilities.toNativeSeparators(searchDir))
213
214 def on_searchDirCheckBox_toggled(self, checked): 195 def on_searchDirCheckBox_toggled(self, checked):
215 """ 196 """
216 Private slot to handle the toggled signal of the search directory 197 Private slot to handle the toggled signal of the search directory
217 checkbox. 198 checkbox.
218 199
219 @param checked flag indicating the state of the checkbox (boolean) 200 @param checked flag indicating the state of the checkbox (boolean)
220 """ 201 """
221 if self.searchDirEdit.text(): 202 if self.searchDirPicker.text():
222 self.__searchFile() 203 self.__searchFile()
223 204
224 def on_projectCheckBox_toggled(self, checked): 205 def on_projectCheckBox_toggled(self, checked):
225 """ 206 """
226 Private slot to handle the toggled signal of the project checkbox. 207 Private slot to handle the toggled signal of the project checkbox.

eric ide

mercurial