aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/filter_action.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt/filter_action.cpp')
-rw-r--r--ui/qt/filter_action.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/ui/qt/filter_action.cpp b/ui/qt/filter_action.cpp
index 5c5db557f5..490350d1df 100644
--- a/ui/qt/filter_action.cpp
+++ b/ui/qt/filter_action.cpp
@@ -9,6 +9,9 @@
#include "filter_action.h"
+#include <ui/qt/wireshark_application.h>
+#include <ui/qt/main_window.h>
+
FilterAction::FilterAction(QObject *parent, FilterAction::Action action, FilterAction::ActionType type, FilterAction::ActionDirection direction) :
QAction(parent),
action_(action),
@@ -176,6 +179,55 @@ const QString FilterAction::actionDirectionName(ActionDirection direction) {
}
}
+QActionGroup * FilterAction::createFilterGroup(QString filter, bool prepare, bool enabled, QWidget * parent)
+{
+ if ( filter.isEmpty() )
+ return Q_NULLPTR;
+
+ FilterAction * filterAction = new FilterAction(parent, prepare ? FilterAction::ActionPrepare : FilterAction::ActionApply);
+
+ QActionGroup * group = new QActionGroup(parent);
+ group->setProperty("filter", filter);
+ group->setProperty("filterAction", prepare ? FilterAction::ActionPrepare : FilterAction::ActionApply);
+ QAction * action = group->addAction(tr("Selected"));
+ action->setProperty("filterType", FilterAction::ActionTypePlain);
+ action = group->addAction(tr("Not Selected"));
+ action->setProperty("filterType", FilterAction::ActionTypeNot);
+ action = group->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "and Selected"));
+ action->setProperty("filterType", FilterAction::ActionTypeAnd);
+ action = group->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "or Selected"));
+ action->setProperty("filterType", FilterAction::ActionTypeOr);
+ action = group->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "and not Selected"));
+ action->setProperty("filterType", FilterAction::ActionTypeAndNot);
+ action = group->addAction(tr(UTF8_HORIZONTAL_ELLIPSIS "or not Selected"));
+ action->setProperty("filterType", FilterAction::ActionTypeOrNot);
+ group->setEnabled(enabled);
+ connect(group, &QActionGroup::triggered, filterAction, &FilterAction::groupTriggered);
+
+ return group;
+}
+
+void FilterAction::groupTriggered(QAction * action)
+{
+ if ( action && wsApp )
+ {
+ if ( action->property("filterType").canConvert<FilterAction::ActionType>() &&
+ sender()->property("filterAction").canConvert<FilterAction::Action>() )
+ {
+ FilterAction::Action act = sender()->property("filterAction").value<FilterAction::Action>();
+ FilterAction::ActionType type = action->property("filterType").value<FilterAction::ActionType>();
+ QString filter = sender()->property("filter").toString();
+
+ QWidget * mainWin = wsApp->mainWindow();
+ if ( qobject_cast<MainWindow *>(mainWin) )
+ {
+ MainWindow * mw = qobject_cast<MainWindow *>(mainWin);
+ mw->setDisplayFilter(filter, act, type);
+ }
+ }
+ }
+}
+
/*
* Editor modelines
*