# eric7.UI.FindFileWidget

Module implementing a dialog to search for text in files.

### Global Attributes

None

### Classes

FindFileDialog | Class implementing a dialog to search for text in files and replace it with some other text.
FindFileWidget | Class implementing a widget to search for text in files and replace it with some other text.

### Functions

None

## FindFileDialog

Class implementing a dialog to search for text in files and replace it with some other text.

The occurrences found are displayed in a tree showing the file name, the line number and the text found. The file will be opened upon a double click onto the respective entry of the list. If the widget is in replace mode the line below shows the text after replacement. Replacements can be authorized by ticking them on. Pressing the replace button performs all ticked replacement operations.

### Signals

designerFile(str)
  emitted to open a Qt-Designer file
linguistFile(str)
  emitted to open a Qt-Linguist (*.ts) file
pixmapFile(str)
  emitted to open a pixmap file
sourceFile(str, int, str, int, int)
  emitted to open a source file at a specificline
svgFile(str)
  emitted to open a SVG file
trpreview([str])
  emitted to preview Qt-Linguist (*.qm) files
umlFile(str)
  emitted to open an eric UML file

### Derived from

QDialog

### Class Attributes

None

### Class Methods

None

### Methods

FindFileDialog | Constructor
activate | Public method to activate the dialog with a given mode, a text to search for and some search parameters.
populateFileCategories | Public method to populate the search file categories list.

### Static Methods

None

#### FindFileDialog (Constructor)

FindFileDialog(project, parent=None)

Constructor

project (Project)
  reference to the project object
parent (QWidget (optional))
  parent widget of this dialog (defaults to None)

#### FindFileDialog.activate

activate(replaceMode=False, txt="", searchDir="", openFiles=False)

Public method to activate the dialog with a given mode, a text to search for and some search parameters.

replaceMode (bool (optional))
  flag indicating replacement mode (defaults to False)
txt (str (optional))
  text to be searched for (defaults to "")
searchDir (str (optional))
  directory to search in (defaults to "")
openFiles (bool (optional))
  flag indicating to operate on open files only (defaults to False)

#### FindFileDialog.populateFileCategories

populateFileCategories()

Public method to populate the search file categories list.

Up

## FindFileWidget

Class implementing a widget to search for text in files and replace it with some other text.

The occurrences found are displayed in a tree showing the file name, the line number and the text found. The file will be opened upon a double click onto the respective entry of the list. If the widget is in replace mode the line below shows the text after replacement. Replacements can be authorized by ticking them on. Pressing the replace button performs all ticked replacement operations.

### Signals

designerFile(str)
  emitted to open a Qt-Designer file
linguistFile(str)
  emitted to open a Qt-Linguist (*.ts) file
pixmapFile(str)
  emitted to open a pixmap file
sourceFile(str, int, str, int, int)
  emitted to open a source file at a specific line
svgFile(str)
  emitted to open a SVG file
trpreview([str])
  emitted to preview Qt-Linguist (*.qm) files
umlFile(str)
  emitted to open an eric UML file

### Derived from

QWidget, Ui_FindFileWidget

### Class Attributes

endRole
lineRole
md5Role
replaceRole
startRole

### Class Methods

None

### Methods

