Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
filter_expression_edit.h
Go to the documentation of this file.
1
9
10#ifndef FILTER_EXPRESSION_EDIT_H
11#define FILTER_EXPRESSION_EDIT_H
12
14
15#include <QIcon>
16#include <QList>
17
19class BookmarkModel;
21
22class QAction;
23class QConcatenateTablesProxyModel;
24class QHBoxLayout;
25class QMenu;
26class QMargins;
27
54class FilterExpressionEdit : public FilterEdit
55{
56 Q_OBJECT
57
58public:
59 explicit FilterExpressionEdit(QWidget *parent = nullptr);
60
67
69 FilterHistoryModel *historyModel() const { return historyModel_; }
70
76
78 BookmarkModel *bookmarkModel() const { return bookmarkModel_; }
79
84 void setApplyActionVisible(bool visible);
85
91 void setAppliedExpression(const QString &expression);
92
94 bool isApplyActionVisible() const { return apply_visible_; }
95
100 void setPreferencesActionVisible(bool visible);
101
108 void setBookmarkIcon(const QIcon &normal, const QIcon &matching);
109
115 void setBookmarkMenuLabels(const QString &saved_section,
116 const QString &save_current,
117 const QString &remove_current,
118 const QString &manage,
119 const QString &preferences);
120
126 QConcatenateTablesProxyModel *completionModel() const { return completion_source_; }
127
134 void setButtonsLeftAligned(bool left);
135
137 bool buttonsLeftAligned() const { return buttons_left_aligned_; }
138
139signals:
141 void applied(const QString &expression);
143 void textChangedExpr(const QString &expression);
145 void validityChanged(bool valid);
147 void cleared();
148
150 void saveBookmarkRequested(const QString &expression);
152 void removeBookmarkRequested(const QString &expression);
157
158protected:
163 void applyExpression();
164
166 void changeEvent(QEvent *event) override;
167
169 bool event(QEvent *event) override;
170
172 void paintEvent(QPaintEvent *event) override;
173
174 virtual void updateButtonTranslations();
175 virtual void updateTranslations();
176
177private:
178 void rebuildBookmarkEntries();
179 void populateHistoryMenu();
180 void updateClearVisible();
181 void updateApplyEnabled();
182 void updateRemoveEnabled();
183 void updateBookmarkState();
184 void updateInlineMargins();
185 void rebuildInlineLayout();
186
187 int inlineEdge() const;
188 QMargins inlineMargins();
189
190 // Inline affordance buttons, placed by a QHBoxLayout inside the field and
191 // sized by AdaptiveToolButton (tight box, zoom-aware glyph). paintEvent()
192 // fences the icon zones off from the tint and anchors the dividers using
193 // inlineMargins(), which mirrors the layout. Parented to this line edit
194 // via the layout.
195 AdaptiveToolButton *bookmark_button_;
196 AdaptiveToolButton *clear_button_;
197 AdaptiveToolButton *history_button_;
198 AdaptiveToolButton *apply_button_;
199 QHBoxLayout *inline_layout_;
200
201 QIcon normal_bookmark_icon_;
202 QIcon matching_bookmark_icon_;
203
204 QMenu *bookmark_menu_;
205 QMenu *history_menu_;
206
207 // Static bookmark-menu actions, kept so labels/enablement can be updated.
208 QAction *save_action_;
209 QAction *remove_action_;
210 QAction *manage_action_;
211 QAction *preferences_action_;
212 QAction *static_separator_;
213 QString saved_section_label_;
214 QList<QAction *> entry_actions_;
215
216 FilterHistoryModel *historyModel_;
217 BookmarkModel *bookmarkModel_;
218 QConcatenateTablesProxyModel *completion_source_;
219
220 bool apply_visible_;
221 QString applied_expression_;
222 bool buttons_left_aligned_;
223};
224
225#endif // FILTER_EXPRESSION_EDIT_H
A flat, icon-only tool button whose footprint hugs its icon and whose icon scales with the applicatio...
Definition adaptive_tool_button.h:47
Abstract list model of saved ("bookmarked") filter expressions.
Definition bookmark_model.h:30
void changeEvent(QEvent *event) override
Event handler for changeEvents, e.g. QEvent::LanguageChange.
Definition filter_expression_edit.cpp:592
void setHistoryModel(FilterHistoryModel *model)
Sets the recent-history model. Caller-owned: the widget keeps a non-owning reference and never delete...
Definition filter_expression_edit.cpp:273
void paintEvent(QPaintEvent *event) override
Paints the field, then the bookmark/apply zone dividers on top.
Definition filter_expression_edit.cpp:617
QConcatenateTablesProxyModel * completionModel() const
The merged history+bookmark model that backs typeahead completion. Owned by the widget; references (d...
Definition filter_expression_edit.h:126
void manageBookmarksRequested()
"Manage" chosen in the bookmark menu.
void setApplyActionVisible(bool visible)
Shows or hides the apply (→) action, selecting explicit- vs implicit-apply mode. Hidden by default.
Definition filter_expression_edit.cpp:325
FilterHistoryModel * historyModel() const
The injected history model, or nullptr.
Definition filter_expression_edit.h:69
void setBookmarkModel(BookmarkModel *model)
Sets the bookmark model. Widget-owned: deleted with the widget and replacing any previous model....
Definition filter_expression_edit.cpp:292
void cleared()
The clear action was triggered (distinct from typing to empty).
BookmarkModel * bookmarkModel() const
The bookmark model, or nullptr.
Definition filter_expression_edit.h:78
void saveBookmarkRequested(const QString &expression)
"Save current" chosen in the bookmark menu.
void setAppliedExpression(const QString &expression)
Records the expression currently in effect. While the field text equals it, the apply action stays di...
Definition filter_expression_edit.cpp:466
void applyExpression()
Validates the final text and, if applyable, emits applied() and records the expression to history....
Definition filter_expression_edit.cpp:359
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...
Definition filter_expression_edit.cpp:333
bool isApplyActionVisible() const
True when the apply action is present (explicit-apply mode).
Definition filter_expression_edit.h:94
bool buttonsLeftAligned() const
True when the inline buttons are left-aligned.
Definition filter_expression_edit.h:137
bool event(QEvent *event) override
Re-syncs the inline insets once the style sheet has been applied.
Definition filter_expression_edit.cpp:607
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 acro...
Definition filter_expression_edit.cpp:345
void applied(const QString &expression)
The current expression was applied (action, or Enter).
void setPreferencesActionVisible(bool visible)
Shows or hides the bookmark menu's "preferences" item. Filter types without a relevant preferences pa...
Definition filter_expression_edit.cpp:340
void validityChanged(bool valid)
Convenience: emitted with (state == Valid || state == Deprecated).
void removeBookmarkRequested(const QString &expression)
"Remove current" chosen in the bookmark menu.
void preferencesRequested()
"Preferences" chosen in the bookmark menu.
void textChangedExpr(const QString &expression)
The expression text changed (distinct from QLineEdit::textChanged).
void setButtonsLeftAligned(bool left)
Left-aligns the inline buttons (all clustered after the bookmark, with the text to their right) inste...
Definition filter_expression_edit.cpp:503
Abstract list model of recently applied filter expressions.
Definition filter_history_model.h:30