KoReplace Class Reference
A generic implementation of the "replace" function. More...
#include <koReplace.h>
Inheritance diagram for KoReplace:


Signals | |
void | highlight (const QString &text, int matchingIndex, int matchedLength, const QRect &expose) |
Connect to this slot to implement highlighting of found text during the replace operation. | |
void | replace (const QString &text, int replacementIndex, int replacedLength, int matchedLength, const QRect &expose) |
Connect to this slot to implement updating of replaced text during the replace operation. | |
Public Member Functions | |
KoReplace (const QString &pattern, const QString &replacement, long options, QWidget *parent=0) | |
Will create a prompt dialog and use it as needed. | |
~KoReplace () | |
bool | replace (QString &text, const QRect &expose) |
Walk the text fragment (e.g. | |
virtual bool | validateMatch (const QString &text, int index, int matchedlength) |
void | abort () |
Abort the current find/replace process. | |
Static Public Member Functions | |
int | replace (QString &text, const QString &pattern, const QString &replacement, int index, long options, int *replacedLength) |
Search the given string, and returns whether a match was found. | |
int | replace (QString &text, const QRegExp &pattern, const QString &replacement, int index, long options, int *replacedLength) |
Private Slots | |
void | slotUser1 () |
void | slotUser2 () |
void | slotUser3 () |
void | slotClose () |
Private Member Functions | |
void | doReplace () |
Static Private Member Functions | |
int | replace (QString &text, const QString &replacement, int index, int length) |
Private Attributes | |
QString | m_pattern |
QRegExp * | m_regExp |
QString | m_replacement |
long | m_options |
QWidget * | m_parent |
unsigned | m_replacements |
QString | m_text |
int | m_index |
QRect | m_expose |
int | m_matchedLength |
bool | m_cancelled |
KoReplacePrivate * | d |
Detailed Description
A generic implementation of the "replace" function.
- Author:
- S.R.Haque <srhaque@iee.org>
Example
To use the class to implement a complete replace feature:
// This creates a replace-on-prompt dialog if needed. dialog = new KoReplace(find, replace, options);
// Connect signals to code which handles highlighting // of found text, and on-the-fly replacement. QObject::connect( dialog, SIGNAL( highlight( const QString &, int, int, const QRect & ) ), this, SLOT( highlight( const QString &, int, int, const QRect & ) ) ); QObject::connect( dialog, SIGNAL( replace( const QString &, int, int, const QRect & ) ), this, SLOT( replace( const QString &, int, int, const QRect & ) ) );
for (text chosen by option SelectedText and in a direction set by FindBackwards) { dialog->replace() } delete dialog;
Definition at line 185 of file koReplace.h.
Constructor & Destructor Documentation
|
Will create a prompt dialog and use it as needed.
Definition at line 97 of file koReplace.cpp. References m_cancelled, m_options, m_parent, m_pattern, m_regExp, m_replacement, m_replacements, and KDialogBase::setMainWidget(). |
|
Definition at line 118 of file koReplace.cpp. References KMessageBox::information(), m_parent, and m_replacements. |
Member Function Documentation
|
Abort the current find/replace process. Call this when the parent widget is getting destroyed. Definition at line 130 of file koReplace.cpp. References slotClose(). Referenced by QEditorView::doReplace(). |
|
Definition at line 255 of file koReplace.cpp. References m_expose, m_index, m_matchedLength, m_options, m_replacement, m_replacements, m_text, and replace(). Referenced by replace(), and slotUser3(). |
|
Connect to this slot to implement highlighting of found text during the replace operation.
Referenced by replace(). |
|
Definition at line 214 of file koReplace.cpp. |
|
Connect to this slot to implement updating of replaced text during the replace operation.
|
|
Definition at line 198 of file koReplace.cpp. References KoFind::find(), replace(), and text(). |
|
Search the given string, and returns whether a match was found. If one is, the replacement string length is also returned. A performance optimised version of the function is provided for use with regular expressions.
Definition at line 182 of file koReplace.cpp. References KoFind::find(), replace(), and text(). |
|
Walk the text fragment (e.g. kwrite line, kspread cell) looking for matches. For each match, if prompt-on-replace is specified, emits the expose() signal and displays the prompt-for-replace dialog before doing the replace.
Definition at line 135 of file koReplace.cpp. References doReplace(), KoFind::find(), highlight(), m_expose, m_index, m_matchedLength, m_options, m_pattern, m_regExp, m_text, text(), and validateMatch(). Referenced by doReplace(), QEditorView::process(), replace(), and slotUser1(). |
|
Reimplemented from KDialogBase. Definition at line 124 of file koReplace.cpp. References m_cancelled. Referenced by abort(). |
|
Reimplemented from KDialogBase. Definition at line 222 of file koReplace.cpp. References m_expose, m_index, m_matchedLength, m_options, m_replacement, m_replacements, m_text, and replace(). |
|
Reimplemented from KDialogBase. Definition at line 241 of file koReplace.cpp. |
|
Reimplemented from KDialogBase. Definition at line 249 of file koReplace.cpp. References doReplace(). |
|
Definition at line 43 of file koReplace.cpp. Referenced by replace(). |
Member Data Documentation
|
Definition at line 272 of file koReplace.h. |
|
Definition at line 266 of file koReplace.h. Referenced by KoReplace(), and slotClose(). |
|
Definition at line 264 of file koReplace.h. Referenced by doReplace(), replace(), and slotUser1(). |
|
Definition at line 263 of file koReplace.h. Referenced by doReplace(), replace(), slotUser1(), and slotUser2(). |
|
Definition at line 265 of file koReplace.h. Referenced by doReplace(), replace(), and slotUser1(). |
|
Definition at line 259 of file koReplace.h. Referenced by doReplace(), KoReplace(), replace(), slotUser1(), and slotUser2(). |
|
Definition at line 260 of file koReplace.h. Referenced by KoReplace(), and ~KoReplace(). |
|
Definition at line 256 of file koReplace.h. Referenced by KoReplace(), and replace(). |
|
Definition at line 257 of file koReplace.h. Referenced by KoReplace(), and replace(). |
|
Definition at line 258 of file koReplace.h. Referenced by doReplace(), KoReplace(), and slotUser1(). |
|
Definition at line 261 of file koReplace.h. Referenced by doReplace(), KoReplace(), slotUser1(), and ~KoReplace(). |
|
Definition at line 262 of file koReplace.h. Referenced by doReplace(), replace(), and slotUser1(). |
The documentation for this class was generated from the following files:
- editors/qeditor/koReplace.h
- editors/qeditor/koReplace.cpp