Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 1f9eb832ba1e4b88d9a5c2b384813bb4 > files > 6718

kdelibs3-apidocs-3.5.10-31.fc15.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US">

<head>
  <title>kutils: KReplace Class Reference (kutils)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <meta http-equiv="Content-Style-Type" content="text/css" />

  <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org"  r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org"  r (n 0 s 0 v 0 l 0))' />

  <meta name="trademark" content="KDE e.V." />
  <meta name="description" content="K Desktop Environment Homepage, KDE.org" />
  <meta name="MSSmartTagsPreventParsing" content="true" />
  <meta name="robots" content="all" />

  <link rel="shortcut icon" href="../../favicon.ico" />

<link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" />



</head>

<body>

<div id="nav_header_top" align="right">
  <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a>

  <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a>
  <span class="doNotDisplay">::</span>

  <div id="nav_header_title" align="left">KDE API Reference</div>


</div>

<div id="nav_header_bottom" align="right">
  <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span>
  <div id="nav_header_bottom_right" style="text-align: left;">
/ <a href="../..">API Reference</a>
 / <a href=".">kutils</a>
  </div>
</div>


<table id="main" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
      <td valign="top" class="menuheader" height="0"></td>

  <td id="contentcolumn" valign="top" rowspan="2" >
    <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;">
    <a name="content"></a>


<!-- Generated by Doxygen 1.7.4 -->
</div>
<div class="header">
  <div class="summary">
<a href="#signals">Signals</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#pro-slots">Protected Slots</a>  </div>
  <div class="headertitle">
<div class="title">KReplace Class Reference<div class="ingroups"><a class="el" href="group__main.html">Main classes</a> &#124; <a class="el" href="group__findreplace.html">Find and Replace classes</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="KReplace" --><!-- doxytag: inherits="KFind" -->
<p>A generic implementation of the "replace" function.  
 <a href="classKReplace.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="kreplace_8h_source.html">kreplace.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for KReplace:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classKReplace.png" usemap="#KReplace_map" alt=""/>
  <map id="KReplace_map" name="KReplace_map">
<area href="classKFind.html" title="A generic implementation of the &quot;find&quot; function." alt="KFind" shape="rect" coords="0,56,66,80"/>
<area href="qobject.html" alt="QObject" shape="rect" coords="0,0,66,24"/>
</map>
 </div></div>