FindFileWidget | Constructor
__buildReFileFilter | Private method to convert a file filter expression into a valid re search pattern.
__clearResults | Private slot to clear the current search results.
__contextMenuRequested | Private slot to handle the context menu request.
__copyToClipboard | Private slot to copy the path of an entry to the clipboard.
__createItem | Private method to create an entry in the file list.
__deselectAll | Private slot to deselect all entries.
__doSearch | Private slot to handle the find button being pressed.
__enableFindButton | Private slot called to enable the find button.
__getFileList | Private method to get a list of files to search.
__openFile | Private slot to open the currently selected entry.
__populateFiltersSelector | Private method to (re-)populate the file filters selector.
__projectClosed | Private slot to react to the closing of a project.
__projectOpened | Private slot to react to the opening of a project.
__selectAll | Private slot to select all entries.
__setOpenFiles | Private slot to set the mode to search in open files.
__setSearchDirectory | Private slot to set the name of the directory to search in.
__stopSearch | Private slot to handle the stop button being pressed.
__stripEol | Private method to strip the eol part.
__toggleReplaceMode | Private slot to toggle the dialog mode.
activate | Public method to activate the widget with a given mode, a text to search for and some search parameters.
on_dirButton_clicked | Private slot to handle the selection of the 'Directory' radio button.
on_dirPicker_editTextChanged | Private slot to handle the textChanged signal of the directory picker.
on_escapeToolButton_toggled | Private slot handling a change of the escape selector.
on_filterCheckBox_clicked | Private slot to handle the selection of the file filter check box.
on_filterComboBox_currentIndexChanged | Private slot to handle the selection of a file filter.
on_filtersConfigButton_clicked | Private slot to edit the list of defined file filter entries.
on_findList_itemDoubleClicked | Private slot to handle the double click on a file item.
on_findtextCombo_editTextChanged | Private slot to handle the editTextChanged signal of the find text combo.
on_openFilesButton_clicked | Private slot to handle the selection of the 'Open Files' radio button.
on_projectButton_clicked | Private slot to handle the selection of the 'Project' radio button.
on_regexpToolButton_toggled | Private slot handling a change of the regexp selector.
on_replaceButton_clicked | Private slot to perform the requested replace actions.
on_replacetextCombo_editTextChanged | Private slot to handle the editTextChanged signal of the replace text combo.
populateFileCategories | Public method to populate the search file categories list.

### Static Methods

None

#### FindFileWidget (Constructor)

FindFileWidget(project, parent=None)

Constructor

project (Project)
  reference to the project object
parent (QWidget (optional))
  parent widget of this dialog (defaults to None)

#### FindFileWidget.__buildReFileFilter

__buildReFileFilter(fileFilter)

Private method to convert a file filter expression into a valid re search pattern.

fileFilter (str)
  file filter expression

Return:
  re search pattern with dot, question mark and star converted

Return Type:
  str

#### FindFileWidget.__clearResults

__clearResults()

Private slot to clear the current search results.

#### FindFileWidget.__contextMenuRequested

__contextMenuRequested(pos)

Private slot to handle the context menu request.

pos (QPoint)
  position the context menu shall be shown

#### FindFileWidget.__copyToClipboard

__copyToClipboard()

Private slot to copy the path of an entry to the clipboard.

#### FindFileWidget.__createItem

__createItem(file, line, text, start, end, replTxt="", md5="")

Private method to create an entry in the file list.

file (str)
  filename of file
line (int)
  line number
text (str)
  text found
start (int)
  start position of match
end (int)
  end position of match
replTxt (str (optional))
  text with replacements applied (defaults to "")
md5 (str (optional))
  MD5 hash of the file (defaults to "")

#### FindFileWidget.__deselectAll

__deselectAll()

Private slot to deselect all entries.

#### FindFileWidget.__doSearch

__doSearch()

Private slot to handle the find button being pressed.

#### FindFileWidget.__enableFindButton

__enableFindButton()

Private slot called to enable the find button.

#### FindFileWidget.__getFileList

__getFileList(path, filterRe, excludeHiddenDirs=False, excludeHiddenFiles=False)

Private method to get a list of files to search.

path (str)
  the root directory to search in
filterRe (regexp object)
  regular expression defining the filter criteria
excludeHiddenDirs (bool)
  flag indicating to exclude hidden directories
excludeHiddenFiles (bool)
  flag indicating to exclude hidden files

Return:
  list of files to be processed

Return Type:
  list of str

#### FindFileWidget.__openFile

__openFile()

Private slot to open the currently selected entry.

#### FindFileWidget.__populateFiltersSelector

__populateFiltersSelector()

Private method to (re-)populate the file filters selector.

#### FindFileWidget.__projectClosed

