aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/proto_tree.cpp9
-rw-r--r--ui/qt/utils/wireshark_mime_data.cpp15
-rw-r--r--ui/qt/utils/wireshark_mime_data.h6
-rw-r--r--ui/qt/widgets/display_filter_edit.cpp20
4 files changed, 39 insertions, 11 deletions
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index b1620b4..f96c742 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -728,16 +728,17 @@ bool ProtoTree::eventFilter(QObject * obj, QEvent * event)
field_info * fi = VariantPointer<field_info>::asPtr(item->data(0, Qt::UserRole));
if ( fi )
{
- QString description = QString(fi->hfinfo->name);
+
QString filter = QString(proto_construct_match_selected_string(fi, cap_file_->edt));
if ( filter.length() > 0 )
{
+ DisplayFilterMimeData * dfmd =
+ new DisplayFilterMimeData(QString(fi->hfinfo->name), QString(fi->hfinfo->abbrev), filter);
QDrag * drag = new QDrag(this);
- drag->setMimeData(new DisplayFilterMimeData(description, filter));
+ drag->setMimeData(dfmd);
- QString cmt = QString("%1\n%2").arg(description, filter);
- DragLabel * content = new DragLabel(cmt, this);
+ DragLabel * content = new DragLabel(dfmd->labelText(), this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
qreal dpr = window()->windowHandle()->devicePixelRatio();
diff --git a/ui/qt/utils/wireshark_mime_data.cpp b/ui/qt/utils/wireshark_mime_data.cpp
index 690e191..1a12578 100644
--- a/ui/qt/utils/wireshark_mime_data.cpp
+++ b/ui/qt/utils/wireshark_mime_data.cpp
@@ -21,10 +21,11 @@
#include <utils/wireshark_mime_data.h>
-DisplayFilterMimeData::DisplayFilterMimeData(QString description, QString filter) :
+DisplayFilterMimeData::DisplayFilterMimeData(QString description, QString field, QString filter) :
QMimeData(),
description_(description),
-filter_(filter)
+filter_(filter),
+field_(field)
{}
QString DisplayFilterMimeData::description() const
@@ -37,6 +38,16 @@ QString DisplayFilterMimeData::filter() const
return filter_;
}
+QString DisplayFilterMimeData::field() const
+{
+ return field_;
+}
+
+QString DisplayFilterMimeData::labelText() const
+{
+ return QString("%1\n%2: %3\n%4: %5").arg(description_, tr("Field"), field_, tr("Filter"), filter_);
+}
+
ToolbarEntryMimeData::ToolbarEntryMimeData(int pos) :
QMimeData(),
pos_(pos)
diff --git a/ui/qt/utils/wireshark_mime_data.h b/ui/qt/utils/wireshark_mime_data.h
index da7417c..82b70bc 100644
--- a/ui/qt/utils/wireshark_mime_data.h
+++ b/ui/qt/utils/wireshark_mime_data.h
@@ -28,15 +28,19 @@ class DisplayFilterMimeData: public QMimeData {
Q_OBJECT
public:
- DisplayFilterMimeData(QString description, QString filter);
+ DisplayFilterMimeData(QString description, QString field, QString filter);
QString description() const;
+ QString field() const;
QString filter() const;
+ QString labelText() const;
+
private:
QString description_;
QString filter_;
+ QString field_;
};
diff --git a/ui/qt/widgets/display_filter_edit.cpp b/ui/qt/widgets/display_filter_edit.cpp
index df5d1b0..97cdbe9 100644
--- a/ui/qt/widgets/display_filter_edit.cpp
+++ b/ui/qt/widgets/display_filter_edit.cpp
@@ -537,7 +537,10 @@ void DisplayFilterEdit::applyOrPrepareFilter()
void DisplayFilterEdit::dragEnterEvent(QDragEnterEvent *event)
{
- if (event && qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) {
+ if ( ! event )
+ return;
+
+ if (qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) {
if ( event->source() != this )
{
event->setDropAction(Qt::CopyAction);
@@ -552,7 +555,10 @@ void DisplayFilterEdit::dragEnterEvent(QDragEnterEvent *event)
void DisplayFilterEdit::dragMoveEvent(QDragMoveEvent *event)
{
- if (event && qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) {
+ if ( ! event )
+ return;
+
+ if (qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) {
if ( event->source() != this )
{
event->setDropAction(Qt::CopyAction);
@@ -567,8 +573,11 @@ void DisplayFilterEdit::dragMoveEvent(QDragMoveEvent *event)
void DisplayFilterEdit::dropEvent(QDropEvent *event)
{
+ if ( ! event )
+ return;
+
/* Moving items around */
- if (event && qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) {
+ if (qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) {
const DisplayFilterMimeData * data = qobject_cast<const DisplayFilterMimeData *>(event->mimeData());
if ( event->source() != this )
@@ -576,7 +585,10 @@ void DisplayFilterEdit::dropEvent(QDropEvent *event)
event->setDropAction(Qt::CopyAction);
event->accept();
- setText(data->filter());
+ if ((QApplication::keyboardModifiers() & Qt::AltModifier))
+ setText(data->field());
+ else
+ setText(data->filter());
// Holding down the Shift key will only prepare filter.
if (!(QApplication::keyboardModifiers() & Qt::ShiftModifier)) {