FindReplaceForm Class Reference

The form for the find/replace dialog. More...

#include <findreplaceform.h>

Inheritance diagram for FindReplaceForm:
Inheritance graph
[legend]

List of all members.

Public Slots

void find (bool down)
 performs the find task
void find ()
 Finds the next occurrence.
void findNext ()
 Finds the next occurrence.
void findPrev ()
 Finds the previous occurrence.
void replace ()
 Replaces the found occurrences and goes to the next occurrence.
void replaceAll ()
 Replaces all the found occurrences.

Public Member Functions

 FindReplaceForm (QWidget *parent=0)
virtual ~FindReplaceForm ()
void setTextEdit (QTextEdit *textEdit_)
 Associates the text editor where to perform the search.
void hideReplaceWidgets ()
 hides replace widgets from the form
virtual void writeSettings (QSettings &settings, const QString &prefix="FindReplaceDialog")
 Writes the state of the form to the passed settings.
virtual void readSettings (QSettings &settings, const QString &prefix="FindReplaceDialog")
 Reads the state of the form from the passed settings.

Protected Slots

void textToFindChanged ()
 when the text edit contents changed
void validateRegExp (const QString &text)
 checks whether the passed text is a valid regexp
void regexpSelected (bool sel)
 the regexp checkbox was selected

Protected Member Functions

void changeEvent (QEvent *e)
void showError (const QString &error)
 shows an error in the dialog
void showMessage (const QString &message)
 shows a message in the dialog

Protected Attributes

Ui::FindReplaceForm * ui
QTextCursor textCursor
 for searching into the text
QTextEdit * textEdit
 the text editor (possibly) associated with this form

Detailed Description

The form for the find/replace dialog.

The form presents the typical widgets you find in standard find/replace dialogs, and it acts on a QTextEdit.

Screenshot-FindReplace.png

You need to set the QTextEdit explicitly, using the method setTextEdit(QTextEdit *textEdit).

For instance

 m_findReplaceDialog = new FindReplaceDialog(this);
 m_findReplaceDialog->setModal(false);
 m_findReplaceDialog->setTextEdit(ui->textEdit);

The find functionalities is available even if the find dialog is not shown: if something to search for was already specified, the application can call the methods findNext() and findPrev() (e.g., by connecting them to menu items).

In case a regular expression is used as the search term, the form also checks whether the expression is a valid regular expression (You may want to take a look at the syntax of regular expressions: http://doc.trolltech.com/qregexp.html).

The form provides also functionalities to save and restore its state using a QSettings object (i.e., the last word searched for, the options of the form, etc.) via the methods writeSettings() and readSettings().

You can take a look at the Examples page.


Constructor & Destructor Documentation

FindReplaceForm::FindReplaceForm ( QWidget *  parent = 0  ) 
FindReplaceForm::~FindReplaceForm (  )  [virtual]

Member Function Documentation

void FindReplaceForm::changeEvent ( QEvent *  e  )  [protected]

Reimplemented in FindForm.

void FindReplaceForm::find (  )  [slot]

Finds the next occurrence.

void FindReplaceForm::find ( bool  down  )  [slot]

performs the find task

Parameters:
down whether to find the next or the previous occurrence
void FindReplaceForm::findNext (  )  [inline, slot]

Finds the next occurrence.

void FindReplaceForm::findPrev (  )  [inline, slot]

Finds the previous occurrence.

void FindReplaceForm::hideReplaceWidgets (  ) 

hides replace widgets from the form

void FindReplaceForm::readSettings ( QSettings &  settings,
const QString &  prefix = "FindReplaceDialog" 
) [virtual]

Reads the state of the form from the passed settings.

Parameters:
settings 
prefix the prefix to look for in the settings

Reimplemented in FindForm.

void FindReplaceForm::regexpSelected ( bool  sel  )  [protected, slot]

the regexp checkbox was selected

void FindReplaceForm::replace (  )  [slot]

Replaces the found occurrences and goes to the next occurrence.

void FindReplaceForm::replaceAll (  )  [slot]

Replaces all the found occurrences.

void FindReplaceForm::setTextEdit ( QTextEdit *  textEdit_  ) 

Associates the text editor where to perform the search.

Parameters:
textEdit_ 
void FindReplaceForm::showError ( const QString &  error  )  [protected]

shows an error in the dialog

void FindReplaceForm::showMessage ( const QString &  message  )  [protected]

shows a message in the dialog

void FindReplaceForm::textToFindChanged (  )  [protected, slot]

when the text edit contents changed

void FindReplaceForm::validateRegExp ( const QString &  text  )  [protected, slot]

checks whether the passed text is a valid regexp

void FindReplaceForm::writeSettings ( QSettings &  settings,
const QString &  prefix = "FindReplaceDialog" 
) [virtual]

Writes the state of the form to the passed settings.

Parameters:
settings 
prefix the prefix to insert in the settings

Reimplemented in FindForm.


Member Data Documentation

QTextCursor FindReplaceForm::textCursor [protected]

for searching into the text

QTextEdit* FindReplaceForm::textEdit [protected]

the text editor (possibly) associated with this form

Ui::FindReplaceForm* FindReplaceForm::ui [protected]

Generated on Sat Nov 28 18:30:56 2009 for QtFindReplaceDialog User's Guide by  doxygen 1.6.1