__projectClosed()

Private slot to react to the closing of a project.

#### FindFileWidget.__projectOpened

__projectOpened()

Private slot to react to the opening of a project.

#### FindFileWidget.__selectAll

__selectAll(check=True)

Private slot to select all entries.

check (bool (optional))
  flag indicating the desired check state (defaults to True)

#### FindFileWidget.__setOpenFiles

__setOpenFiles()

Private slot to set the mode to search in open files.

#### FindFileWidget.__setSearchDirectory

__setSearchDirectory(searchDir)

Private slot to set the name of the directory to search in.

searchDir (str)
  name of the directory to search in

#### FindFileWidget.__stopSearch

__stopSearch()

Private slot to handle the stop button being pressed.

#### FindFileWidget.__stripEol

__stripEol(txt)

Private method to strip the eol part.

txt (str)
  line of text that should be treated

Return:
  text with eol stripped

Return Type:
  str

#### FindFileWidget.__toggleReplaceMode

__toggleReplaceMode()

Private slot to toggle the dialog mode.

#### FindFileWidget.activate

activate(replaceMode=False, txt="", searchDir="", openFiles=False)

Public method to activate the widget with a given mode, a text to search for and some search parameters.

replaceMode (bool (optional))
  flag indicating replacement mode (defaults to False)
txt (str (optional))
  text to be searched for (defaults to "")
searchDir (str (optional))
  directory to search in (defaults to "")
openFiles (bool (optional))
  flag indicating to operate on open files only (defaults to False)

#### FindFileWidget.on_dirButton_clicked

on_dirButton_clicked()

Private slot to handle the selection of the 'Directory' radio button.

#### FindFileWidget.on_dirPicker_editTextChanged

on_dirPicker_editTextChanged(text)

Private slot to handle the textChanged signal of the directory picker.

text (str)
  (ignored)

#### FindFileWidget.on_escapeToolButton_toggled

on_escapeToolButton_toggled(checked)

Private slot handling a change of the escape selector.

checked (bool)
  state of the escape selector

#### FindFileWidget.on_filterCheckBox_clicked

on_filterCheckBox_clicked()

Private slot to handle the selection of the file filter check box.

#### FindFileWidget.on_filterComboBox_currentIndexChanged

on_filterComboBox_currentIndexChanged(index)

Private slot to handle the selection of a file filter.

index (int)
  index of the selected entry

#### FindFileWidget.on_filtersConfigButton_clicked

on_filtersConfigButton_clicked()

Private slot to edit the list of defined file filter entries.

#### FindFileWidget.on_findList_itemDoubleClicked

on_findList_itemDoubleClicked(itm, _column)

Private slot to handle the double click on a file item.

It emits a signal depending on the file extension.

itm (QTreeWidgetItem)
  the double clicked tree item
_column (int)
  column that was double clicked (unused)

#### FindFileWidget.on_findtextCombo_editTextChanged

on_findtextCombo_editTextChanged(text)

Private slot to handle the editTextChanged signal of the find text combo.

text (str)
  (ignored)

#### FindFileWidget.on_openFilesButton_clicked

on_openFilesButton_clicked()

Private slot to handle the selection of the 'Open Files' radio button.

#### FindFileWidget.on_projectButton_clicked

on_projectButton_clicked()

Private slot to handle the selection of the 'Project' radio button.

#### FindFileWidget.on_regexpToolButton_toggled

on_regexpToolButton_toggled(checked)

Private slot handling a change of the regexp selector.

checked (bool)
  state of the regexp selector

#### FindFileWidget.on_replaceButton_clicked

on_replaceButton_clicked()

Private slot to perform the requested replace actions.

#### FindFileWidget.on_replacetextCombo_editTextChanged

on_replacetextCombo_editTextChanged(text)

Private slot to handle the editTextChanged signal of the replace text combo.

text (str)
  (ignored)

#### FindFileWidget.populateFileCategories

populateFileCategories()

Public method to populate the search file categories list.

Up