# 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.

### 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)

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 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

QWidget, Ui_FindFileWidget

### Class Attributes

endRole
lineRole
md5Role
replaceRole
startRole

### Class Methods

None

### Methods

FindFileWidget | Constructor
__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.
__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.
__projectClosed | Private slot to react to the closing of a project.
__projectOpened | Private slot to react to the opening of a project.
__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_filterCheckBox_clicked | Private slot to handle the selection of the file filter check box.
on_filterEdit_textEdited | Private slot to handle the textChanged signal of the file filter edit.
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_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.

### 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.__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.__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.__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.__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
  (ignored)

#### FindFileWidget.on_filterCheckBox_clicked

on_filterCheckBox_clicked()

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

#### FindFileWidget.on_filterEdit_textEdited

on_filterEdit_textEdited(text)

Private slot to handle the textChanged signal of the file filter edit.

text
  (ignored)

#### 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 (ignored)

#### FindFileWidget.on_findtextCombo_editTextChanged

on_findtextCombo_editTextChanged(text)

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

text
  (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_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
  (ignored)

Up