Qt: Fix ghost drag-and-drop in PacketList on empty fields

If you start dragging on an empty field, you pick up the value of
a field you drag over. This is fixed

Change-Id: I7e1c5e353dbc79ee1193b305729fb44d62d98470
Reviewed-on: https://code.wireshark.org/review/33629
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Roland Knall 2019-06-16 23:39:37 +02:00
parent d95262bf74
commit c288574842
2 changed files with 15 additions and 3 deletions

View File

@ -230,6 +230,7 @@ PacketList::PacketList(QWidget *parent) :
overlay_timer_id_(0),
create_near_overlay_(true),
create_far_overlay_(true),
mouse_pressed_at_(QModelIndex()),
capture_in_progress_(false),
tail_timer_id_(0),
rows_inserted_(false),
@ -651,14 +652,22 @@ void PacketList::mousePressEvent (QMouseEvent *event)
setAutoScroll(false);
QTreeView::mousePressEvent(event);
setAutoScroll(true);
QModelIndex curIndex = indexAt(event->pos());
mouse_pressed_at_ = curIndex;
}
void PacketList::mouseReleaseEvent(QMouseEvent *event) {
QTreeView::mouseReleaseEvent(event);
mouse_pressed_at_ = QModelIndex();
}
void PacketList::mouseMoveEvent (QMouseEvent *event)
{
if ( event->buttons() & Qt::LeftButton )
QModelIndex curIndex = indexAt(event->pos());
if ( event->buttons() & Qt::LeftButton && curIndex == mouse_pressed_at_ )
{
QModelIndex curIndex = indexAt(event->pos());
ctx_column_ = curIndex.column();
QMimeData * mimeData = nullptr;
QWidget * content = nullptr;

View File

@ -74,6 +74,7 @@ protected:
void timerEvent(QTimerEvent *event);
void paintEvent(QPaintEvent *event);
virtual void mousePressEvent (QMouseEvent *event);
virtual void mouseReleaseEvent (QMouseEvent *event);
virtual void mouseMoveEvent (QMouseEvent *event);
virtual void resizeEvent(QResizeEvent *event);
@ -99,6 +100,8 @@ private:
bool create_far_overlay_;
QVector<QRgb> overlay_colors_;
QModelIndex mouse_pressed_at_;
RelatedPacketDelegate related_packet_delegate_;
QAction *show_hide_separator_;
QList<QAction *>show_hide_actions_;