useractions: Simplify for loops

This commit is contained in:
Alexander Lohnau 2023-10-21 10:17:58 +02:00
parent f842493563
commit 08c3399568

View file

@ -1793,10 +1793,8 @@ void Window::setShortcut(const QString &_cut)
} }
const QRegularExpression reg(QStringLiteral("(.*\\+)\\((.*)\\)")); const QRegularExpression reg(QStringLiteral("(.*\\+)\\((.*)\\)"));
QList<QKeySequence> keys; QList<QKeySequence> keys;
QStringList groups = cut.split(QStringLiteral(" - ")); const QStringList groups = cut.split(QStringLiteral(" - "));
for (QStringList::ConstIterator it = groups.constBegin(); for (auto it = groups.begin(); it != groups.end(); ++it) {
it != groups.constEnd();
++it) {
const QRegularExpressionMatch match = reg.match(*it); const QRegularExpressionMatch match = reg.match(*it);
if (match.hasMatch()) { if (match.hasMatch()) {
const QString base = match.captured(1); const QString base = match.captured(1);
@ -1817,16 +1815,12 @@ void Window::setShortcut(const QString &_cut)
} }
} }
} }
for (auto it = keys.constBegin(); for (auto it = keys.constBegin(); it != keys.cend(); ++it) {
it != keys.constEnd();
++it) {
if (_shortcut == *it) { // current one is in the list if (_shortcut == *it) { // current one is in the list
return; return;
} }
} }
for (auto it = keys.constBegin(); for (auto it = keys.cbegin(); it != keys.cend(); ++it) {
it != keys.constEnd();
++it) {
if (workspace()->shortcutAvailable(*it, this)) { if (workspace()->shortcutAvailable(*it, this)) {
updateShortcut(*it); updateShortcut(*it);
return; return;