aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/CMakeLists.txt2
-rw-r--r--ui/qt/Makefile.am2
-rw-r--r--ui/qt/coloring_rules_dialog.ui9
-rw-r--r--ui/qt/tabnav_tree_widget.cpp68
-rw-r--r--ui/qt/tabnav_tree_widget.h54
5 files changed, 134 insertions, 1 deletions
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index 085dc9a635..1ddcacf3a9 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -161,6 +161,7 @@ set(WIRESHARK_QT_HEADERS
simple_statistics_dialog.h
stock_icon_tool_button.h
supported_protocols_dialog.h
+ tabnav_tree_widget.h
tap_parameter_dialog.h
tcp_stream_dialog.h
time_shift_dialog.h
@@ -340,6 +341,7 @@ set(WIRESHARK_QT_SRC
stock_icon.cpp
stock_icon_tool_button.cpp
supported_protocols_dialog.cpp
+ tabnav_tree_widget.cpp
tap_parameter_dialog.cpp
tcp_stream_dialog.cpp
time_shift_dialog.cpp
diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am
index 8c88d61bbd..bd3b1cbcd3 100644
--- a/ui/qt/Makefile.am
+++ b/ui/qt/Makefile.am
@@ -292,6 +292,7 @@ MOC_HDRS = \
stats_tree_dialog.h \
stock_icon_tool_button.h \
supported_protocols_dialog.h \
+ tabnav_tree_widget.h \
tap_parameter_dialog.h \
tcp_stream_dialog.h \
time_shift_dialog.h \
@@ -585,6 +586,7 @@ WIRESHARK_QT_SRC = \
stock_icon.cpp \
stock_icon_tool_button.cpp \
supported_protocols_dialog.cpp \
+ tabnav_tree_widget.cpp \
tap_parameter_dialog.cpp \
tcp_stream_dialog.cpp \
time_shift_dialog.cpp \
diff --git a/ui/qt/coloring_rules_dialog.ui b/ui/qt/coloring_rules_dialog.ui
index e2c338ffeb..a8098bae7b 100644
--- a/ui/qt/coloring_rules_dialog.ui
+++ b/ui/qt/coloring_rules_dialog.ui
@@ -15,7 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QTreeWidget" name="coloringRulesTreeWidget">
+ <widget class="TabnavTreeWidget" name="coloringRulesTreeWidget">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
@@ -175,6 +175,13 @@
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>TabnavTreeWidget</class>
+ <extends>QTreeWidget</extends>
+ <header>tabnav_tree_widget.h</header>
+ </customwidget>
+ </customwidgets>
<resources>
<include location="../../image/toolbar.qrc"/>
</resources>
diff --git a/ui/qt/tabnav_tree_widget.cpp b/ui/qt/tabnav_tree_widget.cpp
new file mode 100644
index 0000000000..3d07a1cf35
--- /dev/null
+++ b/ui/qt/tabnav_tree_widget.cpp
@@ -0,0 +1,68 @@
+/* tabnav_tree_widget.cpp
+ * Tree widget with saner tab navigation properties.
+ *
+ * Copyright 2017 Peter Wu <peter@lekensteyn.nl>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "tabnav_tree_widget.h"
+
+// Copy on UatTreeView, modified to use QTreeWidget instead of QTreeView.
+
+TabnavTreeWidget::TabnavTreeWidget(QWidget *parent) : QTreeWidget(parent)
+{
+}
+
+// Note: if a QTableWidget is used, then this is not needed anymore since Tab
+// works as "expected" (move to next cell instead of row).
+// Note 2: this does not help with fields with no widget (like filename).
+QModelIndex TabnavTreeWidget::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
+{
+ QModelIndex current = currentIndex();
+ // If an item is currently selected, interpret Next/Previous. Otherwise,
+ // fallback to the default selection (e.g. first row for Next).
+ if (current.isValid()) {
+ if (cursorAction == MoveNext) {
+ if (current.column() < model()->columnCount()) {
+ return current.sibling(current.row(), current.column() + 1);
+ }
+ return current;
+ } else if (cursorAction == MovePrevious) {
+ if (current.column() > 0) {
+ return current.sibling(current.row(), current.column() - 1);
+ }
+ return current;
+ }
+ }
+
+ return QTreeView::moveCursor(cursorAction, modifiers);
+}
+
+/* * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/ui/qt/tabnav_tree_widget.h b/ui/qt/tabnav_tree_widget.h
new file mode 100644
index 0000000000..781f8ecae7
--- /dev/null
+++ b/ui/qt/tabnav_tree_widget.h
@@ -0,0 +1,54 @@
+/* tabnav_tree_widget.h
+ * Tree widget with saner tab navigation properties.
+ *
+ * Copyright 2017 Peter Wu <peter@lekensteyn.nl>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef TABNAV_TREE_WIDGET_H
+#define TABNAV_TREE_WIDGET_H
+
+#include <config.h>
+#include <QTreeWidget>
+
+/**
+ * Like QTreeWidget, but instead of changing to the next row (same column) when
+ * pressing Tab while editing, change to the next column (same row).
+ */
+class TabnavTreeWidget : public QTreeWidget
+{
+ Q_OBJECT
+public:
+ TabnavTreeWidget(QWidget *parent = 0);
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
+};
+#endif // TABNAV_TREE_WIDGET_H
+
+/* * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */