Qt: Add a filter expression item to the display filter edit menu.

Add an item to the display filter bookmark menu which opens the filter
expression preferences. We also need an expression editor frame similar
to the column editor frame, but hopefully this will suffice until that
exists.

Change-Id: If4c159bb769f0f8e7f89db55f1c6fd7c0bf65c87
Reviewed-on: https://code.wireshark.org/review/11315
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2015-10-27 09:52:51 -07:00
parent 2ccb9d2d95
commit e70a23f49d
6 changed files with 17 additions and 4 deletions

View File

@ -334,6 +334,8 @@ void DisplayFilterEdit::checkFilter(const QString& filter_text)
connect(save_action, SIGNAL(triggered(bool)), this, SLOT(saveFilter()));
QAction *manage_action = bb_menu->addAction(tr("Manage Display Filters"));
connect(manage_action, SIGNAL(triggered(bool)), this, SLOT(showFilters()));
QAction *expr_action = bb_menu->addAction(tr("Manage Filter Expressions"));
connect(expr_action, SIGNAL(triggered(bool)), this, SLOT(showExpressionPrefs()));
QAction *first_filter = NULL;
for (GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = g_list_next(df_item)) {
@ -544,6 +546,11 @@ void DisplayFilterEdit::showFilters()
display_filter_dlg.exec();
}
void DisplayFilterEdit::showExpressionPrefs()
{
emit showPreferencesDialog(PreferencesDialog::ppFilterExpressions);
}
void DisplayFilterEdit::prepareFilter()
{
QAction *pa = qobject_cast<QAction*>(sender());

View File

@ -22,6 +22,7 @@
#ifndef DISPLAYFILTEREDIT_H
#define DISPLAYFILTEREDIT_H
#include "preferences_dialog.h"
#include "syntax_line_edit.h"
class QEvent;
@ -53,6 +54,7 @@ private slots:
void saveFilter();
void removeFilter();
void showFilters();
void showExpressionPrefs();
void prepareFilter();
private:
@ -69,6 +71,7 @@ signals:
void popFilterSyntaxStatus();
void pushFilterSyntaxWarning(const QString&);
void filterPackets(QString new_filter, bool force);
void showPreferencesDialog(PreferencesDialog::PreferencesPane start_pane);
};
#endif // DISPLAYFILTEREDIT_H

View File

@ -154,7 +154,7 @@ void FilterExpressionsPreferencesFrame::keyPressEvent(QKeyEvent *evt)
QFrame::keyPressEvent(evt);
}
void FilterExpressionsPreferencesFrame::addExpression(bool enabled, const char *label, char *expression)
void FilterExpressionsPreferencesFrame::addExpression(bool enabled, const QString label, const QString expression)
{
QTreeWidgetItem *item = new QTreeWidgetItem(ui->expressionTreeWidget);
@ -267,9 +267,10 @@ void FilterExpressionsPreferencesFrame::expressionEditingFinished()
ui->expressionTreeWidget->removeItemWidget(item, expression_col_);
}
static const QString new_button_label_ = QObject::tr("My Filter");
void FilterExpressionsPreferencesFrame::on_newToolButton_clicked()
{
addExpression(true, "My Filter", NULL); //TODO : Fix Translate
addExpression(true, new_button_label_, QString());
}
void FilterExpressionsPreferencesFrame::on_deleteToolButton_clicked()

View File

@ -51,7 +51,7 @@ private:
QLineEdit *cur_line_edit_;
QString saved_col_string_;
void addExpression(bool enabled, const char *label, char *expression);
void addExpression(bool enabled, const QString label, const QString expression);
private slots:
void updateWidgets(void);

View File

@ -26,7 +26,7 @@
</column>
<column>
<property name="text">
<string>Label</string>
<string>Button Label</string>
</property>
</column>
<column>

View File

@ -281,6 +281,8 @@ MainWindow::MainWindow(QWidget *parent) :
connect(df_edit, SIGNAL(pushFilterSyntaxWarning(const QString&)),
main_ui_->statusBar, SLOT(pushTemporaryStatus(const QString&)));
connect(df_edit, SIGNAL(filterPackets(QString,bool)), this, SLOT(filterPackets(QString,bool)));
connect(df_edit, SIGNAL(showPreferencesDialog(PreferencesDialog::PreferencesPane)),
this, SLOT(showPreferencesDialog(PreferencesDialog::PreferencesPane)));
connect(wsApp, SIGNAL(preferencesChanged()), df_edit, SLOT(checkFilter()));
connect(df_edit, SIGNAL(textChanged(QString)), funnel_statistics_, SLOT(displayFilterTextChanged(QString)));