| Wireshark 4.7.3 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
13#include <ui/qt/widgets/filter_edit.h>
14
15#include <QIcon>
16#include <QList>
17
18 class FilterHistoryModel;
19 class BookmarkModel;
20 class AdaptiveToolButton;
21
22 class QAction;
23 class QConcatenateTablesProxyModel;
24 class QHBoxLayout;
25 class QMenu;
26 class QMargins;
27
54 class FilterExpressionEdit : public FilterEdit
55{
56 Q_OBJECT
57
58 public:
59 explicit FilterExpressionEdit(QWidget *parent = nullptr);
60
66 void setHistoryModel(FilterHistoryModel *model);
67
69 FilterHistoryModel *historyModel() const { return historyModel_; }
70
75 void setBookmarkModel(BookmarkModel *model);
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);
147 void manageBookmarksRequested();
149 void preferencesRequested();
150
151 protected:
156 void applyExpression();
157
159 void paintEvent(QPaintEvent *event) override;
160
161 private:
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
AdaptiveToolButton
A flat, icon-only tool button whose footprint hugs its icon and whose icon scales with the applicatio...
Definition adaptive_tool_button.h:47
BookmarkModel
Abstract list model of saved ("bookmarked") filter expressions.
Definition bookmark_model.h:30
FilterExpressionEdit::setHistoryModel
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
FilterExpressionEdit::paintEvent
void paintEvent(QPaintEvent *event) override
Paints the field, then the bookmark/apply zone dividers on top.
Definition filter_expression_edit.cpp:549
FilterExpressionEdit::completionModel
QConcatenateTablesProxyModel * completionModel() const
The merged history+bookmark model that backs typeahead completion. Owned by the widget; references (d...
Definition filter_expression_edit.h:119
FilterExpressionEdit::manageBookmarksRequested
void manageBookmarksRequested()
"Manage" chosen in the bookmark menu.
FilterExpressionEdit::setApplyActionVisible
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
FilterExpressionEdit::historyModel
FilterHistoryModel * historyModel() const
The injected history model, or nullptr.
Definition filter_expression_edit.h:69
FilterExpressionEdit::setBookmarkModel
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
FilterExpressionEdit::cleared
void cleared()
The clear action was triggered (distinct from typing to empty).
FilterExpressionEdit::bookmarkModel
BookmarkModel * bookmarkModel() const
The bookmark model, or nullptr.
Definition filter_expression_edit.h:78
FilterExpressionEdit::saveBookmarkRequested
void saveBookmarkRequested(const QString &expression)
"Save current" chosen in the bookmark menu.
FilterExpressionEdit::applyExpression
void applyExpression()
Validates the final text and, if applyable, emits applied() and records the expression to history....
Definition filter_expression_edit.cpp:361
FilterExpressionEdit::setBookmarkIcon
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
FilterExpressionEdit::isApplyActionVisible
bool isApplyActionVisible() const
True when the apply action is present (explicit-apply mode).
Definition filter_expression_edit.h:87
FilterExpressionEdit::buttonsLeftAligned
bool buttonsLeftAligned() const
True when the inline buttons are left-aligned.
Definition filter_expression_edit.h:130
FilterExpressionEdit::setBookmarkMenuLabels
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
FilterExpressionEdit::applied
void applied(const QString &expression)
The current expression was applied (action, or Enter).
FilterExpressionEdit::setPreferencesActionVisible
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
FilterExpressionEdit::validityChanged
void validityChanged(bool valid)
Convenience: emitted with (state == Valid || state == Deprecated).
FilterExpressionEdit::removeBookmarkRequested
void removeBookmarkRequested(const QString &expression)
"Remove current" chosen in the bookmark menu.
FilterExpressionEdit::preferencesRequested
void preferencesRequested()
"Preferences" chosen in the bookmark menu.
FilterExpressionEdit::textChangedExpr
void textChangedExpr(const QString &expression)
The expression text changed (distinct from QLineEdit::textChanged).
FilterExpressionEdit::setButtonsLeftAligned
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
FilterHistoryModel
Abstract list model of recently applied filter expressions.
Definition filter_history_model.h:30
filter_edit.h