Changeset View
Changeset View
Standalone View
Standalone View
src/search/kateplaintextsearch.cpp
Show All 21 Lines | |||||
22 | //BEGIN includes | 22 | //BEGIN includes | ||
23 | #include "kateplaintextsearch.h" | 23 | #include "kateplaintextsearch.h" | ||
24 | 24 | | |||
25 | #include "kateregexpsearch.h" | 25 | #include "kateregexpsearch.h" | ||
26 | 26 | | |||
27 | #include <ktexteditor/document.h> | 27 | #include <ktexteditor/document.h> | ||
28 | 28 | | |||
29 | #include "katepartdebug.h" | 29 | #include "katepartdebug.h" | ||
30 | | ||||
31 | #include <QRegularExpression> | ||||
30 | //END includes | 32 | //END includes | ||
31 | 33 | | |||
32 | //BEGIN d'tor, c'tor | 34 | //BEGIN d'tor, c'tor | ||
33 | // | 35 | // | ||
34 | // KateSearch Constructor | 36 | // KateSearch Constructor | ||
35 | // | 37 | // | ||
36 | KatePlainTextSearch::KatePlainTextSearch(const KTextEditor::Document *document, Qt::CaseSensitivity caseSensitivity, bool wholeWords) | 38 | KatePlainTextSearch::KatePlainTextSearch(const KTextEditor::Document *document, Qt::CaseSensitivity caseSensitivity, bool wholeWords) | ||
37 | : m_document(document) | 39 | : m_document(document) | ||
Show All 10 Lines | |||||
48 | } | 50 | } | ||
49 | //END | 51 | //END | ||
50 | 52 | | |||
51 | KTextEditor::Range KatePlainTextSearch::search(const QString &text, const KTextEditor::Range &inputRange, bool backwards) | 53 | KTextEditor::Range KatePlainTextSearch::search(const QString &text, const KTextEditor::Range &inputRange, bool backwards) | ||
52 | { | 54 | { | ||
53 | // abuse regex for whole word plaintext search | 55 | // abuse regex for whole word plaintext search | ||
54 | if (m_wholeWords) { | 56 | if (m_wholeWords) { | ||
55 | // escape dot and friends | 57 | // escape dot and friends | ||
56 | const QString workPattern = QStringLiteral("\\b%1\\b").arg(QRegExp::escape(text)); | 58 | const QString workPattern = QStringLiteral("\\b%1\\b").arg(QRegularExpression::escape(text)); | ||
57 | 59 | | |||
58 | return KateRegExpSearch(m_document, m_caseSensitivity).search(workPattern, inputRange, backwards).at(0); | 60 | return KateRegExpSearch(m_document, m_caseSensitivity).search(workPattern, inputRange, backwards).at(0); | ||
59 | } | 61 | } | ||
60 | 62 | | |||
61 | if (text.isEmpty() || !inputRange.isValid() || (inputRange.start() == inputRange.end())) { | 63 | if (text.isEmpty() || !inputRange.isValid() || (inputRange.start() == inputRange.end())) { | ||
62 | return KTextEditor::Range::invalid(); | 64 | return KTextEditor::Range::invalid(); | ||
63 | } | 65 | } | ||
64 | 66 | | |||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |