diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-10-10 17:52:21 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-16 17:31:31 +0200 |
commit | fb21212f1eeddb9e2f13b7d5b0b4f48147f05412 (patch) | |
tree | 0261c8f34131d1a499879d16b453180a9cded1ca /src | |
parent | 78f946f6dc23185e86d7a59e703cd8b3b6ee0e39 (diff) |
QWindowsKeyMapper: replace one magic constant with a symbolic one
Replace occurrences of a literal 9 that mean 'number of modifier key
combinations' with the new symbolic constant NumMods.
Change-Id: I1e78a1a3c00b81095450ec0557e30751da44c39a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/windows/qwindowskeymapper.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index b57a27acb4..fff7b848b8 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -436,6 +436,7 @@ static const Qt::KeyboardModifiers ModsTbl[] = { Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier, // 7 Qt::NoModifier, // Fall-back to raw Key_* }; +static const size_t NumMods = sizeof ModsTbl / sizeof *ModsTbl; /** Remap return or action key to select key for windows mobile. @@ -535,7 +536,7 @@ static inline bool isModifierKey(int code) struct KeyboardLayoutItem { bool dirty; quint8 deadkeys; - quint32 qtKey[9]; // Can by any Qt::Key_<foo>, or unicode character + quint32 qtKey[NumMods]; // Can by any Qt::Key_<foo>, or unicode character }; void QWindowsKeyMapper::deleteLayouts() @@ -666,8 +667,8 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 if (QWindowsContext::verboseEvents > 1) { qDebug("updatePossibleKeyCodes for virtual key = 0x%02x!", vk_key); - for (int i = 0; i < 9; ++i) { - qDebug(" [%d] (%d,0x%02x,'%c') %s", i, + for (size_t i = 0; i < NumMods; ++i) { + qDebug(" [%d] (%d,0x%02x,'%c') %s", int(i), keyLayout[vk_key]->qtKey[i], keyLayout[vk_key]->qtKey[i], keyLayout[vk_key]->qtKey[i] ? keyLayout[vk_key]->qtKey[i] : 0x03, @@ -679,7 +680,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 bool QWindowsKeyMapper::isADeadKey(unsigned int vk_key, unsigned int modifiers) { if (keyLayout && (vk_key < 256) && keyLayout[vk_key]) { - for (register int i = 0; i < 9; ++i) { + for (register size_t i = 0; i < NumMods; ++i) { if (uint(ModsTbl[i]) == modifiers) return bool(keyLayout[vk_key]->deadkeys & 1<<i); } @@ -1135,7 +1136,7 @@ QList<int> QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const } result << int(baseKey + keyMods); // The base key is _always_ valid, of course - for (int i = 1; i < 9; ++i) { + for (int i = 1; i < NumMods; ++i) { Qt::KeyboardModifiers neededMods = ModsTbl[i]; quint32 key = kbItem->qtKey[i]; if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) |