diff options
author | Alessandro Portale <alessandro.portale@nokia.com> | 2009-11-06 19:10:12 (GMT) |
---|---|---|
committer | Alessandro Portale <alessandro.portale@nokia.com> | 2009-11-06 19:16:17 (GMT) |
commit | 7ea04bf5c065a037b2db667572e1947f1a1b8b2e (patch) | |
tree | cea44364c37d63012242ddbf98bb32ea8aa9c7ad | |
parent | 676780d515cedca85829ae962e4f501c5e5b6581 (diff) | |
download | Qt-7ea04bf5c065a037b2db667572e1947f1a1b8b2e.zip Qt-7ea04bf5c065a037b2db667572e1947f1a1b8b2e.tar.gz Qt-7ea04bf5c065a037b2db667572e1947f1a1b8b2e.tar.bz2 |
Simplify NavigationModeKeypad cases
Basically, QFileDialog on Desktop performs heavy event handling tweaks
on the lineedit and listview to make them ultra keyboard friendly.
We added many "anti"-hacks for Keypadnavigation to restore the native
behavior of the widgets. The result is pure unmaintainability.
(I admit that most of these "anti"-hacks were my fault, since I
participated in some and reviewed all of them)
This commit has results in the same native behavior for Keypad
navigation but without having the #ifdefs inside the event handling
switches.
Only one of these switch-#ifdefs was there before and still is.
embeddedlinux and wince should still be fine and without unintended
behavioural changes compared to Qt 4.5, since the
Qt::NavigationModeKeypadTabOrder case stays unchanged.
Reviewed-by: axis
Reviewed-by: Sami Merila
modified: src/gui/dialogs/qfiledialog.cpp
-rw-r--r-- | src/gui/dialogs/qfiledialog.cpp | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 6bc6b76..3b1befd 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -3022,12 +3022,6 @@ bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) { case Qt::Key_Escape: q->hide(); return true; -#ifdef QT_KEYPAD_NAVIGATION - case Qt::Key_Down: - case Qt::Key_Up: - return (QApplication::navigationMode() != Qt::NavigationModeKeypadTabOrder - && QApplication::navigationMode() != Qt::NavigationModeKeypadDirectional); -#endif default: break; } @@ -3145,20 +3139,16 @@ QSize QFileDialogListView::sizeHint() const void QFileDialogListView::keyPressEvent(QKeyEvent *e) { - if (!d_ptr->itemViewKeyboardEvent(e)) { - QListView::keyPressEvent(e); - } #ifdef QT_KEYPAD_NAVIGATION - else if ((QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder - || QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) - && !hasEditFocus()) { - e->ignore(); - } else { - e->accept(); + if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { + QListView::keyPressEvent(e); + return; } -#else +#endif // QT_KEYPAD_NAVIGATION + + if (!d_ptr->itemViewKeyboardEvent(e)) + QListView::keyPressEvent(e); e->accept(); -#endif } QFileDialogTreeView::QFileDialogTreeView(QWidget *parent) : QTreeView(parent) @@ -3184,20 +3174,16 @@ void QFileDialogTreeView::init(QFileDialogPrivate *d_pointer) void QFileDialogTreeView::keyPressEvent(QKeyEvent *e) { - if (!d_ptr->itemViewKeyboardEvent(e)) { - QTreeView::keyPressEvent(e); - } #ifdef QT_KEYPAD_NAVIGATION - else if ((QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder - || QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) - && !hasEditFocus()) { - e->ignore(); - } else { - e->accept(); + if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { + QTreeView::keyPressEvent(e); + return; } -#else +#endif // QT_KEYPAD_NAVIGATION + + if (!d_ptr->itemViewKeyboardEvent(e)) + QTreeView::keyPressEvent(e); e->accept(); -#endif } QSize QFileDialogTreeView::sizeHint() const @@ -3213,13 +3199,16 @@ QSize QFileDialogTreeView::sizeHint() const */ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e) { +#ifdef QT_KEYPAD_NAVIGATION + if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { + QLineEdit::keyPressEvent(e); + return; + } +#endif // QT_KEYPAD_NAVIGATION + int key = e->key(); QLineEdit::keyPressEvent(e); - if (key != Qt::Key_Escape -#ifdef QT_KEYPAD_NAVIGATION - && QApplication::navigationMode() == Qt::NavigationModeNone -#endif - ) + if (key != Qt::Key_Escape) e->accept(); if (hideOnEsc && (key == Qt::Key_Escape || key == Qt::Key_Return || key == Qt::Key_Enter)) { e->accept(); |