Changeset View
Changeset View
Standalone View
Standalone View
src/variableeditor/variablelistview.cpp
Show All 16 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "variableeditor.h" | 21 | #include "variableeditor.h" | ||
22 | #include "variablelistview.h" | 22 | #include "variablelistview.h" | ||
23 | #include "variableitem.h" | 23 | #include "variableitem.h" | ||
24 | 24 | | |||
25 | #include <QRegularExpression> | ||||
25 | #include <QResizeEvent> | 26 | #include <QResizeEvent> | ||
26 | 27 | | |||
27 | VariableListView::VariableListView(const QString &variableLine, QWidget *parent) | 28 | VariableListView::VariableListView(const QString &variableLine, QWidget *parent) | ||
28 | : QScrollArea(parent) | 29 | : QScrollArea(parent) | ||
29 | { | 30 | { | ||
30 | setBackgroundRole(QPalette::Base); | 31 | setBackgroundRole(QPalette::Base); | ||
31 | 32 | | |||
32 | setWidget(new QWidget(this)); | 33 | setWidget(new QWidget(this)); | ||
Show All 9 Lines | |||||
42 | { | 43 | { | ||
43 | QString tmp = line.trimmed(); | 44 | QString tmp = line.trimmed(); | ||
44 | if (tmp.startsWith(QLatin1String("kate:"))) { | 45 | if (tmp.startsWith(QLatin1String("kate:"))) { | ||
45 | tmp.remove(0, 5); | 46 | tmp.remove(0, 5); | ||
46 | } | 47 | } | ||
47 | 48 | | |||
48 | QStringList variables = tmp.split(QLatin1Char(';'), QString::SkipEmptyParts); | 49 | QStringList variables = tmp.split(QLatin1Char(';'), QString::SkipEmptyParts); | ||
49 | 50 | | |||
50 | QRegExp sep(QLatin1String("\\s+")); | 51 | const QRegularExpression sep(QStringLiteral("\\s+")); | ||
mwolff: static? | |||||
51 | for (int i = 0; i < variables.size(); ++i) { | 52 | for (int i = 0; i < variables.size(); ++i) { | ||
52 | QStringList pair = variables[i].split(sep, QString::SkipEmptyParts); | 53 | QStringList pair = variables[i].split(sep, QString::SkipEmptyParts); | ||
mwolff: future: splitRef | |||||
53 | if (pair.size() < 2) { | 54 | if (pair.size() < 2) { | ||
54 | continue; | 55 | continue; | ||
55 | } | 56 | } | ||
56 | if (pair.size() > 2) { // e.g. fonts have spaces in the value. Hence, join all value items again | 57 | if (pair.size() > 2) { // e.g. fonts have spaces in the value. Hence, join all value items again | ||
57 | QString key = pair[0]; | 58 | QString key = pair[0]; | ||
58 | pair.removeAt(0); | 59 | pair.removeAt(0); | ||
59 | QString value = pair.join(QLatin1Char(' ')); | 60 | QString value = pair.join(QLatin1Char(' ')); | ||
60 | pair.clear(); | 61 | pair.clear(); | ||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |
static?