forked from osmocom/wireshark
Qt: Add Drag-and-Drop to Packetlist
Allow cells to be used in drag-and-drop operations Change-Id: I6eeb5e32076ba9dddc73265e213e8cfeae1f0783 Reviewed-on: https://code.wireshark.org/review/33604 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
parent
d370f54c47
commit
20246cf005
|
@ -49,6 +49,8 @@
|
||||||
#include <ui/qt/utils/variant_pointer.h>
|
#include <ui/qt/utils/variant_pointer.h>
|
||||||
#include <ui/qt/models/pref_models.h>
|
#include <ui/qt/models/pref_models.h>
|
||||||
#include <ui/qt/widgets/packet_list_header.h>
|
#include <ui/qt/widgets/packet_list_header.h>
|
||||||
|
#include <ui/qt/utils/wireshark_mime_data.h>
|
||||||
|
#include <ui/qt/widgets/drag_label.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
|
@ -66,6 +68,7 @@
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include "wsutil/file_util.h"
|
#include "wsutil/file_util.h"
|
||||||
|
@ -648,6 +651,30 @@ void PacketList::mousePressEvent (QMouseEvent *event)
|
||||||
setAutoScroll(false);
|
setAutoScroll(false);
|
||||||
QTreeView::mousePressEvent(event);
|
QTreeView::mousePressEvent(event);
|
||||||
setAutoScroll(true);
|
setAutoScroll(true);
|
||||||
|
|
||||||
|
QModelIndex curIndex = indexAt(event->pos());
|
||||||
|
ctx_column_ = curIndex.column();
|
||||||
|
QString filter = getFilterFromRowAndColumn();
|
||||||
|
if ( ! filter.isEmpty() )
|
||||||
|
{
|
||||||
|
QString abbrev = filter.left(filter.indexOf(' '));
|
||||||
|
QString name = model()->headerData(ctx_column_, header()->orientation()).toString();
|
||||||
|
|
||||||
|
DisplayFilterMimeData * dfmd =
|
||||||
|
new DisplayFilterMimeData(name, abbrev, filter);
|
||||||
|
QDrag * drag = new QDrag(this);
|
||||||
|
drag->setMimeData(dfmd);
|
||||||
|
|
||||||
|
DragLabel * content = new DragLabel(dfmd->labelText(), this);
|
||||||
|
qreal dpr = window()->windowHandle()->devicePixelRatio();
|
||||||
|
QPixmap pixmap(content->size() * dpr);
|
||||||
|
pixmap.setDevicePixelRatio(dpr);
|
||||||
|
content->render(&pixmap);
|
||||||
|
drag->setPixmap(pixmap);
|
||||||
|
|
||||||
|
drag->exec(Qt::CopyAction);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketList::resizeEvent(QResizeEvent *event)
|
void PacketList::resizeEvent(QResizeEvent *event)
|
||||||
|
|
Loading…
Reference in New Issue