Changeset View
Changeset View
Standalone View
Standalone View
src/utils/katecommandrangeexpressionparser.cpp
Show All 19 Lines | |||||
20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
21 | * Boston, MA 02110-1301, USA. | 21 | * Boston, MA 02110-1301, USA. | ||
22 | */ | 22 | */ | ||
23 | #include "katecommandrangeexpressionparser.h" | 23 | #include "katecommandrangeexpressionparser.h" | ||
24 | 24 | | |||
25 | #include "kateview.h" | 25 | #include "kateview.h" | ||
26 | #include "katedocument.h" | 26 | #include "katedocument.h" | ||
27 | 27 | | |||
28 | #include <QRegularExpression> | ||||
28 | #include <QStringList> | 29 | #include <QStringList> | ||
29 | 30 | | |||
30 | using KTextEditor::Range; | 31 | using KTextEditor::Range; | ||
31 | using KTextEditor::Cursor; | 32 | using KTextEditor::Cursor; | ||
32 | 33 | | |||
33 | CommandRangeExpressionParser::CommandRangeExpressionParser() | 34 | CommandRangeExpressionParser::CommandRangeExpressionParser() | ||
34 | { | 35 | { | ||
35 | m_line.setPattern(QStringLiteral("\\d+")); | 36 | m_line.setPattern(QStringLiteral("\\d+")); | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 72 | { | |||
110 | return parsedRange; | 111 | return parsedRange; | ||
111 | } | 112 | } | ||
112 | 113 | | |||
113 | int CommandRangeExpressionParser::calculatePosition(const QString &string, KTextEditor::ViewPrivate *view) | 114 | int CommandRangeExpressionParser::calculatePosition(const QString &string, KTextEditor::ViewPrivate *view) | ||
114 | { | 115 | { | ||
115 | 116 | | |||
116 | int pos = 0; | 117 | int pos = 0; | ||
117 | QList<bool> operators_list; | 118 | QList<bool> operators_list; | ||
118 | QStringList split = string.split(QRegExp(QLatin1String("[-+](?!([+-]|$))"))); | 119 | const QStringList split = string.split(QRegularExpression(QStringLiteral("[-+](?!([+-]|$))"))); | ||
mwolff: future: splitRef | |||||
dhaumann: Yes, later... | |||||
119 | QList<int> values; | 120 | QList<int> values; | ||
120 | 121 | | |||
121 | foreach (const QString &line, split) { | 122 | for (const QString &line : split) { | ||
122 | pos += line.size(); | 123 | pos += line.size(); | ||
123 | 124 | | |||
124 | if (pos < string.size()) { | 125 | if (pos < string.size()) { | ||
125 | if (string.at(pos) == QLatin1Char('+')) { | 126 | if (string.at(pos) == QLatin1Char('+')) { | ||
126 | operators_list.push_back(true); | 127 | operators_list.push_back(true); | ||
127 | } else if (string.at(pos) == QLatin1Char('-')) { | 128 | } else if (string.at(pos) == QLatin1Char('-')) { | ||
128 | operators_list.push_back(false); | 129 | operators_list.push_back(false); | ||
129 | } else { | 130 | } else { | ||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |
future: splitRef