summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2010-02-25 09:28:47 (GMT)
committerJanne Anttila <janne.anttila@digia.com>2010-02-25 11:46:56 (GMT)
commitd8465414e6fd543cfc20e732030dedd8d2bc685f (patch)
tree1075f00a121c2f9de241dc2e561332c7d7ff93db /src/gui/kernel/qwidget.cpp
parent68c909373d96f61f1a06cfb486df320e56b2e75a (diff)
downloadQt-d8465414e6fd543cfc20e732030dedd8d2bc685f.zip
Qt-d8465414e6fd543cfc20e732030dedd8d2bc685f.tar.gz
Qt-d8465414e6fd543cfc20e732030dedd8d2bc685f.tar.bz2
Improvements to itemview keypad navigation in S60.
The logic used in this commit is partially taken from sliders. This commit makes it possible to interact (change row or column) in itemview even itemview does not have editFocus. Interacting without editFocus is enabled when it is not possible to keypad navigate to reuqested direction. In addition if keypad navigation to any direction is not possible (i.e there is only one listwidget on screen), there is no sense to add "done" softkey to get out of edit focus. Task-number: QTBUG-4802 Reviewed-by: Alessandro Portale
Diffstat (limited to 'src/gui/kernel/qwidget.cpp')
-rw-r--r--src/gui/kernel/qwidget.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 850e961..d3340df 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -118,6 +118,10 @@
#include "private/qgraphicssystem_p.h"
#include "private/qgesturemanager_p.h"
+#ifdef QT_KEYPAD_NAVIGATION
+#include "qtabwidget.h" // Needed in inTabWidget()
+#endif // QT_KEYPAD_NAVIGATION
+
// widget/widget data creation count
//#define QWIDGET_EXTRA_DEBUG
//#define ALIEN_DEBUG
@@ -11626,6 +11630,45 @@ QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction)
}
return targetWidget;
}
+
+/*!
+ \internal
+
+ Tells us if it there is currently a reachable widget by keypad navigation in
+ a certain \a orientation.
+ If no navigation is possible, occuring key events in that \a orientation may
+ be used to interact with the value in the focussed widget, even though it
+ currently has not the editFocus.
+
+ \sa QWidgetPrivate::widgetInNavigationDirection(), QWidget::hasEditFocus()
+*/
+bool QWidgetPrivate::canKeypadNavigate(Qt::Orientation orientation)
+{
+ return orientation == Qt::Horizontal?
+ (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast)
+ || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest))
+ :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth)
+ || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth));
+}
+/*!
+ \internal
+
+ Checks, if the \a widget is inside a QTabWidget. If is is inside
+ one, left/right key events will be used to switch between tabs in keypad
+ navigation. If there is no QTabWidget, the horizontal key events can be used
+to
+ interact with the value in the focussed widget, even though it currently has
+ not the editFocus.
+
+ \sa QWidget::hasEditFocus()
+*/
+bool QWidgetPrivate::inTabWidget(QWidget *widget)
+{
+ for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget())
+ if (qobject_cast<const QTabWidget*>(tabWidget))
+ return true;
+ return false;
+}
#endif
/*!