cutter/src/widgets/SymbolsWidget.h

77 lines
1.8 KiB
C
Raw Normal View History

#ifndef SYMBOLSWIDGET_H
#define SYMBOLSWIDGET_H
2017-10-02 09:41:28 +00:00
#include <memory>
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include "Cutter.h"
#include "CutterDockWidget.h"
class MainWindow;
class QTreeWidgetItem;
2018-03-21 20:32:32 +00:00
namespace Ui {
class SymbolsWidget;
}
class SymbolsModel: public QAbstractListModel
{
Q_OBJECT
private:
QList<SymbolDescription> *symbols;
public:
enum Column { AddressColumn = 0, TypeColumn, NameColumn, ColumnCount };
enum Role { SymbolDescriptionRole = Qt::UserRole };
SymbolsModel(QList<SymbolDescription> *exports, QObject *parent = Q_NULLPTR);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void beginReloadSymbols();
void endReloadSymbols();
};
class SymbolsProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
SymbolsProxyModel(SymbolsModel *sourceModel, QObject *parent = Q_NULLPTR);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class SymbolsWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit SymbolsWidget(MainWindow *main, QAction *action = nullptr);
~SymbolsWidget();
private slots:
void on_symbolsTreeView_doubleClicked(const QModelIndex &index);
void refreshSymbols();
private:
2017-10-02 09:41:28 +00:00
std::unique_ptr<Ui::SymbolsWidget> ui;
QList<SymbolDescription> symbols;
SymbolsModel *symbolsModel;
SymbolsProxyModel *symbolsProxyModel;
void setScrollMode();
};
#endif // SYMBOLSWIDGET_H