11#pragma once
22
3+ #include < QStandardItemModel>
4+ #include < QSortFilterProxyModel>
35#include < QtWidgets/QDialog>
46#include < QtWidgets/QLineEdit>
57#include < QtWidgets/QPushButton>
911#include < QtWidgets/QTreeWidget>
1012#include < QtWidgets/QCheckBox>
1113#include < QtGui/QKeyEvent>
12-
13- #include " uitypes.h"
1414#include " binaryninjaapi.h"
15+ #include " filter.h"
16+ #include " uitypes.h"
17+
1518
1619constexpr int IndexRole = Qt::UserRole;
1720constexpr int ItemRole = Qt::UserRole + 1 ;
1821constexpr int LocationRole = Qt::UserRole + 2 ;
22+ constexpr int IndexColumn = 0 ;
1923constexpr int NameColumn = 1 ;
2024constexpr int LocationColumn = 2 ;
2125
2226
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
2441{
2542 Q_OBJECT
2643public:
27- explicit BackgroundTreeWidget (QWidget *parent);
44+ explicit BndbImportTreeView (QWidget *parent);
2845
2946Q_SIGNALS:
3047 void addressDoubleClicked (uint64_t address);
@@ -33,18 +50,23 @@ class BackgroundTreeWidget : public QTreeWidget
3350 virtual void keyPressEvent (QKeyEvent* event) override ;
3451};
3552
53+
3654/* !
3755
3856 \ingroup uiapi
3957*/
40- class BINARYNINJAUIAPI BndbImportDialog : public QDialog
58+ class BINARYNINJAUIAPI BndbImportDialog : public QDialog, public FilterTarget
4159{
4260 Q_OBJECT
61+
62+ FilteredView* m_filteredView;
63+ QWidget* m_filterWidget;
64+ QStandardItemModel* m_model;
65+ BndbImportFilterProxyModel* m_filterModel;
4366 QLineEdit* m_fileEdit;
4467 QPushButton* m_browseButton;
4568 QWidget* m_resultsWidget;
46- QTreeWidget* m_typesTree;
47- QPushButton* m_previewButton;
69+ BndbImportTreeView* m_typesTree;
4870 QPushButton* m_importButton;
4971 BinaryViewRef m_data;
5072
@@ -83,16 +105,22 @@ protected Q_SLOTS:
83105
84106private:
85107 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);
95115
116+ public:
96117 BndbImportDialog (QWidget* parent, BinaryViewRef view);
97118 ~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 ;
98126};
0 commit comments