From fd4c5b6e1c4ef488e827a1610fd62e1105373a13 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 14 Dec 2012 18:19:07 +0100 Subject: 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 --- src/quick/items/qquickitem.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/quick/items/qquickitem.cpp') 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); -- cgit v1.2.3