diff options
author | Robin Burchell <robin+qt@viroteck.net> | 2012-12-14 18:19:07 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-08 03:17:37 +0100 |
commit | fd4c5b6e1c4ef488e827a1610fd62e1105373a13 (patch) | |
tree | a9abe03a704b749b7b6aa72960a221fb421296ac /src/quick/items/qquickitem.cpp | |
parent | c280d67864dbef12c490380c29e03d5b18c102f1 (diff) |
Deinline QQuickKeysAttached::keyToSignal.
This also means we don't need to expose the SigMap struct or value - it can be
made file-local. This isn't performance-critical, so it shouldn't really matter.
Change-Id: I08d48df4f903df49a6ea58e6f10f3f53a97d89de
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 6668cb72c5..3af378dd84 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -739,7 +739,12 @@ void QQuickKeyNavigationAttached::setFocusNavigation(QQuickItem *currentItem, co while (currentItem != initialItem && isNextItem); } -const QQuickKeysAttached::SigMap QQuickKeysAttached::sigMap[] = { +struct SigMap { + int key; + const char *sig; +}; + +const SigMap sigMap[] = { { Qt::Key_Left, "leftPressed" }, { Qt::Key_Right, "rightPressed" }, { Qt::Key_Up, "upPressed" }, @@ -771,6 +776,21 @@ const QQuickKeysAttached::SigMap QQuickKeysAttached::sigMap[] = { { 0, 0 } }; +const QByteArray QQuickKeysAttached::keyToSignal(int key) +{ + QByteArray keySignal; + if (key >= Qt::Key_0 && key <= Qt::Key_9) { + keySignal = "digit0Pressed"; + keySignal[5] = '0' + (key - Qt::Key_0); + } else { + int i = 0; + while (sigMap[i].key && sigMap[i].key != key) + ++i; + keySignal = sigMap[i].sig; + } + return keySignal; +} + bool QQuickKeysAttached::isConnected(const char *signalName) { Q_D(QQuickKeysAttached); |