1 #ifndef SYMBOLSWIDGET_H
2 #define SYMBOLSWIDGET_H
3 
4 #include <memory>
5 #include <QAbstractListModel>
6 #include <QSortFilterProxyModel>
7 
8 #include "core/Cutter.h"
9 #include "CutterDockWidget.h"
10 #include "widgets/ListDockWidget.h"
11 
12 
13 class MainWindow;
14 class QTreeWidgetItem;
15 class SymbolsWidget;
16 
17 
18 class SymbolsModel: public AddressableItemModel<QAbstractListModel>
19 {
20     Q_OBJECT
21 
22     friend SymbolsWidget;
23 
24 private:
25     QList<SymbolDescription> *symbols;
26 
27 public:
28     enum Column { AddressColumn = 0, TypeColumn, NameColumn, CommentColumn, ColumnCount };
29     enum Role { SymbolDescriptionRole = Qt::UserRole };
30 
31     SymbolsModel(QList<SymbolDescription> *exports, QObject *parent = nullptr);
32 
33     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
34     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
35 
36     QVariant data(const QModelIndex &index, int role) const override;
37     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
38 
39     RVA address(const QModelIndex &index) const override;
40     QString name(const QModelIndex &index) const override;
41 };
42 
43 class SymbolsProxyModel : public AddressableFilterProxyModel
44 {
45     Q_OBJECT
46 
47 public:
48     SymbolsProxyModel(SymbolsModel *sourceModel, QObject *parent = nullptr);
49 
50 protected:
51     bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
52     bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
53 };
54 
55 
56 class SymbolsWidget : public ListDockWidget
57 {
58     Q_OBJECT
59 
60 public:
61     explicit SymbolsWidget(MainWindow *main);
62     ~SymbolsWidget();
63 
64 private slots:
65     void refreshSymbols();
66 
67 private:
68     QList<SymbolDescription> symbols;
69     SymbolsModel *symbolsModel;
70     SymbolsProxyModel *symbolsProxyModel;
71 
72 };
73 
74 #endif // SYMBOLSWIDGET_H
75