Wireshark 4.7.2
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
CaptureFilterEntry Class Reference

Capture-filter entry: the FilterExpressionEdit leaf for libpcap filters. More...

#include <capture_filter_entry.h>

Inheritance diagram for CaptureFilterEntry:
FilterExpressionEdit FilterEdit

Public Slots

void recheck ()
 Re-validates the current text (e.g. when the interface selection changes).
Public Slots inherited from FilterEdit
void insertFilter (const QString &filter)
 Inserts filter at the cursor, padding with spaces as needed to keep the expression well-formed. Replaces a current selection.

Signals

void captureFilterSyntaxChanged (bool valid)
 Capture-filter validity changed (from the base validityChanged).
void captureFilterChanged (const QString &filter)
 Capture-filter text changed (from the base textChangedExpr).
void startCapture ()
 Capture requested via Enter (from the base applied).
void addBookmark (const QString &filter)
 Bookmark requested for the current expression.
Signals inherited from FilterExpressionEdit
void applied (const QString &expression)
 The current expression was applied (action, or Enter).
void textChangedExpr (const QString &expression)
 The expression text changed (distinct from QLineEdit::textChanged).
void validityChanged (bool valid)
 Convenience: emitted with (state == Valid || state == Deprecated).
void cleared ()
 The clear action was triggered (distinct from typing to empty).
void saveBookmarkRequested (const QString &expression)
 "Save current" chosen in the bookmark menu.
void removeBookmarkRequested (const QString &expression)
 "Remove current" chosen in the bookmark menu.
void manageBookmarksRequested ()
 "Manage" chosen in the bookmark menu.
void preferencesRequested ()
 "Preferences" chosen in the bookmark menu.
Signals inherited from FilterEdit
void syntaxStateChanged (FilterEdit::SyntaxState state)
 Emitted whenever the syntax state changes.

Public Member Functions

 CaptureFilterEntry (QWidget *parent=nullptr)
void setConflict (bool conflict=false)
 Sets the conflict state shown when selected interfaces disagree on their capture filter (adjusts placeholder text and tooltip).
Public Member Functions inherited from FilterExpressionEdit
 FilterExpressionEdit (QWidget *parent=nullptr)
void setHistoryModel (FilterHistoryModel *model)
 Sets the recent-history model. Caller-owned: the widget keeps a non-owning reference and never deletes it. The history action and merged completion source pick it up.
FilterHistoryModelhistoryModel () const
 The injected history model, or nullptr.
void setBookmarkModel (BookmarkModel *model)
 Sets the bookmark model. Widget-owned: deleted with the widget and replacing any previous model. Enables the bookmark action and menu.
BookmarkModelbookmarkModel () const
 The bookmark model, or nullptr.
void setApplyActionVisible (bool visible)
 Shows or hides the apply (→) action, selecting explicit- vs implicit-apply mode. Hidden by default.
bool isApplyActionVisible () const
 True when the apply action is present (explicit-apply mode).
void setPreferencesActionVisible (bool visible)
 Shows or hides the bookmark menu's "preferences" item. Filter types without a relevant preferences pane (e.g. capture) hide it.
void setBookmarkIcon (const QIcon &normal, const QIcon &matching)
 Sets the leading bookmark glyphs: normal in the per-filter colour and matching shown when the current text is already a saved bookmark. Leaves supply both (same SVG, different theme token); the base swaps between them as the text matches a bookmark.
void setBookmarkMenuLabels (const QString &saved_section, const QString &save_current, const QString &remove_current, const QString &manage, const QString &preferences)
 Supplies the bookmark-menu label strings. Menu structure, behaviour and enablement are identical across filter types; only the wording differs, so leaves provide it here.
QConcatenateTablesProxyModel * completionModel () const
 The merged history+bookmark model that backs typeahead completion. Owned by the widget; references (does not own) its sources. Leaves point their FilterCompleter at this.
void setButtonsLeftAligned (bool left)
 Left-aligns the inline buttons (all clustered after the bookmark, with the text to their right) instead of right-anchoring the trailing trio. Persisted in recent.gui_geometry_leftalign_actions, so display and capture both honour the saved preference.
bool buttonsLeftAligned () const
 True when the inline buttons are left-aligned.
Public Member Functions inherited from FilterEdit
 FilterEdit (QWidget *parent=nullptr)
SyntaxState state () const
 Current syntax state.
QString syntaxStateName () const
 Lowercase state name used for QSS property matching.
void setValidator (FilterValidator *validator)
 Installs the filter validator. Widget-owned (deleted with the widget, and replaces any previous validator).
FilterValidatorvalidator () const
 The installed filter validator, or nullptr.
void setCompleter (FilterCompleter *completer)
 Installs the filter completer. Widget-owned, and also set as the QLineEdit completer so the native typeahead popup works.
FilterCompletercompleter () const
 The installed filter completer, or nullptr.
QString lastError () const
 Short error message from the last validation, or empty.
QString lastErrorFull () const
 Full, location-annotated error message, or empty.
QString deprecatedToken () const
 Deprecated token from the last validation, or empty.

Static Public Member Functions

static QPair< const QString, bool > getSelectedFilter ()
 The capture filter common to the selected interfaces.

Additional Inherited Members

Public Types inherited from FilterEdit
enum class  SyntaxState {
  Empty , Busy , Intermediate , Invalid ,
  Deprecated , Valid
}
 Visual/semantic state of the current text, mapped from the validator. More...
Protected Member Functions inherited from FilterExpressionEdit
void applyExpression ()
 Validates the final text and, if applyable, emits applied() and records the expression to history. No-op when empty or Invalid.
void paintEvent (QPaintEvent *event) override
 Paints the field, then the bookmark/apply zone dividers on top.
Protected Member Functions inherited from FilterEdit
void setState (SyntaxState state)
 Sets the state, re-polishes the style for the new QSS property, and emits syntaxStateChanged() if it changed.
void validateNow ()
 Runs the validator against the current text and updates the state.
Properties inherited from FilterEdit
QString syntaxState

Detailed Description

Capture-filter entry: the FilterExpressionEdit leaf for libpcap filters.

Wires the capture validator/completer/history/bookmark backends, runs in implicit-apply mode, and translates the base's generic signals to the capture-filter vocabulary (captureFilterSyntaxChanged / captureFilterChanged / startCapture / addBookmark).

This is the capture-filter widget used everywhere capture filters are entered (welcome page and Capture Options main field); the old SyntaxLineEdit-based CaptureFilterEdit and the CaptureFilterCombo wrapper have been removed. Inline table-cell editors (per-interface rows, the saved-filter manager) use a plain FilterEdit with a capture validator instead, as they need no in-line chrome.

Member Function Documentation

◆ getSelectedFilter()

QPair< const QString, bool > CaptureFilterEntry::getSelectedFilter ( )
static

The capture filter common to the selected interfaces.

Returns
(filter, conflict): empty/false if none selected, (filter, false) if all agree, (empty, true) if they differ.

The documentation for this class was generated from the following files: