aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2017-11-12 11:16:34 +0100
committerRoland Knall <rknall@gmail.com>2017-11-12 15:07:54 +0000
commit447291d84a63d3e707fd00111ba465e5c230c849 (patch)
treeb89950dfb70f3d49e701b5613e37656042eeea9d /ui
parent8e5436687a46de93ee40f4e8ab510cdc5768f9a5 (diff)
Qt: Fix DragDrop on ProtoTree
Fix two issues, first that you could not move the scrollbar as it would initiate a drag-drop operation. Second, if you start a drag-drop operation at the top of a field, it would select the field you move over as well. Change-Id: I553785b1b6c586919e025d3042a876701f36860d Reviewed-on: https://code.wireshark.org/review/24376 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/proto_tree.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index f96c742598..a34b3896aa 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -38,6 +38,7 @@
#include <QScrollBar>
#include <QTreeWidgetItemIterator>
#include <QUrl>
+#include <QItemSelectionModel>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QWindow>
@@ -708,6 +709,10 @@ bool ProtoTree::eventFilter(QObject * obj, QEvent * event)
if ( cap_file_ && event->type() != QEvent::MouseButtonPress && event->type() != QEvent::MouseMove )
return QTreeWidget::eventFilter(obj, event);
+ /* Mouse was over scrollbar, ignoring */
+ if ( qobject_cast<QScrollBar *>(obj) )
+ return QTreeWidget::eventFilter(obj, event);
+
if ( event->type() == QEvent::MouseButtonPress )
{
QMouseEvent * ev = (QMouseEvent *)event;
@@ -728,6 +733,12 @@ bool ProtoTree::eventFilter(QObject * obj, QEvent * event)
field_info * fi = VariantPointer<field_info>::asPtr(item->data(0, Qt::UserRole));
if ( fi )
{
+ /* Hack to prevent QItemSelection taking the item which has been dragged over at start
+ * of drag-drop operation. selectionModel()->blockSignals could have done the trick, but
+ * it does not take in a QTreeWidget (maybe View) */
+ QModelIndex idx = indexFromItem(item, 0);
+ emit fieldSelected(new FieldInformation(fi, this));
+ selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
QString filter = QString(proto_construct_match_selected_string(fi, cap_file_->edt));