diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-16 17:43:54 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-05-17 19:20:05 +0000 |
commit | 21e0cb7a42bd4f5f7173a93971217271245efde6 (patch) | |
tree | 6608c9326b0bf54dfa17fde7ac18e1749ebc91b9 /src/gui/kernel/qkeysequence.cpp | |
parent | 22ae4ba3b716eb7c19d827500dbece5965f62c25 (diff) |
QKeySequence/Mac: remove NumEntries variable
Keep it DRY. Just let the compiler figure out the size.
Pick-to: 6.3 6.2
Change-Id: I2bf1c44d4e2060a9398700d16ab98d67c849814c
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/gui/kernel/qkeysequence.cpp')
-rw-r--r-- | src/gui/kernel/qkeysequence.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 5e5b5d4eee..6f0479b0d3 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -59,7 +59,6 @@ static const MacSpecialKey entries[] = { { Qt::Key_Alt, kOptionUnicode }, { Qt::Key_CapsLock, 0x21EA }, }; -static const int NumEntries = std::size(entries); static bool operator<(const MacSpecialKey &entry, int key) { @@ -71,12 +70,11 @@ static bool operator<(int key, const MacSpecialKey &entry) return key < entry.key; } -static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntries; QChar qt_macSymbolForQtKey(int key) { - const MacSpecialKey *i = std::lower_bound(entries, MacSpecialKeyEntriesEnd, key); - if ((i == MacSpecialKeyEntriesEnd) || (key < *i)) + const auto i = std::lower_bound(std::begin(entries), std::end(entries), key); + if (i == std::end(entries) || key < *i) return QChar(); ushort macSymbol = i->macSymbol; if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta) @@ -93,8 +91,7 @@ QChar qt_macSymbolForQtKey(int key) static int qtkeyForMacSymbol(const QChar ch) { const ushort unicode = ch.unicode(); - for (int i = 0; i < NumEntries; ++i) { - const MacSpecialKey &entry = entries[i]; + for (const MacSpecialKey &entry : entries) { if (entry.macSymbol == unicode) { int key = entry.key; if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta) |