-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathfilter.h
More file actions
114 lines (84 loc) · 2.38 KB
/
filter.h
File metadata and controls
114 lines (84 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#pragma once
#include <QtWidgets/QLineEdit>
#include "binaryninjaapi.h"
#include "uicontext.h"
/*!
\defgroup filter Filter
\ingroup uiapi
*/
/*!
\ingroup filter
*/
enum BINARYNINJAUIAPI FilterOption {
NoFilterOption = 0,
CaseSensitiveOption = 1,
UseRegexOption = 2,
};
Q_DECLARE_FLAGS(FilterOptions, FilterOption)
/*!
\ingroup filter
*/
class BINARYNINJAUIAPI FilterTarget
{
public:
virtual ~FilterTarget() {}
virtual void setFilter(const std::string& filter, FilterOptions options) = 0;
virtual void scrollToFirstItem() = 0;
virtual void scrollToCurrentItem() = 0;
// Select an item, typically the first, if none is already selected.
virtual void ensureSelection() = 0;
// Activate the selected item, typically in response to the user
// pressing the return key.
virtual void activateSelection() = 0;
// Transfer focus away from the `FilterEdit`. By default, focus
// is transferred to `this` if it is an instance of `QWidget`.
virtual void closeFilter();
};
/*!
\ingroup filter
*/
class BINARYNINJAUIAPI FilterEdit : public QLineEdit
{
Q_OBJECT
FilterTarget* m_target;
FilterOptions m_filterOptions;
QAction* m_clearAction;
QAction* m_regexAction;
QAction* m_regexWarningAction;
QAction* m_caseSensitivityAction;
QIcon getActionIcon(const QString& iconName, bool enabled) const;
public:
FilterEdit(FilterTarget* target);
void showRegexToggle(bool enabled);
void setRegexValidationError(const QString& error);
FilterOptions getFilterOptions() const { return m_filterOptions; }
Q_SIGNALS:
void optionsChanged(FilterOptions options);
protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void keyPressEvent(QKeyEvent* event) override;
};
/*!
\ingroup filter
*/
class BINARYNINJAUIAPI FilteredView : public QWidget
{
Q_OBJECT
FilterTarget* m_target;
QWidget* m_widget;
FilterEdit* m_filter;
QTimer* m_timer;
public:
FilteredView(QWidget* parent, QWidget* filtered, FilterTarget* target, FilterEdit* edit = nullptr);
void setFilterPlaceholderText(const QString& text);
void setFilterToolTip(const QString& text);
void updateFonts();
void clearFilter();
void showFilter(const QString& initialText);
void focusAndSelectFilter();
bool hasFilterText() const;
static bool match(const std::string& name, const std::string& filter, bool caseSensitive = false);
private Q_SLOTS:
void timerStart();
void filterChanged();
};