Changeset View
Changeset View
Standalone View
Standalone View
libdbusmenuqt/dbusmenushortcut_p.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 48 | for (; ptr->zero != nullptr; ++ptr) { | |||
---|---|---|---|---|---|
51 | tokens->replaceInStrings(from, to); | 51 | tokens->replaceInStrings(from, to); | ||
52 | } | 52 | } | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | DBusMenuShortcut DBusMenuShortcut::fromKeySequence(const QKeySequence& sequence) | 55 | DBusMenuShortcut DBusMenuShortcut::fromKeySequence(const QKeySequence& sequence) | ||
56 | { | 56 | { | ||
57 | QString string = sequence.toString(); | 57 | QString string = sequence.toString(); | ||
58 | DBusMenuShortcut shortcut; | 58 | DBusMenuShortcut shortcut; | ||
59 | QStringList tokens = string.split(QStringLiteral(", ")); | 59 | const QStringList tokens = string.split(QStringLiteral(", ")); | ||
60 | Q_FOREACH(QString token, tokens) { | 60 | for (QString token : tokens) { | ||
apol: const &, also this should possibly be transformed into a splitRef. | |||||
nicolasfella: Doesn't work trivially because of the token.replace() below | |||||
61 | // Hack: Qt::CTRL | Qt::Key_Plus is turned into the string "Ctrl++", | 61 | // Hack: Qt::CTRL | Qt::Key_Plus is turned into the string "Ctrl++", | ||
62 | // but we don't want the call to token.split() to consider the | 62 | // but we don't want the call to token.split() to consider the | ||
63 | // second '+' as a separator so we replace it with its final value. | 63 | // second '+' as a separator so we replace it with its final value. | ||
64 | token.replace(QLatin1String("++"), QLatin1String("+plus")); | 64 | token.replace(QLatin1String("++"), QLatin1String("+plus")); | ||
65 | QStringList keyTokens = token.split('+'); | 65 | QStringList keyTokens = token.split('+'); | ||
66 | processKeyTokens(&keyTokens, QT_COLUMN, DM_COLUMN); | 66 | processKeyTokens(&keyTokens, QT_COLUMN, DM_COLUMN); | ||
67 | shortcut << keyTokens; | 67 | shortcut << keyTokens; | ||
68 | } | 68 | } | ||
69 | return shortcut; | 69 | return shortcut; | ||
70 | } | 70 | } | ||
71 | 71 | | |||
72 | QKeySequence DBusMenuShortcut::toKeySequence() const | 72 | QKeySequence DBusMenuShortcut::toKeySequence() const | ||
73 | { | 73 | { | ||
74 | QStringList tmp; | 74 | QStringList tmp; | ||
75 | Q_FOREACH(const QStringList& keyTokens_, *this) { | 75 | for (const QStringList& keyTokens_: qAsConst(*this)) { | ||
apol: this is already const, no?
weirdest foreach in KDE xD 🏅 | |||||
76 | QStringList keyTokens = keyTokens_; | 76 | QStringList keyTokens = keyTokens_; | ||
77 | processKeyTokens(&keyTokens, DM_COLUMN, QT_COLUMN); | 77 | processKeyTokens(&keyTokens, DM_COLUMN, QT_COLUMN); | ||
78 | tmp << keyTokens.join(QLatin1String("+")); | 78 | tmp << keyTokens.join(QLatin1String("+")); | ||
79 | } | 79 | } | ||
80 | QString string = tmp.join(QLatin1String(", ")); | 80 | QString string = tmp.join(QLatin1String(", ")); | ||
81 | return QKeySequence::fromString(string); | 81 | return QKeySequence::fromString(string); | ||
82 | } | 82 | } |
const &, also this should possibly be transformed into a splitRef.