<p><a href="classKReplace-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="signals"></a>
Signals</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#afdefd71e9e487ea7292409172eb4430c">replace</a> (const <a class="elRef" href="qstring.html">QString</a> &amp;text, int replacementIndex, int replacedLength, int matchedLength)</td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#a21ecb263e51c6dd319aec0b059abc9a3">KReplace</a> (const <a class="elRef" href="qstring.html">QString</a> &amp;pattern, const <a class="elRef" href="qstring.html">QString</a> &amp;replacement, long options, <a class="elRef" href="qwidget.html">QWidget</a> *<a class="elRef" href="qobject.html#parent">parent</a>=0)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#a9d751c132f43866225f854e3d14e5632">KReplace</a> (const <a class="elRef" href="qstring.html">QString</a> &amp;pattern, const <a class="elRef" href="qstring.html">QString</a> &amp;replacement, long options, <a class="elRef" href="qwidget.html">QWidget</a> *<a class="elRef" href="qobject.html#parent">parent</a>, <a class="elRef" href="qwidget.html">QWidget</a> *replaceDialog)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#ae1867c23a1a814d7a341ccdb203eb141">~KReplace</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#ad8d728e77616b2e0554d4d1390f1afb0">numReplacements</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#a9a17ef8077940fe22bc4596308e3b513">resetCounts</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classKFind.html#a40a6b946c7c572127a8bc03f0983086f">Result</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#abcdf792c73f9971964db69a90a36c030">replace</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="kdeui.tag:../../kdeui/html/" href="../../kdeui/html/classKDialogBase.html">KDialogBase</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#a7145c5261063c8e789da58062c7ceb11">replaceNextDialog</a> (bool create=false)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#ac7c64ccb2e4a416507774ed8d6781cfe">closeReplaceNextDialog</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#a7988a0b910f65e972ef7d12c8a538f01">shouldRestart</a> (bool forceAsking=false, bool showNumMatches=true) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#a97ff667380c4adb8916bd0cbcf96f512">displayFinalDialog</a> () const </td></tr>
<tr><td colspan="2"><h2><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#a82a378409efe5dcc3e06a0a46c8bcf5e">replace</a> (<a class="elRef" href="qstring.html">QString</a> &amp;text, const <a class="elRef" href="qstring.html">QString</a> &amp;pattern, const <a class="elRef" href="qstring.html">QString</a> &amp;replacement, int index, long options, int *replacedLength)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classKReplace.html#a3071bff758152292c517b49496353069">replace</a> (<a class="elRef" href="qstring.html">QString</a> &amp;text, const <a class="elRef" href="qregexp.html">QRegExp</a> &amp;pattern, const <a class="elRef" href="qstring.html">QString</a> &amp;replacement, int index, long options, int *replacedLength)</td></tr>
<tr><td colspan="2"><h2><a name="pro-slots"></a>
Protected Slots</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a74e5439d742312ea4bb53578dd61e2fb"></a><!-- doxytag: member="KReplace::slotSkip" ref="a74e5439d742312ea4bb53578dd61e2fb" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>slotSkip</b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a061977e0f0c60369a5f2e7465e86b84a"></a><!-- doxytag: member="KReplace::slotReplace" ref="a061977e0f0c60369a5f2e7465e86b84a" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>slotReplace</b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7bfc3484ac99173cf85ee89532cc8f10"></a><!-- doxytag: member="KReplace::slotReplaceAll" ref="a7bfc3484ac99173cf85ee89532cc8f10" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>slotReplaceAll</b> ()</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>A generic implementation of the "replace" function. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>S.R.Haque &lt;<a href="mailto:srhaque@iee.org">srhaque@iee.org</a>&gt;, David Faure &lt;<a href="mailto:faure@kde.org">faure@kde.org</a>&gt;</dd></dl>
<p><b>Detail:</b> </p>
<p>This class includes prompt handling etc. Also provides some static functions which can be used to create custom behavior instead of using the class directly.</p>
<p><b>Example:</b> </p>
<p>To use the class to implement a complete replace feature:</p>
<p>In the slot connect to the replace action, after using <a class="el" href="classKReplaceDialog.html" title="A generic &quot;replace&quot; dialog.">KReplaceDialog</a>: </p>
<div class="fragment"><pre class="fragment">  <span class="comment">// This creates a replace-on-prompt dialog if needed.</span>
  m_replace = <span class="keyword">new</span> <a class="code" href="classKReplace.html#a21ecb263e51c6dd319aec0b059abc9a3" title="Only use this constructor if you don&#39;t use KFindDialog, or if you use it as a modal dialog...">KReplace</a>(<a class="code" href="classKFind.html#a56d66f34345ae798fc561ad13336a779">pattern</a>, replacement, <a class="code" href="classKFind.html#a5aac4ccbdf73d8ee87c332f7e41484c2" title="Return the current options.">options</a>, <span class="keyword">this</span>);

  <span class="comment">// Connect signals to code which handles highlighting</span>
  <span class="comment">// of found text, and on-the-fly replacement.</span>
  <a class="codeRef" href="qobject.html#connect">connect</a>( m_replace, SIGNAL( <a class="code" href="classKFind.html#af66e494430aa005f66f08052ed82b0e9" title="Connect to this signal to implement highlighting of found text during the find operation.">highlight</a>( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &amp;, <span class="keywordtype">int</span>, <span class="keywordtype">int</span> ) ),
          <span class="keyword">this</span>, SLOT( slotHighlight( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &amp;, <span class="keywordtype">int</span>, <span class="keywordtype">int</span> ) ) );
  <span class="comment">// Connect findNext signal - called when pressing the button in the dialog</span>
  <a class="codeRef" href="qobject.html#connect">connect</a>( m_replace, SIGNAL( findNext() ),
          <span class="keyword">this</span>, SLOT( slotReplaceNext() ) );
  <span class="comment">// Connect replace signal - called when doing a replacement</span>
  <a class="codeRef" href="qobject.html#connect">connect</a>( m_replace, SIGNAL( <a class="code" href="classKReplace.html#abcdf792c73f9971964db69a90a36c030" title="Walk the text fragment (e.g.">replace</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &amp;, <span class="keywordtype">int</span>, <span class="keywordtype">int</span>, <span class="keywordtype">int</span>) ),
          <span class="keyword">this</span>, SLOT( slotReplace(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &amp;, <span class="keywordtype">int</span>, <span class="keywordtype">int</span>, <span class="keywordtype">int</span>) ) );
