Wireshark 4.7.2
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
87 bool isApplyActionVisible() const { return apply_visible_; }
88
93 void setPreferencesActionVisible(bool visible);
94
101 void setBookmarkIcon(const QIcon &normal, const QIcon &matching);
102
108 void setBookmarkMenuLabels(const QString &saved_section,
109 const QString &save_current,
110 const QString &remove_current,
111 const QString &manage,
112 const QString &preferences);
113
119 QConcatenateTablesProxyModel *completionModel() const { return completion_source_; }
120
127 void setButtonsLeftAligned(bool left);
128
130 bool buttonsLeftAligned() const { return buttons_left_aligned_; }
131
132signals:
134 void applied(const QString &expression);
136 void textChangedExpr(const QString &expression);
138 void validityChanged(bool valid);
140 void cleared();
141
143 void saveBookmarkRequested(const QString &expression);
145 void removeBookmarkRequested(const QString &expression);
150
151protected:
156 void applyExpression();
157
159 void paintEvent(QPaintEvent *event) override;
160
161private:
162 void rebuildBookmarkEntries();
163 void populateHistoryMenu();
164 void updateClearVisible();
165 void updateApplyEnabled();
166 void updateRemoveEnabled();
167 void updateBookmarkState();
168 void updateInlineMargins();
169 void rebuildInlineLayout();
170
171 QMargins inlineMargins();
172
173 // Inline affordance buttons, placed by a QHBoxLayout inside the field and
174 // sized by AdaptiveToolButton (tight box, zoom-aware glyph). paintEvent()
175 // uses their geometry to fence the icon zones off from the tint and to
176 // anchor the dividers. Parented to this line edit via the layout.
177 AdaptiveToolButton *bookmark_button_;
178 AdaptiveToolButton *clear_button_;
179 AdaptiveToolButton *history_button_;
180 AdaptiveToolButton *apply_button_;
181 QHBoxLayout *inline_layout_;
182
183 QIcon normal_bookmark_icon_;
184 QIcon matching_bookmark_icon_;
185
186 QMenu *bookmark_menu_;
187 QMenu *history_menu_;
188
189 // Static bookmark-menu actions, kept so labels/enablement can be updated.
190 QAction *save_action_;
191 QAction *remove_action_;
192 QAction *manage_action_;
193 QAction *preferences_action_;
194 QAction *static_separator_;
195 QString saved_section_label_;
196 QList<QAction *> entry_actions_;
197
198 FilterHistoryModel *historyModel_;
199 BookmarkModel *bookmarkModel_;
200 QConcatenateTablesProxyModel *completion_source_;
201
202 bool apply_visible_;
203 bool buttons_left_aligned_;
204};
205
206#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 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:275
void paintEvent(QPaintEvent *event) override
Paints the field, then the bookmark/apply zone dividers on top.
Definition filter_expression_edit.cpp:549
QConcatenateTablesProxyModel * completionModel() const
The merged history+bookmark model that backs typeahead completion. Owned by the widget; references (d...
Definition filter_expression_edit.h:119
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:327
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:294
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 applyExpression()
Validates the final text and, if applyable, emits applied() and records the expression to history....
Definition filter_expression_edit.cpp:361
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:335
bool isApplyActionVisible() const
True when the apply action is present (explicit-apply mode).
Definition filter_expression_edit.h:87
bool buttonsLeftAligned() const
True when the inline buttons are left-aligned.
Definition filter_expression_edit.h:130
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:347
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:342
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:492
Abstract list model of recently applied filter expressions.
Definition filter_history_model.h:30