<table><tr><td style="">poboiko added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D29318">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
          color: #6B748C;
          font-style: italic;
          margin: 4px 0 12px 0;
          padding: 8px 12px;
          background-color: #F8F9FC;">
<div style="font-style: normal;
          padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D29318#660961" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D29318#660961</a>, <a href="https://phabricator.kde.org/p/dvratil/" style="
              border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@dvratil</a> wrote:</div>
<div style="margin: 0;
          padding: 0;
          border: 0;
          color: rgb(107, 116, 140);"><p>If the code is shared, why not put it into a shared function that both editors can call? As fat as I can see, the function would only need the <tt style="background: #ebebeb; font-size: 13px;">QTextDocument</tt> and the <tt style="background: #ebebeb; font-size: 13px;">mFindWidget</tt> as inputs and would return the number of replacements made, which you can then use to emit the signal.</p></div>
</blockquote>

<p>That's what I've tried to suggest originally:</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>(in principle, to avoid code duplication, we can move this to FindBarBase. We only need to access mView->document(), which depends on the underlying text widget, so we could add a virtual QTextDocument *document() method to FindBarBase and reimplement it)</p></blockquote>

<p>But now as I can see it might be not the best place: it would seem like <tt style="background: #ebebeb; font-size: 13px;">TextEditFindBarBase</tt> is supposed to be as backend-agnostic as possible (not even necessary <tt style="background: #ebebeb; font-size: 13px;">QTextDocument</tt>-based...). Do you have suggestions, where should I put it then?</p>

<p>Actually, there is a larger issue with that: the <tt style="background: #ebebeb; font-size: 13px;">RichTextEditFindBar</tt> and <tt style="background: #ebebeb; font-size: 13px;">PlainTextEditFindBar</tt> classes are completely equivalent (up to naming), not only the added method :(<br />
(that stems from the fact that both <tt style="background: #ebebeb; font-size: 13px;">QTextEdit</tt> and <tt style="background: #ebebeb; font-size: 13px;">QPlainTextEdit</tt> have similar interface: we only use methods <tt style="background: #ebebeb; font-size: 13px;">document</tt>, <tt style="background: #ebebeb; font-size: 13px;">textCursor</tt>, <tt style="background: #ebebeb; font-size: 13px;">moveCursor</tt>, <tt style="background: #ebebeb; font-size: 13px;">setTextCursor</tt>, <tt style="background: #ebebeb; font-size: 13px;">isReadOnly</tt>, <tt style="background: #ebebeb; font-size: 13px;">find</tt>, and they are present in both classes).</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R86 PIM: Text Editor</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D29318">https://phabricator.kde.org/D29318</a></div></div><br /><div><strong>To: </strong>poboiko, mlaurent, dvratil<br /><strong>Cc: </strong>dvratil, kde-pim, fbampaloukas, dcaliste, dvasin, rodsevich, winterz, vkrause, mlaurent, knauss<br /></div>