1
1
#pragma once
2
2
3
+ #include < QStandardItemModel>
4
+ #include < QSortFilterProxyModel>
3
5
#include < QtWidgets/QDialog>
4
6
#include < QtWidgets/QLineEdit>
5
7
#include < QtWidgets/QPushButton>
9
11
#include < QtWidgets/QTreeWidget>
10
12
#include < QtWidgets/QCheckBox>
11
13
#include < QtGui/QKeyEvent>
12
-
13
- #include " uitypes.h"
14
14
#include " binaryninjaapi.h"
15
+ #include " filter.h"
16
+ #include " uitypes.h"
17
+
15
18
16
19
constexpr int IndexRole = Qt::UserRole;
17
20
constexpr int ItemRole = Qt::UserRole + 1 ;
18
21
constexpr int LocationRole = Qt::UserRole + 2 ;
22
+ constexpr int IndexColumn = 0 ;
19
23
constexpr int NameColumn = 1 ;
20
24
constexpr int LocationColumn = 2 ;
21
25
22
26
23
- class BackgroundTreeWidget : public QTreeWidget
27
+ class BndbImportFilterProxyModel : public QSortFilterProxyModel
28
+ {
29
+ Q_OBJECT
30
+
31
+ protected:
32
+ bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const override ;
33
+
34
+ public:
35
+ BndbImportFilterProxyModel (QObject* parent = nullptr ) : QSortFilterProxyModel(parent) {}
36
+ void updateFilter ();
37
+ };
38
+
39
+
40
+ class BndbImportTreeView : public QTreeView
24
41
{
25
42
Q_OBJECT
26
43
public:
27
- explicit BackgroundTreeWidget (QWidget *parent);
44
+ explicit BndbImportTreeView (QWidget *parent);
28
45
29
46
Q_SIGNALS:
30
47
void addressDoubleClicked (uint64_t address);
@@ -33,18 +50,23 @@ class BackgroundTreeWidget : public QTreeWidget
33
50
virtual void keyPressEvent (QKeyEvent* event) override ;
34
51
};
35
52
53
+
36
54
/* !
37
55
38
56
\ingroup uiapi
39
57
*/
40
- class BINARYNINJAUIAPI BndbImportDialog : public QDialog
58
+ class BINARYNINJAUIAPI BndbImportDialog : public QDialog, public FilterTarget
41
59
{
42
60
Q_OBJECT
61
+
62
+ FilteredView* m_filteredView;
63
+ QWidget* m_filterWidget;
64
+ QStandardItemModel* m_model;
65
+ BndbImportFilterProxyModel* m_filterModel;
43
66
QLineEdit* m_fileEdit;
44
67
QPushButton* m_browseButton;
45
68
QWidget* m_resultsWidget;
46
- QTreeWidget* m_typesTree;
47
- QPushButton* m_previewButton;
69
+ BndbImportTreeView* m_typesTree;
48
70
QPushButton* m_importButton;
49
71
BinaryViewRef m_data;
50
72
@@ -83,16 +105,22 @@ protected Q_SLOTS:
83
105
84
106
private:
85
107
bool loadTypes ();
86
- bool isExistingType (const BinaryNinja::QualifiedName& name, bool function) const ;
87
- bool isBuiltinType (const BinaryNinja::QualifiedName& name) const ;
88
- void ApplyFunctionTypes (const std::vector<SymbolAndType>& functions);
89
- void ApplyFunctionTypesToImports (const std::vector<SymbolAndType>& functions);
90
- void ApplyDataVariables (const std::vector<SymbolAndType>& dataVariables);
91
- std::vector<SymbolRef> matchingSymbol (const SymbolRef sym, std::vector<BNSymbolType> allowed, bool allowPrefix);
92
- void navigateToItem (QTreeWidgetItem *item, int column);
93
- bool inSymbolBlackList (const SymbolRef sym);
94
- public:
108
+ static bool isBuiltinType (const BinaryNinja::QualifiedName& name);
109
+ static bool inSymbolBlackList (const SymbolRef sym);
110
+ void applyFunctionTypes (const std::vector<SymbolAndType>& functions);
111
+ void applyFunctionTypesToImports (const std::vector<SymbolAndType>& functions);
112
+ void applyDataVariables (const std::vector<SymbolAndType>& dataVariables);
113
+ std::vector<SymbolRef> matchingSymbol (const SymbolRef& sym, std::vector<BNSymbolType> allowed, bool allowPrefix);
114
+ void navigateToItem (const QModelIndex& index);
95
115
116
+ public:
96
117
BndbImportDialog (QWidget* parent, BinaryViewRef view);
97
118
~BndbImportDialog () = default ;
119
+
120
+ void setFilter (const std::string& filter) override ;
121
+ void scrollToFirstItem () override ;
122
+ void scrollToCurrentItem () override ;
123
+ void selectFirstItem () override ;
124
+ void activateFirstItem () override ;
125
+ void closeFilter () override ;
98
126
};
0 commit comments