</pre></div><p> Then initialize the variables determining the "current position" (to the cursor, if the option FromCursor is set, to the beginning of the selection if the option SelectedText is set, and to the beginning of the document otherwise). Initialize the "end of search" variables as well (end of doc or end of selection). Swap begin and end if FindBackwards. Finally, call slotReplaceNext();</p>
<div class="fragment"><pre class="fragment">  <span class="keywordtype">void</span> slotReplaceNext()
  {
      <a class="code" href="classKFind.html#a40a6b946c7c572127a8bc03f0983086f" title="Result enum.">KFind::Result</a> res = <a class="code" href="classKFind.html#a40a6b946c7c572127a8bc03f0983086faba61fbb9416d27f4ca375335f6aadf5a" title="No match was found.">KFind::NoMatch</a>;
      <span class="keywordflow">while</span> ( res == <a class="code" href="classKFind.html#a40a6b946c7c572127a8bc03f0983086faba61fbb9416d27f4ca375335f6aadf5a" title="No match was found.">KFind::NoMatch</a> &amp;&amp; &lt;position not at end&gt; ) {
          <span class="keywordflow">if</span> ( m_replace-&gt;needData() )
              m_replace-&gt;setData( &lt;current text fragment&gt; );

          <span class="comment">// Let KReplace inspect the text fragment, and display a dialog if a match is found</span>
          res = m_replace-&gt;replace();

          <span class="keywordflow">if</span> ( res == <a class="code" href="classKFind.html#a40a6b946c7c572127a8bc03f0983086faba61fbb9416d27f4ca375335f6aadf5a" title="No match was found.">KFind::NoMatch</a> ) {
              &lt;Move to the <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/namespaceKStdAccel.html#a3c93cec83afd9c54d443fe78a9899502">next</a> text fragment, honoring the FindBackwards setting <span class="keywordflow">for</span> the direction&gt;
          }
      }

      <span class="keywordflow">if</span> ( res == <a class="code" href="classKFind.html#a40a6b946c7c572127a8bc03f0983086faba61fbb9416d27f4ca375335f6aadf5a" title="No match was found.">KFind::NoMatch</a> ) <span class="comment">// i.e. at end</span>
          &lt;Call either  m_replace-&gt;displayFinalDialog(); <span class="keyword">delete</span> m_replace; m_replace = 0L;
           or           <span class="keywordflow">if</span> ( m_replace-&gt;shouldRestart() ) { reinit (w/o FromCursor) and call slotReplaceNext(); }
                        <span class="keywordflow">else</span> { m_replace-&gt;closeReplaceNextDialog(); }&gt;
  }
</pre></div><p>Don't forget delete m_find in the destructor of your class, unless you gave it a parent widget on construction. </p>

