diff options
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 7 | ||||
-rw-r--r-- | src/gui/itemviews/qabstractitemview_p.h | 1 | ||||
-rw-r--r-- | src/gui/itemviews/qtreeview.cpp | 12 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 3738816..fc53ea3 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -104,7 +104,8 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() horizontalScrollMode(QAbstractItemView::ScrollPerItem), currentIndexSet(false), wrapItemText(false), - delayedPendingLayout(false) + delayedPendingLayout(false), + moveCursorUpdatedView(false) { } @@ -2210,6 +2211,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) #endif QPersistentModelIndex newCurrent; + d->moveCursorUpdatedView = false; switch (event->key()) { case Qt::Key_Down: newCurrent = moveCursor(MoveDown, event->modifiers()); @@ -2266,6 +2268,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) QRect rect(d->pressedPosition - d->offset(), QSize(1, 1)); setSelection(rect, command); } + event->accept(); return; } } @@ -2363,6 +2366,8 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) } break; } } + if (d->moveCursorUpdatedView) + event->accept(); } /*! diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 509459c..fce74f3 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -419,6 +419,7 @@ public: bool wrapItemText; mutable bool delayedPendingLayout; + bool moveCursorUpdatedView; private: mutable QBasicTimer delayedLayout; diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index fcdc429..95ba67c 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2139,9 +2139,10 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie return d->modelIndex(d->above(vi), current.column()); case MoveLeft: { QScrollBar *sb = horizontalScrollBar(); - if (vi < d->viewItems.count() && d->viewItems.at(vi).expanded && d->itemsExpandable && sb->value() == sb->minimum()) + if (vi < d->viewItems.count() && d->viewItems.at(vi).expanded && d->itemsExpandable && sb->value() == sb->minimum()) { d->collapse(vi, true); - else { + d->moveCursorUpdatedView = true; + } else { bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this); if (descend) { QModelIndex par = current.parent(); @@ -2161,7 +2162,10 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie return next; } + int oldValue = sb->value(); sb->setValue(sb->value() - sb->singleStep()); + if (oldValue != sb->value()) + d->moveCursorUpdatedView = true; } } @@ -2173,6 +2177,7 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie if (vi < d->viewItems.count() && !d->viewItems.at(vi).expanded && d->itemsExpandable && d->hasVisibleChildren(d->viewItems.at(vi).index)) { d->expand(vi, true); + d->moveCursorUpdatedView = true; } else { bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this); if (descend) { @@ -2195,7 +2200,10 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie //last restort: we change the scrollbar value QScrollBar *sb = horizontalScrollBar(); + int oldValue = sb->value(); sb->setValue(sb->value() + sb->singleStep()); + if (oldValue != sb->value()) + d->moveCursorUpdatedView = true; } } updateGeometries(); |