Switch to unified view

a/src/qtgui/preview_w.cpp b/src/qtgui/preview_w.cpp
...
...
137
    if (l_cursor.paragraph() == last && l_cursor.atParagEnd())
137
    if (l_cursor.paragraph() == last && l_cursor.atParagEnd())
138
        break;
138
        break;
139
    l_cursor.gotoNextLetter();
139
    l_cursor.gotoNextLetter();
140
    }
140
    }
141
}
141
}
142
143
144
#if (QT_VERSION >= 0x040000)
145
146
// Had to reimplement Qtextdocument::find() by duplicating the qt3
147
// version.  The version in qt4 qt3support was modified for some
148
// unknown reason and exhibits quadratic behaviour, and is totally
149
// unusable on big documents
150
static bool QTextDocument_find(Q3TextDocument *doc, Q3TextCursor& cursor, 
151
                               const QString &expr, bool cs, bool wo, 
152
                               bool forward)
153
{
154
    Qt::CaseSensitivity caseSensitive = cs ? Qt::CaseSensitive : 
155
        Qt::CaseInsensitive;
156
157
    doc->removeSelection(Q3TextDocument::Standard);
158
    Q3TextParagraph *p = 0;
159
    if ( expr.isEmpty() )
160
  return FALSE;
161
    for (;;) {
162
  if ( p != cursor.paragraph() ) {
163
      p = cursor.paragraph();
164
      QString s = cursor.paragraph()->string()->toString();
165
      int start = cursor.index();
166
      for ( ;; ) {
167
      int res = forward ? s.indexOf(expr, start, caseSensitive ) : 
168
                    s.lastIndexOf(expr, start, caseSensitive);
169
      int end = res + expr.length();
170
      if ( res == -1 || ( !forward && start <= res ) )
171
          break;
172
      if (!wo || ((res == 0||s[res - 1].isSpace() || 
173
                             s[res - 1].isPunct()) &&
174
                            (end == (int)s.length() || s[end].isSpace() || 
175
                             s[end].isPunct()))) {
176
          doc->removeSelection(Q3TextDocument::Standard);
177
          cursor.setIndex( forward ? end : res );
178
          doc->setSelectionStart(Q3TextDocument::Standard, cursor);
179
          cursor.setIndex( forward ? res : end );
180
          doc->setSelectionEnd(Q3TextDocument::Standard, cursor);
181
          if ( !forward )
182
          cursor.setIndex( res );
183
          return TRUE;
184
      }
185
      start = res + (forward ? 1 : -1);
186
      }
187
  }
188
  if ( forward ) {
189
      if ( cursor.paragraph() == doc->lastParagraph() && 
190
                 cursor.atParagEnd() )
191
       break;
192
      cursor.gotoNextLetter();
193
  } else {
194
      if ( cursor.paragraph() == doc->firstParagraph() && 
195
                 cursor.atParagStart() )
196
       break;
197
      cursor.gotoPreviousLetter();
198
  }
199
    }
200
    return FALSE;
201
202
}
203
204
bool PreviewTextEdit::find(const QString &expr, bool cs, bool wo,
205
                           bool forward, int *para, int *index)
206
{
207
    drawCursor(false);
208
#ifndef QT_NO_CURSOR
209
    viewport()->setCursor(isReadOnly() ? Qt::ArrowCursor : Qt::IBeamCursor);
210
#endif
211
    Q3TextCursor findcur = *textCursor();
212
    if (para && index) {
213
        if (document()->paragAt(*para))
214
            findcur.gotoPosition(document()->paragAt(*para), *index);
215
        else
216
            findcur.gotoEnd();
217
    } else if (document()->hasSelection(Q3TextDocument::Standard)){
218
        // maks sure we do not find the same selection again
219
        if (forward)
220
            findcur.gotoNextLetter();
221
        else
222
            findcur.gotoPreviousLetter();
223
    } else if (!forward && findcur.index() == 0 && findcur.paragraph() == findcur.topParagraph()) {
224
        findcur.gotoEnd();
225
    }
226
    removeSelection(Q3TextDocument::Standard);
227
    bool found = QTextDocument_find(document(), findcur, expr, cs, wo, forward);
228
    if (found) {
229
        if (para)
230
            *para = findcur.paragraph()->paragId();
231
        if (index)
232
            *index = findcur.index();
233
        *textCursor() = findcur;
234
        repaintChanged();
235
        ensureCursorVisible();
236
    }
237
    drawCursor(true);
238
    if (found) {
239
        emit cursorPositionChanged(textCursor());
240
        emit cursorPositionChanged(textCursor()->paragraph()->paragId(), 
241
                                   textCursor()->index());
242
    }
243
    return found;
244
}
245
246
#endif
142
247
143
void Preview::init()
248
void Preview::init()
144
{
249
{
145
    setName("Preview");
250
    setName("Preview");
146
    setSizePolicy( QSizePolicy((QSizePolicy::SizeType)5, 
251
    setSizePolicy( QSizePolicy((QSizePolicy::SizeType)5,