<p>Definition at line <a class="el" href="kreplace_8h_source.html#l00097">97</a> of file <a class="el" href="kreplace_8h_source.html">kreplace.h</a>.</p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a21ecb263e51c6dd319aec0b059abc9a3"></a><!-- doxytag: member="KReplace::KReplace" ref="a21ecb263e51c6dd319aec0b059abc9a3" args="(const QString &amp;pattern, const QString &amp;replacement, long options, QWidget *parent=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">KReplace::KReplace </td>
          <td>(</td>
          <td class="paramtype">const <a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>pattern</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>replacement</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long&#160;</td>
          <td class="paramname"><em>options</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="elRef" href="qwidget.html">QWidget</a> *&#160;</td>
          <td class="paramname"><em>parent</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Only use this constructor if you don't use <a class="el" href="classKFindDialog.html" title="A generic &quot;find&quot; dialog.">KFindDialog</a>, or if you use it as a modal dialog. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">pattern</td><td>The pattern to look for. </td></tr>
    <tr><td class="paramname">replacement</td><td>The replacement string. </td></tr>
    <tr><td class="paramname">options</td><td>Options for the find dialog. </td></tr>
  </table>
  </dd>
</dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classKFindDialog.html" title="A generic &quot;find&quot; dialog.">KFindDialog</a> and <a class="el" href="classKReplaceDialog.html" title="A generic &quot;replace&quot; dialog.">KReplaceDialog</a>. </dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">parent</td><td>The parent widget. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00063">63</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a9d751c132f43866225f854e3d14e5632"></a><!-- doxytag: member="KReplace::KReplace" ref="a9d751c132f43866225f854e3d14e5632" args="(const QString &amp;pattern, const QString &amp;replacement, long options, QWidget *parent, QWidget *replaceDialog)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">KReplace::KReplace </td>
          <td>(</td>
          <td class="paramtype">const <a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>pattern</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>replacement</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long&#160;</td>
          <td class="paramname"><em>options</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="elRef" href="qwidget.html">QWidget</a> *&#160;</td>
          <td class="paramname"><em>parent</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="elRef" href="qwidget.html">QWidget</a> *&#160;</td>
          <td class="paramname"><em>replaceDialog</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>This is the recommended constructor if you also use <a class="el" href="classKReplaceDialog.html" title="A generic &quot;replace&quot; dialog.">KReplaceDialog</a> (non-modal). </p>
<p>You should pass the pointer to it here, so that when a message box appears it has the right parent. Don't worry about deletion, <a class="el" href="classKReplace.html" title="A generic implementation of the &quot;replace&quot; function.">KReplace</a> will notice if the find dialog is closed. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">pattern</td><td>The pattern to look for. </td></tr>
    <tr><td class="paramname">replacement</td><td>The replacement string. </td></tr>
    <tr><td class="paramname">options</td><td>Options for the find dialog. </td></tr>
  </table>
  </dd>
</dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classKFindDialog.html" title="A generic &quot;find&quot; dialog.">KFindDialog</a> and <a class="el" href="classKReplaceDialog.html" title="A generic &quot;replace&quot; dialog.">KReplaceDialog</a>. </dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">parent</td><td>The parent widget. </td></tr>
    <tr><td class="paramname">replaceDialog</td><td>A pointer to the <a class="el" href="classKReplaceDialog.html" title="A generic &quot;replace&quot; dialog.">KReplaceDialog</a> object. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00070">70</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="ae1867c23a1a814d7a341ccdb203eb141"></a><!-- doxytag: member="KReplace::~KReplace" ref="ae1867c23a1a814d7a341ccdb203eb141" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">KReplace::~KReplace </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Destructor. </p>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00077">77</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="ac7c64ccb2e4a416507774ed8d6781cfe"></a><!-- doxytag: member="KReplace::closeReplaceNextDialog" ref="ac7c64ccb2e4a416507774ed8d6781cfe" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KReplace::closeReplaceNextDialog </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Close the "replace next?" dialog. </p>
<p>The application should do this when the last match was hit. If the application deletes the <a class="el" href="classKReplace.html" title="A generic implementation of the &quot;replace&quot; function.">KReplace</a>, then "find previous" won't be possible anymore. </p>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00323">323</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a97ff667380c4adb8916bd0cbcf96f512"></a><!-- doxytag: member="KReplace::displayFinalDialog" ref="a97ff667380c4adb8916bd0cbcf96f512" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KReplace::displayFinalDialog </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Displays the final dialog telling the user how many replacements were made. </p>
<p>Call either this or <a class="el" href="classKReplace.html#a7988a0b910f65e972ef7d12c8a538f01" title="Returns true if we should restart the search from scratch.">shouldRestart()</a>. </p>

<p>Reimplemented from <a class="el" href="classKFind.html#afe38e946ffcdbfcc60597bd80e5dd032">KFind</a>.</p>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00102">102</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="ad8d728e77616b2e0554d4d1390f1afb0"></a><!-- doxytag: member="KReplace::numReplacements" ref="ad8d728e77616b2e0554d4d1390f1afb0" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int KReplace::numReplacements </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Return the number of replacements made (i.e. </p>
<p>the number of times the replace signal was emitted). Can be used in a dialog box to tell the user how many replacements were made. The final dialog does so already, unless you used setDisplayFinalDialog(false). </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>The number of replacements. </dd></dl>

<p>Definition at line <a class="el" href="kreplace_8h_source.html#l00138">138</a> of file <a class="el" href="kreplace_8h_source.html">kreplace.h</a>.</p>

</div>
</div>
<a class="anchor" id="afdefd71e9e487ea7292409172eb4430c"></a><!-- doxytag: member="KReplace::replace" ref="afdefd71e9e487ea7292409172eb4430c" args="(const QString &amp;text, int replacementIndex, int replacedLength, int matchedLength)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KReplace::replace </td>
          <td>(</td>
          <td class="paramtype">const <a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>text</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>replacementIndex</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>replacedLength</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>matchedLength</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [signal]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Connect to this slot to implement updating of replaced text during the replace operation. </p>
<p>Extra care must be taken to properly implement the "no prompt-on-replace" case. For instance highlight isn't emitted in that case (some code might rely on it), and for performance reasons one should repaint after <a class="el" href="classKReplace.html#abcdf792c73f9971964db69a90a36c030" title="Walk the text fragment (e.g.">replace()</a> ONLY if prompt-on-replace was selected.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">text</td><td>The text, in which the replacement has already been done. </td></tr>
    <tr><td class="paramname">replacementIndex</td><td>Starting index of the matched substring </td></tr>
    <tr><td class="paramname">replacedLength</td><td>Length of the replacement string </td></tr>
    <tr><td class="paramname">matchedLength</td><td>Length of the matched string </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="abcdf792c73f9971964db69a90a36c030"></a><!-- doxytag: member="KReplace::replace" ref="abcdf792c73f9971964db69a90a36c030" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classKFind.html#a40a6b946c7c572127a8bc03f0983086f">KFind::Result</a> KReplace::replace </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Walk the text fragment (e.g. </p>
<p>kwrite line, kspread cell) looking for matches. For each match, if prompt-on-replace is specified, emits the <a class="el" href="classKFind.html#af66e494430aa005f66f08052ed82b0e9" title="Connect to this signal to implement highlighting of found text during the find operation.">highlight()</a> signal and displays the prompt-for-replace dialog before doing the replace. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>Whether or not there has been a match. </dd></dl>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00110">110</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a82a378409efe5dcc3e06a0a46c8bcf5e"></a><!-- doxytag: member="KReplace::replace" ref="a82a378409efe5dcc3e06a0a46c8bcf5e" args="(QString &amp;text, const QString &amp;pattern, const QString &amp;replacement, int index, long options, int *replacedLength)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int KReplace::replace </td>
          <td>(</td>
          <td class="paramtype"><a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>text</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>pattern</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>replacement</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>index</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long&#160;</td>
          <td class="paramname"><em>options</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>replacedLength</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Searches the given string, replaces with the given replacement string, and returns whether a match was found. </p>
<p>If one is, the replacement string length is also returned.</p>
<p>A performance optimised version of the function is provided for use with regular expressions.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">text</td><td>The string to search. </td></tr>
    <tr><td class="paramname">pattern</td><td>The pattern to look for. </td></tr>
    <tr><td class="paramname">replacement</td><td>The replacement string to insert into the text. </td></tr>
    <tr><td class="paramname">index</td><td>The starting index into the string. </td></tr>
    <tr><td class="paramname">options</td><td>The options to use. </td></tr>
    <tr><td class="paramname">replacedLength</td><td>Output parameter, contains the length of the replaced string. Not always the same as replacement.length(), when backreferences are used. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The index at which a match was found, or -1 if no match was found. </dd></dl>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00180">180</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a3071bff758152292c517b49496353069"></a><!-- doxytag: member="KReplace::replace" ref="a3071bff758152292c517b49496353069" args="(QString &amp;text, const QRegExp &amp;pattern, const QString &amp;replacement, int index, long options, int *replacedLength)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int KReplace::replace </td>
          <td>(</td>
          <td class="paramtype"><a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>text</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="elRef" href="qregexp.html">QRegExp</a> &amp;&#160;</td>
          <td class="paramname"><em>pattern</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="elRef" href="qstring.html">QString</a> &amp;&#160;</td>
          <td class="paramname"><em>replacement</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>index</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long&#160;</td>
          <td class="paramname"><em>options</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>replacedLength</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Searches the given regular expression, replaces with the given replacement string, and returns whether a match was found. </p>
<p>If one is, the replacement string length is also returned.</p>
<p>Another version of the function is provided for use with strings.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">text</td><td>The string to search. </td></tr>
    <tr><td class="paramname">pattern</td><td>The regular expression pattern to look for. </td></tr>
    <tr><td class="paramname">replacement</td><td>The replacement string to insert into the text. </td></tr>
    <tr><td class="paramname">index</td><td>The starting index into the string. </td></tr>
    <tr><td class="paramname">options</td><td>The options to use. </td></tr>
    <tr><td class="paramname">replacedLength</td><td>Output parameter, contains the length of the replaced string. Not always the same as replacement.length(), when backreferences are used. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The index at which a match was found, or -1 if no match was found. </dd></dl>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00196">196</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a7145c5261063c8e789da58062c7ceb11"></a><!-- doxytag: member="KReplace::replaceNextDialog" ref="a7145c5261063c8e789da58062c7ceb11" args="(bool create=false)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="elRef" doxygen="kdeui.tag:../../kdeui/html/" href="../../kdeui/html/classKDialogBase.html">KDialogBase</a> * KReplace::replaceNextDialog </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>create</em> = <code>false</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Return (or create) the dialog that shows the "find next?" prompt. </p>
<p>Usually you don't need to call this. One case where it can be useful, is when the user selects the "Find" menu item while a find operation is under way. In that case, the program may want to call setActiveWindow() on that dialog. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>The replace next dialog. </dd></dl>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00082">82</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a9a17ef8077940fe22bc4596308e3b513"></a><!-- doxytag: member="KReplace::resetCounts" ref="a9a17ef8077940fe22bc4596308e3b513" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void KReplace::resetCounts </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Call this to reset the numMatches &amp; numReplacements counts. </p>
<p>Can be useful if reusing the same <a class="el" href="classKReplace.html" title="A generic implementation of the &quot;replace&quot; function.">KReplace</a> for different operations, or when restarting from the beginning of the document. </p>

<p>Reimplemented from <a class="el" href="classKFind.html#afb374c90fc8ee5c1f21f84d934b0df35">KFind</a>.</p>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00278">278</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a7988a0b910f65e972ef7d12c8a538f01"></a><!-- doxytag: member="KReplace::shouldRestart" ref="a7988a0b910f65e972ef7d12c8a538f01" args="(bool forceAsking=false, bool showNumMatches=true) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool KReplace::shouldRestart </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>forceAsking</em> = <code>false</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>showNumMatches</em> = <code>true</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns <code>true</code> if we should restart the search from scratch. </p>
<p>Can ask the user, or return <code>false</code> (if we already searched/replaced the whole document without the PromptOnReplace option).</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">forceAsking</td><td>set to <code>true</code> if the user modified the document during the search. In that case it makes sense to restart the search again.</td></tr>
    <tr><td class="paramname">showNumMatches</td><td>set to <code>true</code> if the dialog should show the number of matches. Set to <code>false</code> if the application provides a "find previous" action, in which case the match count will be erroneous when hitting the end, and we could even be hitting the beginning of the document (so not all matches have even been seen).</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd><code>true</code>, if the search should be restarted. </dd></dl>

<p>Reimplemented from <a class="el" href="classKFind.html#a0cdf16a51c2ddd48d647ef20faf4c5a8">KFind</a>.</p>

<p>Definition at line <a class="el" href="kreplace_8cpp_source.html#l00284">284</a> of file <a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="kreplace_8h_source.html">kreplace.h</a></li>
<li><a class="el" href="kreplace_8cpp_source.html">kreplace.cpp</a></li>
</ul>
</div>
    </div></div>


      </td>
  </tr>
  <tr>
    <td valign="top" id="leftmenu" width="25%">
      <a name="navigation"></a>
      <div class="menu_box"><h2>kutils</h2>
<div class="nav_list">
<ul><li><a href="index.html">Main Page</a></li><li><a href="modules.html">Modules</a></li><li><a href="namespaces.html">Namespace List</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="functions.html">Class Members</a></li><li><a href="pages.html">Related Pages</a></li></ul>
<!--
<h2>Class Picker</h2>
<div style="text-align: center;">
<form name="guideform">
<select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value">
<option value="annotated.html">-- Choose --</option>
  <option value="classKCModuleContainer.html">kcmodulecontainer</option>,  <option value="classKCModuleInfo.html">kcmoduleinfo</option>,  <option value="classKCModuleLoader.html">kcmoduleloader</option>,  <option value="classKCModuleProxy.html">kcmoduleproxy</option>,  <option value="classKCModuleProxyIface.html">kcmoduleproxyiface</option>,  <option value="classKCModuleProxyRootDispatcher.html">kcmoduleproxyrootdispatcher</option>,  <option value="classKCMultiDialog.html">kcmultidialog</option>,  <option value="classKFind.html">kfind</option>,  <option value="classKFindDialog.html">kfinddialog</option>,  <option value="classKMultiTabBar.html">kmultitabbar</option>,  <option value="classKMultiTabBarButton.html">kmultitabbarbutton</option>,  <option value="classKMultiTabBarTab.html">kmultitabbartab</option>,  <option value="classKPluginInfo.html">kplugininfo</option>,  <option value="classKPluginSelector.html">kpluginselector</option>,  <option value="classKReplace.html">kreplace</option>,  <option value="classKReplaceDialog.html">kreplacedialog</option>,  <option value="classKSettings_1_1ComponentsDialog.html">ksettings::componentsdialog</option>,  <option value="classKSettings_1_1Dialog.html">ksettings::dialog</option>,  <option value="classKSettings_1_1Dispatcher.html">ksettings::dispatcher</option>,  <option value="classKSettings_1_1PluginPage.html">ksettings::pluginpage</option>,
</select>
</form>
</div>
-->
</div></div>
<div class="menu_box"><h2>API Dox</h2>
<div class="nav_list">
<ul>
<li><a href="../../arts/html/index.html">arts</a></li><li><a href="../../dcop/html/index.html">dcop</a></li><li><a href="../../dnssd/html/index.html">dnssd</a></li><li><a href="../../interfaces/html/index.html">interfaces</a></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../interfaces/kimproxy/interface/html/index.html">interface</a></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../interfaces/kimproxy/library/html/index.html">library</a></li><li>&nbsp;&nbsp;<a href="../../interfaces/kspeech/html/index.html">kspeech</a></li><li>&nbsp;&nbsp;<a href="../../interfaces/ktexteditor/html/index.html">ktexteditor</a></li><li><a href="../../kabc/html/index.html">kabc</a></li><li><a href="../../kate/html/index.html">kate</a></li><li><a href="../../kcmshell/html/index.html">kcmshell</a></li><li><a href="../../kdecore/html/index.html">kdecore</a></li><li><a href="../../kded/html/index.html">kded</a></li><li><a href="../../kdefx/html/index.html">kdefx</a></li><li><a href="../../kdeprint/html/index.html">kdeprint</a></li><li><a href="../../kdesu/html/index.html">kdesu</a></li><li><a href="../../kdeui/html/index.html">kdeui</a></li><li><a href="../../kdoctools/html/index.html">kdoctools</a></li><li><a href="../../khtml/html/index.html">khtml</a></li><li><a href="../../kimgio/html/index.html">kimgio</a></li><li><a href="../../kinit/html/index.html">kinit</a></li><li><a href="../../kio/html/index.html">kio</a></li><li>&nbsp;&nbsp;<a href="../../kio/bookmarks/html/index.html">bookmarks</a></li><li>&nbsp;&nbsp;<a href="../../kio/httpfilter/html/index.html">httpfilter</a></li><li>&nbsp;&nbsp;<a href="../../kio/kfile/html/index.html">kfile</a></li><li>&nbsp;&nbsp;<a href="../../kio/kio/html/index.html">kio</a></li><li>&nbsp;&nbsp;<a href="../../kio/kioexec/html/index.html">kioexec</a></li><li>&nbsp;&nbsp;<a href="../../kio/kpasswdserver/html/index.html">kpasswdserver</a></li><li>&nbsp;&nbsp;<a href="../../kio/kssl/html/index.html">kssl</a></li><li><a href="../../kioslave/html/index.html">kioslave</a></li><li>&nbsp;&nbsp;<a href="../../kioslave/http/html/index.html">http</a></li><li><a href="../../kjs/html/index.html">kjs</a></li><li><a href="../../kmdi/html/index.html">kmdi</a></li><li>&nbsp;&nbsp;<a href="../../kmdi/kmdi/html/index.html">kmdi</a></li><li><a href="../../knewstuff/html/index.html">knewstuff</a></li><li><a href="../../kparts/html/index.html">kparts</a></li><li><a href="../../kresources/html/index.html">kresources</a></li><li><a href="../../kspell2/html/index.html">kspell2</a></li><li><a href="../../kunittest/html/index.html">kunittest</a></li><li><a href="../../kutils/html/index.html">kutils</a></li><li><a href="../../kwallet/html/index.html">kwallet</a></li><li><a href="../../libkmid/html/index.html">libkmid</a></li><li><a href="../../libkscreensaver/html/index.html">libkscreensaver</a></li>
</ul></div></div>


        </td>
</tr>
</table>

<span class="doNotDisplay">
  <a href="http://www.kde.org/" accesskey="8">KDE Home</a> |
  <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> |
  <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a>
</span>


<div style="height: 8px"></div>

<div id="footer">
  <div id="footer_left">
    Maintained by <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;groo&#116;&#64;kde&#46;or&#x67;">Adriaan de Groot</a>
and
<a href="&#109;a&#105;&#108;&#116;&#111;&#58;w&#105;nter&#64;kde&#46;or&#x67">Allen Winter</a>.
<br/>
    KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> |
    <a href="http://www.kde.org/contact/impressum.php">Legal</a>
  </div>
  <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div>
</div>

<!--
WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL
BE BLOCKED INSTANTLY AND PERMANENTLY!
<a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a>
WARNING END
-->

</body>
</html>