summaryrefslogtreecommitdiff
path: root/ui/qt/capture_filter_edit.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-02-23 10:04:16 -0800
committerGerald Combs <gerald@wireshark.org>2016-02-26 17:28:04 +0000
commit070fc33e8501168debf879b9068da5da8e6445d6 (patch)
treeb502f9c492f44ffe73f386dfdf9ea584f1178729 /ui/qt/capture_filter_edit.cpp
parent10358a2f14a69fbbf0e3042429399e4934a79674 (diff)
downloadwireshark-070fc33e8501168debf879b9068da5da8e6445d6.tar.gz
Qt: Update selected interface filter behavior.
Change the selected interface behavior in the main window and the capture interfaces dialog to better handle multiple selections. Attempt to document this at the top of interface_tree.cpp. Move the default capture filter code from CaptureFilterEdit to MainWelcome. Add a "conflicting filter" check to CaptureEdit which updates the placeholder text. Handle conflicting filters in the main welcome screen and the capture interfaces dialog. Propagate interface selections and filter updates in the capture interfaces dialog to the main welcome screen. Consolidate some of the interface handling code in InterfaceTree and CaptureInterfacesDialog. Make sure CaptureInterfacesDialog manages the global capture options by device name instead numeric index. Start deprecating prefs.capture_devices_filter and capture_dev_user_cfilter_find. Change some member function names so that they're hopefully more clear and consistent. Ping-Bug: 11886 Change-Id: I63b06dbae29c2c45ee9252092ad54bdcbacae6e6 Reviewed-on: https://code.wireshark.org/review/14129 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/capture_filter_edit.cpp')
-rw-r--r--ui/qt/capture_filter_edit.cpp59
1 files changed, 45 insertions, 14 deletions
diff --git a/ui/qt/capture_filter_edit.cpp b/ui/qt/capture_filter_edit.cpp
index 7779ad6f5a..0a033f43dc 100644
--- a/ui/qt/capture_filter_edit.cpp
+++ b/ui/qt/capture_filter_edit.cpp
@@ -126,10 +126,7 @@ CaptureFilterEdit::CaptureFilterEdit(QWidget *parent, bool plain) :
setCompleter(new QCompleter(completion_model_, this));
setCompletionTokenChars(libpcap_primitive_chars_);
- placeholder_text_ = QString(tr("Enter a capture filter %1")).arg(UTF8_HORIZONTAL_ELLIPSIS);
-#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
- setPlaceholderText(placeholder_text_);
-#endif
+ setConflict(false);
if (!plain_) {
bookmark_button_ = new StockIconToolButton(this, "x-capture-filter-bookmark");
@@ -215,7 +212,7 @@ CaptureFilterEdit::CaptureFilterEdit(QWidget *parent, bool plain) :
QThread *syntax_thread = new QThread;
syntax_worker_ = new CaptureFilterSyntaxWorker;
syntax_worker_->moveToThread(syntax_thread);
- connect(wsApp, SIGNAL(appInitialized()), this, SLOT(initCaptureFilter()));
+ connect(wsApp, SIGNAL(appInitialized()), this, SLOT(updateBookmarkMenu()));
connect(wsApp, SIGNAL(captureFilterListChanged()), this, SLOT(updateBookmarkMenu()));
connect(syntax_thread, SIGNAL(started()), syntax_worker_, SLOT(start()));
connect(syntax_thread, SIGNAL(started()), this, SLOT(checkFilter()));
@@ -294,12 +291,55 @@ void CaptureFilterEdit::resizeEvent(QResizeEvent *)
}
}
+void CaptureFilterEdit::setConflict(bool conflict)
+{
+ if (conflict) {
+ //: This is a very long concept that needs to fit into a short space.
+ placeholder_text_ = tr("Multiple filters selected. Override them here or leave this blank to preserve them.");
+ setToolTip(tr("<p>The interfaces you have selected have different capture filters."
+ " Typing a filter here will override them. Doing nothing will"
+ " preserve them.</p>"));
+ } else {
+ placeholder_text_ = QString(tr("Enter a capture filter %1")).arg(UTF8_HORIZONTAL_ELLIPSIS);
+ setToolTip(QString());
+ }
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ setPlaceholderText(placeholder_text_);
+#endif
+}
+
+// XXX Make this private along with setConflict.
+QPair<const QString, bool> CaptureFilterEdit::getSelectedFilter()
+{
+ QString user_filter;
+ bool filter_conflict = false;
+#ifdef HAVE_LIBPCAP
+ int selected_devices = 0;
+
+ for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
+ interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
+ if (device.selected) {
+ selected_devices++;
+ if (selected_devices == 1) {
+ user_filter = device.cfilter;
+ } else {
+ if (user_filter.compare(device.cfilter)) {
+ filter_conflict = true;
+ }
+ }
+ }
+ }
+#endif // HAVE_LIBPCAP
+ return QPair<const QString, bool>(user_filter, filter_conflict);
+}
+
void CaptureFilterEdit::checkFilter(const QString& filter)
{
setSyntaxState(Busy);
popFilterSyntaxStatus();
bool empty = filter.isEmpty();
+ setConflict(false);
if (bookmark_button_) {
bool match = false;
@@ -385,15 +425,6 @@ void CaptureFilterEdit::updateBookmarkMenu()
checkFilter();
}
-void CaptureFilterEdit::initCaptureFilter()
-{
-#ifdef HAVE_LIBPCAP
- setText(global_capture_opts.default_options.cfilter);
-#endif // HAVE_LIBPCAP
-
- updateBookmarkMenu();
-}
-
void CaptureFilterEdit::setFilterSyntaxState(QString filter, int state, QString err_msg)
{
if (filter.compare(text()) == 0) { // The user hasn't changed the filter