aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/main_welcome.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-01-18 16:02:48 -0800
committerGerald Combs <gerald@wireshark.org>2016-01-27 16:13:19 +0000
commite57bb1919c80a2d1c245d539f6450b9b9defcb68 (patch)
tree0b4ab4fb919af94d7c92e313b2331894457b955f /ui/qt/main_welcome.cpp
parent841f636dc075a306cd048e7f954b8cba5fa6960c (diff)
Make Qt UI capture filter behavior more closely match the GTK+ UI.
If the user enters a capture filter in the Capture Interfaces dialog and presses "Start", make sure we copy the filter to the main welcome screen. Back out capture filter code from g0ce9ac4. Leave out the code that set the global capture filter. Move the code that set individual capture filters to the welcome screen. Fix multiple interface selection in the welcome screen. Rename allFilterComboBox in the capture interfaces dialog to captureFilterComboBox to match the main welcome screen. If the user starts typing in captureFilterComboBox, make sure the "Capture Filter" column is visible. Update the "Capture Filter" column as the user types. Conversely, if the user edits the "Capture Filter" column, update captureFilterComboBox accordingly. If we're editing a per-interface filter make sure we commit its contents before starting capture. Map our device index directly to each tree item instead of using a separate map which will no longer be valid any time our sort order changes (which we do right away in our constructor). Don't set prefs.capture_devices_filter in the Qt UI. The GTK+ UI doesn't and doing so can lead to surprising behavior. Note that it's mostly unused. Note that we don't multiple selected filters very well. Ping-Bug: 11886 Change-Id: I3c052f4f464411e2fb8fb7d96b218e1ce2bac3fd Reviewed-on: https://code.wireshark.org/review/13410 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/main_welcome.cpp')
-rw-r--r--ui/qt/main_welcome.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp
index 87341b6869..a789132f78 100644
--- a/ui/qt/main_welcome.cpp
+++ b/ui/qt/main_welcome.cpp
@@ -27,6 +27,8 @@
#include <epan/prefs.h>
+#include "ui/capture_globals.h"
+
#include "wsutil/ws_version_info.h"
#include "main_welcome.h"
@@ -171,6 +173,8 @@ MainWelcome::MainWelcome(QWidget *parent) :
#endif
connect(welcome_ui_->interfaceTree, SIGNAL(interfacesUpdated()),
welcome_ui_->captureFilterComboBox, SIGNAL(interfacesChanged()));
+ connect(welcome_ui_->captureFilterComboBox->lineEdit(), SIGNAL(textEdited(QString)),
+ this, SLOT(captureFilterTextEdited(QString)));
connect(welcome_ui_->captureFilterComboBox, SIGNAL(pushFilterSyntaxStatus(const QString&)),
this, SIGNAL(pushFilterSyntaxStatus(const QString&)));
connect(welcome_ui_->captureFilterComboBox, SIGNAL(popFilterSyntaxStatus()),
@@ -207,6 +211,14 @@ const QString MainWelcome::captureFilter()
return welcome_ui_->captureFilterComboBox->currentText();
}
+void MainWelcome::setCaptureFilter(const QString capture_filter)
+{
+ // capture_filter comes from the current filter in
+ // CaptureInterfacesDialog. We need to find a good way to handle
+ // multiple filters.
+ welcome_ui_->captureFilterComboBox->lineEdit()->setText(capture_filter);
+}
+
void MainWelcome::appInitialized()
{
// XXX Add a "check for updates" link?
@@ -234,6 +246,37 @@ void MainWelcome::appInitialized()
splash_overlay_ = NULL;
}
+// Update each selected device cfilter when the user changes the contents
+// of the capture filter lineedit. We do so here so that we don't clobber
+// filters set in the Capture Options / Interfaces dialog or ones set via
+// the command line.
+void MainWelcome::captureFilterTextEdited(const QString capture_filter)
+{
+ if (global_capture_opts.num_selected > 0) {
+ interface_t device;
+
+ for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
+ device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
+ if (!device.selected) {
+ continue;
+ }
+ // if (device.active_dlt == -1) {
+ // simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The link type of interface %s was not specified.", device.name);
+ // continue; /* Programming error: somehow managed to select an "unsupported" entry */
+ // }
+ g_array_remove_index(global_capture_opts.all_ifaces, i);
+ g_free(device.cfilter);
+ if (capture_filter.isEmpty()) {
+ device.cfilter = NULL;
+ } else {
+ device.cfilter = qstring_strdup(capture_filter);
+ }
+ g_array_insert_val(global_capture_opts.all_ifaces, i, device);
+ // update_filter_string(device.name, filter_text);
+ }
+ }
+}
+
void MainWelcome::interfaceDoubleClicked(QTreeWidgetItem *item, int)
{
if (item) {