cutter/src/widgets/SymbolsWidget.h
Paul I bebc2ec36d More c++11 (#478)
* Replace 0 and Q_NULLPTR with nullptr
* Use c++11 foreach
2018-05-04 09:58:32 +02:00

77 lines
1.8 KiB
C++

#ifndef SYMBOLSWIDGET_H
#define SYMBOLSWIDGET_H
#include <memory>
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include "Cutter.h"
#include "CutterDockWidget.h"
class MainWindow;
class QTreeWidgetItem;
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 = 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 = 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:
std::unique_ptr<Ui::SymbolsWidget> ui;
QList<SymbolDescription> symbols;
SymbolsModel *symbolsModel;
SymbolsProxyModel *symbolsProxyModel;
void setScrollMode();
};
#endif // SYMBOLSWIDGET_H