diff options
author | Gerald Combs <gerald@wireshark.org> | 2018-02-05 16:48:13 -0800 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2018-02-06 07:19:09 +0000 |
commit | ab202adb0ae95de3d63b7ba43a062133f38ee299 (patch) | |
tree | 724ac386434e6a87e5536453fe78d50c4b25ea80 | |
parent | 8ab3060aace7b20c2845f2f725d4f306cca61dd4 (diff) |
Proto tree: Update left arrow navigation behavior.
If the user presses the left arrow when a non-expaned proto tree item is
selected, jump to its parent item as described in the "Main Window
Navigation" section of the User's Guide..
Change-Id: Ie7478a2c292df9a225555f5539d7ba90ab5e132d
Reviewed-on: https://code.wireshark.org/review/25623
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r-- | ui/qt/proto_tree.cpp | 12 | ||||
-rw-r--r-- | ui/qt/proto_tree.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index 89e225e947..ed9da842f6 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -587,6 +587,18 @@ bool ProtoTree::eventFilter(QObject * obj, QEvent * event) return QTreeView::eventFilter(obj, event); } +QModelIndex ProtoTree::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) +{ + if (cursorAction == MoveLeft && selectionModel()->hasSelection()) { + QModelIndex cur_idx = selectionModel()->selectedIndexes().first(); + QModelIndex parent = cur_idx.parent(); + if (!isExpanded(cur_idx) && parent.isValid() && parent != rootIndex()) { + return parent; + } + } + return QTreeView::moveCursor(cursorAction, modifiers); +} + /* * Editor modelines * diff --git a/ui/qt/proto_tree.h b/ui/qt/proto_tree.h index 7190eae0fb..8394b69815 100644 --- a/ui/qt/proto_tree.h +++ b/ui/qt/proto_tree.h @@ -45,6 +45,7 @@ protected: virtual void timerEvent(QTimerEvent *event); virtual void keyReleaseEvent(QKeyEvent *event); virtual bool eventFilter(QObject * obj, QEvent * ev); + virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers); private: ProtoTreeModel *proto_tree_model_; |