forked from osmocom/wireshark
Qt: Move Filterbuttons to display filter
Allow filterbuttons to be dragged to the display filter bar Change-Id: I25e87d0ca86fc7437a20994800bec164ccffef27 Reviewed-on: https://code.wireshark.org/review/34838 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
ca64fb62c0
commit
a3e3a73a82
|
@ -49,6 +49,7 @@ void DisplayFilterMimeData::allowPlainText()
|
|||
ToolbarEntryMimeData::ToolbarEntryMimeData(QString element, int pos) :
|
||||
WiresharkMimeData(),
|
||||
element_(element),
|
||||
filter_(QString()),
|
||||
pos_(pos)
|
||||
{}
|
||||
|
||||
|
@ -67,6 +68,16 @@ int ToolbarEntryMimeData::position() const
|
|||
return pos_;
|
||||
}
|
||||
|
||||
void ToolbarEntryMimeData::setFilter(QString text)
|
||||
{
|
||||
filter_ = text;
|
||||
}
|
||||
|
||||
QString ToolbarEntryMimeData::filter() const
|
||||
{
|
||||
return filter_;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
|
|
|
@ -47,12 +47,15 @@ public:
|
|||
|
||||
int position() const;
|
||||
QString element() const;
|
||||
QString filter() const;
|
||||
void setFilter(QString);
|
||||
|
||||
QString labelText() const override;
|
||||
|
||||
private:
|
||||
|
||||
QString element_;
|
||||
QString filter_;
|
||||
int pos_;
|
||||
|
||||
};
|
||||
|
|
|
@ -538,7 +538,8 @@ void DisplayFilterEdit::dragEnterEvent(QDragEnterEvent *event)
|
|||
if ( ! event )
|
||||
return;
|
||||
|
||||
if (qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) {
|
||||
if (qobject_cast<const DisplayFilterMimeData *>(event->mimeData()) ||
|
||||
qobject_cast<const ToolbarEntryMimeData *>(event->mimeData())) {
|
||||
if ( event->source() != this )
|
||||
{
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
|
@ -556,7 +557,8 @@ void DisplayFilterEdit::dragMoveEvent(QDragMoveEvent *event)
|
|||
if ( ! event )
|
||||
return;
|
||||
|
||||
if (qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) {
|
||||
if (qobject_cast<const DisplayFilterMimeData *>(event->mimeData()) ||
|
||||
qobject_cast<const ToolbarEntryMimeData *>(event->mimeData())) {
|
||||
if ( event->source() != this )
|
||||
{
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
|
@ -574,21 +576,29 @@ void DisplayFilterEdit::dropEvent(QDropEvent *event)
|
|||
if ( ! event )
|
||||
return;
|
||||
|
||||
/* Moving items around */
|
||||
QString filterText = "";
|
||||
if (qobject_cast<const DisplayFilterMimeData *>(event->mimeData())) {
|
||||
const DisplayFilterMimeData * data = qobject_cast<const DisplayFilterMimeData *>(event->mimeData());
|
||||
|
||||
QString filterText;
|
||||
if ((QApplication::keyboardModifiers() & Qt::AltModifier))
|
||||
filterText = data->field();
|
||||
else
|
||||
filterText = data->filter();
|
||||
}
|
||||
else if (qobject_cast<const ToolbarEntryMimeData *>(event->mimeData())) {
|
||||
const ToolbarEntryMimeData * data = qobject_cast<const ToolbarEntryMimeData *>(event->mimeData());
|
||||
|
||||
filterText = data->filter();
|
||||
}
|
||||
|
||||
/* Moving items around */
|
||||
if (filterText.length() > 0) {
|
||||
if ( event->source() != this )
|
||||
{
|
||||
event->setDropAction(Qt::CopyAction);
|
||||
event->accept();
|
||||
|
||||
QString filterText;
|
||||
if ((QApplication::keyboardModifiers() & Qt::AltModifier))
|
||||
filterText = data->field();
|
||||
else
|
||||
filterText = data->filter();
|
||||
|
||||
bool prepare = QApplication::keyboardModifiers() & Qt::ShiftModifier;
|
||||
|
||||
if ( text().length() > 0 || QApplication::keyboardModifiers() & Qt::MetaModifier)
|
||||
|
|
|
@ -93,6 +93,11 @@ void DragDropToolBar::clear()
|
|||
childCounter = 0;
|
||||
}
|
||||
|
||||
WiresharkMimeData * DragDropToolBar::createMimeData(QString name, int position)
|
||||
{
|
||||
return new ToolbarEntryMimeData(name, position);
|
||||
}
|
||||
|
||||
bool DragDropToolBar::eventFilter(QObject * obj, QEvent * event)
|
||||
{
|
||||
if ( ! obj->isWidgetType() )
|
||||
|
@ -118,8 +123,7 @@ bool DragDropToolBar::eventFilter(QObject * obj, QEvent * event)
|
|||
if ( ! qobject_cast<QToolButton *>(elem) || ! elem->property(drag_drop_toolbar_action_).isValid() )
|
||||
return QToolBar::eventFilter(obj, event);
|
||||
|
||||
ToolbarEntryMimeData * temd =
|
||||
new ToolbarEntryMimeData(((QToolButton *)elem)->text(), elem->property(drag_drop_toolbar_action_).toInt());
|
||||
WiresharkMimeData * temd = createMimeData(((QToolButton *)elem)->text(), elem->property(drag_drop_toolbar_action_).toInt());
|
||||
DragLabel * lbl = new DragLabel(temd->labelText(), this);
|
||||
QDrag * drag = new QDrag(this);
|
||||
drag->setMimeData(temd);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <QToolBar>
|
||||
#include <QPoint>
|
||||
|
||||
class WiresharkMimeData;
|
||||
|
||||
class DragDropToolBar : public QToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -30,6 +32,8 @@ Q_SIGNALS:
|
|||
|
||||
protected:
|
||||
|
||||
virtual WiresharkMimeData * createMimeData(QString name, int position);
|
||||
|
||||
virtual void childEvent(QChildEvent * event);
|
||||
|
||||
virtual bool eventFilter(QObject * obj, QEvent * ev);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <ui/qt/widgets/filter_expression_toolbar.h>
|
||||
#include <ui/qt/utils/color_utils.h>
|
||||
#include <ui/qt/utils/qt_ui_utils.h>
|
||||
#include <ui/qt/utils/wireshark_mime_data.h>
|
||||
#include <ui/qt/models/uat_model.h>
|
||||
#include <ui/qt/filter_action.h>
|
||||
#include <ui/qt/wireshark_application.h>
|
||||
|
@ -141,6 +142,24 @@ void FilterExpressionToolBar::removeFilter()
|
|||
}
|
||||
}
|
||||
|
||||
WiresharkMimeData * FilterExpressionToolBar::createMimeData(QString name, int position)
|
||||
{
|
||||
ToolbarEntryMimeData * element = new ToolbarEntryMimeData(name, position);
|
||||
UatModel * uatModel = new UatModel(this, "Display expressions");
|
||||
|
||||
QModelIndex rowIndex;
|
||||
for ( int cnt = 0; cnt < uatModel->rowCount() && ! rowIndex.isValid(); cnt++ )
|
||||
{
|
||||
if ( uatModel->data(uatModel->index(cnt, 1), Qt::DisplayRole).toString().compare(name) == 0 )
|
||||
{
|
||||
rowIndex = uatModel->index(cnt, 2);
|
||||
element->setFilter(rowIndex.data().toString());
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
void FilterExpressionToolBar::onActionMoved(QAction* action, int oldPos, int newPos)
|
||||
{
|
||||
gchar* err = NULL;
|
||||
|
|
|
@ -23,6 +23,9 @@ public:
|
|||
protected:
|
||||
virtual bool event(QEvent *event);
|
||||
|
||||
protected:
|
||||
virtual WiresharkMimeData * createMimeData(QString name, int position);
|
||||
|
||||
public slots:
|
||||
void filterExpressionsChanged();
|
||||
|
||||
|
|
Loading…
Reference in New Issue