summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/filter_expressions.c8
-rw-r--r--epan/filter_expressions.h2
-rw-r--r--ui/qt/CMakeLists.txt3
-rw-r--r--ui/qt/Makefile.am2
-rw-r--r--ui/qt/Makefile.common4
-rw-r--r--ui/qt/Wireshark.pro3
-rw-r--r--ui/qt/filter_expression_frame.cpp112
-rw-r--r--ui/qt/filter_expression_frame.h73
-rw-r--r--ui/qt/filter_expression_frame.ui151
-rw-r--r--ui/qt/main_window.cpp5
-rw-r--r--ui/qt/main_window.h1
-rw-r--r--ui/qt/main_window.ui38
-rw-r--r--ui/qt/main_window_slots.cpp14
13 files changed, 399 insertions, 17 deletions
diff --git a/epan/filter_expressions.c b/epan/filter_expressions.c
index 936fca96c7..1b6d3069e6 100644
--- a/epan/filter_expressions.c
+++ b/epan/filter_expressions.c
@@ -44,16 +44,10 @@ filter_expression_new(const gchar *label, const gchar *expr,
struct filter_expression *expression;
struct filter_expression *prev;
- expression = (struct filter_expression *)g_malloc(sizeof(struct filter_expression));
- memset(expression, '\0', sizeof(struct filter_expression));
- expression->button = NULL;
+ expression = (struct filter_expression *)g_malloc0(sizeof(struct filter_expression));
expression->label = g_strdup(label);
expression->expression = g_strdup(expr);
expression->enabled = enabled;
- expression->deleted = FALSE;
- expression->index = 0;
-
- expression->next = NULL;
/* Add it at the end so the button order is always the same*/
if (*pfilter_expression_head == NULL) {
diff --git a/epan/filter_expressions.h b/epan/filter_expressions.h
index fa2ec7790d..20c0667270 100644
--- a/epan/filter_expressions.h
+++ b/epan/filter_expressions.h
@@ -38,7 +38,7 @@ struct filter_expression {
gchar *label;
gchar *expression;
- gint index;
+ gint index;
gboolean enabled; /* Can be set to FALSE by Preferences Dialog */
gboolean deleted; /* Can be set to TRUE by Preferences Dialog (GTK+ only) */
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index d39be1ca97..84783a3d3f 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -63,6 +63,7 @@ set(WIRESHARK_QT_HEADERS
filter_action.h
filter_dialog.h
filter_dialog.h
+ filter_expression_frame.h
filter_expressions_preferences_frame.h
follow_stream_dialog.h
follow_stream_text.h
@@ -210,6 +211,7 @@ set(WIRESHARK_QT_SRC
file_set_dialog.cpp
filter_action.cpp
filter_dialog.cpp
+ filter_expression_frame.cpp
filter_expressions_preferences_frame.cpp
follow_stream_dialog.cpp
follow_stream_text.cpp
@@ -353,6 +355,7 @@ set(WIRESHARK_QT_UI
export_pdu_dialog.ui
file_set_dialog.ui
filter_dialog.ui
+ filter_expression_frame.ui
filter_expressions_preferences_frame.ui
follow_stream_dialog.ui
font_color_preferences_frame.ui
diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am
index fb7f2f592f..237f7f5bbd 100644
--- a/ui/qt/Makefile.am
+++ b/ui/qt/Makefile.am
@@ -174,6 +174,8 @@ file_set_dialog.$(OBJEXT): ui_file_set_dialog.h
filter_dialog.$(OBJEXT): ui_filter_dialog.h
+filter_expression_frame.$(OBJEXT): ui_filter_expression_frame.h
+
filter_expressions_preferences_frame.$(OBJEXT): ui_filter_expressions_preferences_frame.h
follow_stream_dialog.$(OBJEXT): ui_follow_stream_dialog.h
diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common
index eb3bba2290..0c1d09cde1 100644
--- a/ui/qt/Makefile.common
+++ b/ui/qt/Makefile.common
@@ -52,6 +52,7 @@ NODIST_GENERATED_HEADER_FILES = \
ui_extcap_options_dialog.h \
ui_file_set_dialog.h \
ui_filter_dialog.h \
+ ui_filter_expression_frame.h \
ui_filter_expressions_preferences_frame.h \
ui_follow_stream_dialog.h \
ui_font_color_preferences_frame.h \
@@ -184,6 +185,7 @@ MOC_HDRS = \
file_set_dialog.h \
filter_action.h \
filter_dialog.h \
+ filter_expression_frame.h \
filter_expressions_preferences_frame.h \
follow_stream_dialog.h \
follow_stream_text.h \
@@ -298,6 +300,7 @@ UI_FILES = \
extcap_options_dialog.ui \
file_set_dialog.ui \
filter_dialog.ui \
+ filter_expression_frame.ui \
filter_expressions_preferences_frame.ui \
follow_stream_dialog.ui \
font_color_preferences_frame.ui \
@@ -442,6 +445,7 @@ WIRESHARK_QT_SRC = \
file_set_dialog.cpp \
filter_action.cpp \
filter_dialog.cpp \
+ filter_expression_frame.cpp \
filter_expressions_preferences_frame.cpp \
follow_stream_dialog.cpp \
follow_stream_text.cpp \
diff --git a/ui/qt/Wireshark.pro b/ui/qt/Wireshark.pro
index 9892177d6b..eeeccea6f8 100644
--- a/ui/qt/Wireshark.pro
+++ b/ui/qt/Wireshark.pro
@@ -231,6 +231,7 @@ FORMS += \
extcap_options_dialog.ui \
file_set_dialog.ui \
filter_dialog.ui \
+ filter_expression_frame.ui \
filter_expressions_preferences_frame.ui \
follow_stream_dialog.ui \
font_color_preferences_frame.ui \
@@ -316,6 +317,7 @@ HEADERS += $$HEADERS_WS_C \
extcap_argument_file.h \
extcap_options_dialog.h \
filter_action.h \
+ filter_expression_frame.h \
filter_expressions_preferences_frame.h \
follow_stream_dialog.h \
follow_stream_text.h \
@@ -704,6 +706,7 @@ SOURCES += \
file_set_dialog.cpp \
filter_action.cpp \
filter_dialog.cpp \
+ filter_expression_frame.cpp \
filter_expressions_preferences_frame.cpp \
follow_stream_dialog.cpp \
follow_stream_text.cpp \
diff --git a/ui/qt/filter_expression_frame.cpp b/ui/qt/filter_expression_frame.cpp
new file mode 100644
index 0000000000..d0ccb2677b
--- /dev/null
+++ b/ui/qt/filter_expression_frame.cpp
@@ -0,0 +1,112 @@
+/* filter_expression_frame.cpp
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "filter_expression_frame.h"
+#include "ui_filter_expression_frame.h"
+
+#include <epan/filter_expressions.h>
+
+// To do:
+// - Add the ability to edit current expressions.
+
+FilterExpressionFrame::FilterExpressionFrame(QWidget *parent) :
+ AccordionFrame(parent),
+ ui(new Ui::FilterExpressionFrame)
+{
+ ui->setupUi(this);
+}
+
+FilterExpressionFrame::~FilterExpressionFrame()
+{
+ delete ui;
+}
+
+void FilterExpressionFrame::addExpression(const QString filter_text)
+{
+ if (isVisible()) {
+ on_cancelButton_clicked();
+ return;
+ }
+
+ ui->labelLineEdit->setText(tr("Apply this filter"));
+ ui->displayFilterLineEdit->setText(filter_text);
+}
+
+void FilterExpressionFrame::showEvent(QShowEvent *event)
+{
+ ui->labelLineEdit->setFocus();
+ ui->labelLineEdit->selectAll();
+
+ AccordionFrame::showEvent(event);
+}
+
+void FilterExpressionFrame::updateWidgets()
+{
+ bool ok_enable = false;
+
+ if (!ui->labelLineEdit->text().isEmpty()) {
+ ok_enable = true;
+ }
+
+ ui->okButton->setEnabled(ok_enable);
+}
+
+void FilterExpressionFrame::on_filterExpressionPreferencesToolButton_clicked()
+{
+ on_cancelButton_clicked();
+ emit showPreferencesDialog(PreferencesDialog::ppFilterExpressions);
+}
+
+void FilterExpressionFrame::on_labelLineEdit_textChanged(const QString)
+{
+ updateWidgets();
+}
+
+void FilterExpressionFrame::on_okButton_clicked()
+{
+ QByteArray label_ba = ui->labelLineEdit->text().toUtf8();
+ QByteArray expr_ba = ui->displayFilterLineEdit->text().toUtf8();
+
+ filter_expression_new(label_ba.constData(), expr_ba.constData(), TRUE);
+
+ on_cancelButton_clicked();
+ emit filterExpressionsChanged();
+}
+
+void FilterExpressionFrame::on_cancelButton_clicked()
+{
+ ui->labelLineEdit->clear();
+ ui->displayFilterLineEdit->clear();
+ animatedHide();
+}
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/ui/qt/filter_expression_frame.h b/ui/qt/filter_expression_frame.h
new file mode 100644
index 0000000000..3e289919f5
--- /dev/null
+++ b/ui/qt/filter_expression_frame.h
@@ -0,0 +1,73 @@
+/* filter_expression_frame.h
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef FILTER_EXPRESSION_FRAME_H
+#define FILTER_EXPRESSION_FRAME_H
+
+#include "accordion_frame.h"
+#include "preferences_dialog.h"
+
+namespace Ui {
+class FilterExpressionFrame;
+}
+
+class FilterExpressionFrame : public AccordionFrame
+{
+ Q_OBJECT
+
+public:
+ explicit FilterExpressionFrame(QWidget *parent = 0);
+ ~FilterExpressionFrame();
+
+ void addExpression(const QString filter_text);
+
+signals:
+ void showPreferencesDialog(PreferencesDialog::PreferencesPane start_pane);
+ void filterExpressionsChanged();
+
+protected:
+ virtual void showEvent(QShowEvent *event);
+
+private:
+ Ui::FilterExpressionFrame *ui;
+
+private slots:
+ void updateWidgets();
+ void on_filterExpressionPreferencesToolButton_clicked();
+ void on_labelLineEdit_textChanged(const QString);
+ void on_okButton_clicked();
+ void on_cancelButton_clicked();
+};
+
+#endif // FILTER_EXPRESSION_FRAME_H
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/ui/qt/filter_expression_frame.ui b/ui/qt/filter_expression_frame.ui
new file mode 100644
index 0000000000..7a2a33f67d
--- /dev/null
+++ b/ui/qt/filter_expression_frame.ui
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FilterExpressionFrame</class>
+ <widget class="QFrame" name="FilterExpressionFrame">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>745</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Frame</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0,1,0,0,0">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QToolButton" name="filterExpressionPreferencesToolButton">
+ <property name="text">
+ <string>Filter Expression Preferences…</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>88</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelLabel">
+ <property name="text">
+ <string>Label:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="SyntaxLineEdit" name="labelLineEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="filterLabel">
+ <property name="text">
+ <string>Filter:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="DisplayFilterEdit" name="displayFilterLineEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="okButton">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>SyntaxLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>syntax_line_edit.h</header>
+ </customwidget>
+ <customwidget>
+ <class>DisplayFilterEdit</class>
+ <extends>QLineEdit</extends>
+ <header>display_filter_edit.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index ba2087a981..2b47f866c0 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -323,6 +323,7 @@ MainWindow::MainWindow(QWidget *parent) :
main_ui_->addressEditorFrame->hide();
main_ui_->columnEditorFrame->hide();
main_ui_->preferenceEditorFrame->hide();
+ main_ui_->filterExpressionFrame->hide();
#ifndef HAVE_LIBPCAP
main_ui_->menuCapture->setEnabled(false);
@@ -481,6 +482,10 @@ MainWindow::MainWindow(QWidget *parent) :
this, SLOT(showPreferencesDialog(QString)));
connect(main_ui_->preferenceEditorFrame, SIGNAL(showProtocolPreferences(QString)),
this, SLOT(showPreferencesDialog(QString)));
+ connect(main_ui_->filterExpressionFrame, SIGNAL(showPreferencesDialog(PreferencesDialog::PreferencesPane)),
+ this, SLOT(showPreferencesDialog(PreferencesDialog::PreferencesPane)));
+ connect(main_ui_->filterExpressionFrame, SIGNAL(filterExpressionsChanged()),
+ this, SLOT(filterExpressionsChanged()));
connect(this, SIGNAL(setCaptureFile(capture_file*)),
main_ui_->searchFrame, SLOT(setCaptureFile(capture_file*)));
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index be314ed24e..40c52e7b9a 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -285,6 +285,7 @@ private slots:
void setFeaturesEnabled(bool enabled = true);
void on_actionDisplayFilterExpression_triggered();
+ void on_actionNewDisplayFilterExpression_triggered();
void displayFilterButtonClicked();
// Handle FilterAction signals
diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui
index 761f160cb1..3ee4ffadbd 100644
--- a/ui/qt/main_window.ui
+++ b/ui/qt/main_window.ui
@@ -101,6 +101,9 @@
<widget class="PreferenceEditorFrame" name="preferenceEditorFrame"/>
</item>
<item>
+ <widget class="FilterExpressionFrame" name="filterExpressionFrame"/>
+ </item>
+ <item>
<widget class="QStackedWidget" name="mainStack">
<property name="enabled">
<bool>true</bool>
@@ -698,6 +701,12 @@
<property name="movable">
<bool>false</bool>
</property>
+ <property name="iconSize">
+ <size>
+ <width>14</width>
+ <height>14</height>
+ </size>
+ </property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
@@ -705,6 +714,8 @@
<bool>true</bool>
</attribute>
<addaction name="actionDisplayFilterExpression"/>
+ <addaction name="separator"/>
+ <addaction name="actionNewDisplayFilterExpression"/>
</widget>
<widget class="QToolBar" name="wirelessToolBar">
<property name="windowTitle">
@@ -1240,12 +1251,12 @@
<property name="text">
<string>As Filter</string>
</property>
- <property name="shortcut">
- <string>Ctrl+Shift+C</string>
- </property>
<property name="toolTip">
<string>Copy this item as a display filter</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+Shift+C</string>
+ </property>
</action>
<action name="actionAnalyzeAAFSelected">
<property name="text">
@@ -2806,6 +2817,21 @@
<string>Show IEEE 802.11 wireless LAN statistics.</string>
</property>
</action>
+ <action name="actionNewDisplayFilterExpression">
+ <property name="icon">
+ <iconset resource="../../image/toolbar.qrc">
+ <normaloff>:/stock/plus-8.png</normaloff>:/stock/plus-8.png</iconset>
+ </property>
+ <property name="text">
+ <string>Add a filter button</string>
+ </property>
+ <property name="iconText">
+ <string>Expression…</string>
+ </property>
+ <property name="toolTip">
+ <string>Add a display filter button.</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
@@ -2849,6 +2875,12 @@
<header>address_editor_frame.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>FilterExpressionFrame</class>
+ <extends>QFrame</extends>
+ <header>filter_expression_frame.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources>
<include location="../../image/toolbar.qrc"/>
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index a51c293e9d..ace6fe50dd 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -760,13 +760,13 @@ void MainWindow::filterExpressionsChanged()
// Recreate filter buttons
foreach (QAction *act, main_ui_->displayFilterToolBar->actions()) {
// Permanent actions shouldn't have data
- if (act->property(dfe_property_).isValid() || act->isSeparator()) {
+ if (act->property(dfe_property_).isValid()) {
main_ui_->displayFilterToolBar->removeAction(act);
delete act;
}
}
- bool first = true;
+ // XXX Add a context menu for removing and changing buttons.
for (struct filter_expression *fe = *pfilter_expression_head; fe != NULL; fe = fe->next) {
if (!fe->enabled) continue;
QAction *dfb_action = new QAction(fe->label, main_ui_->displayFilterToolBar);
@@ -775,10 +775,6 @@ void MainWindow::filterExpressionsChanged()
dfb_action->setProperty(dfe_property_, true);
main_ui_->displayFilterToolBar->addAction(dfb_action);
connect(dfb_action, SIGNAL(triggered()), this, SLOT(displayFilterButtonClicked()));
- if (first) {
- first = false;
- main_ui_->displayFilterToolBar->insertSeparator(dfb_action);
- }
}
}
@@ -1507,6 +1503,12 @@ void MainWindow::on_actionDisplayFilterExpression_triggered()
dfe_dialog->show();
}
+void MainWindow::on_actionNewDisplayFilterExpression_triggered()
+{
+ main_ui_->filterExpressionFrame->addExpression(df_combo_box_->lineEdit()->text());
+ showAccordionFrame(main_ui_->filterExpressionFrame);
+}
+
// On Qt4 + OS X with unifiedTitleAndToolBarOnMac set it's possible to make
// the main window obnoxiously wide.