2018-05-21 17:34:41 +00:00
|
|
|
#ifndef HEADERSWIDGET_H
|
|
|
|
#define HEADERSWIDGET_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2019-08-19 13:35:25 +00:00
|
|
|
#include "ListDockWidget.h"
|
2018-05-21 17:34:41 +00:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
|
|
|
class MainWindow;
|
|
|
|
class QTreeWidget;
|
|
|
|
|
2018-09-30 20:00:53 +00:00
|
|
|
namespace Ui {
|
|
|
|
class HeadersWidget;
|
2018-05-21 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MainWindow;
|
|
|
|
class QTreeWidgetItem;
|
2018-10-10 11:33:55 +00:00
|
|
|
class HeadersWidget;
|
2018-05-21 17:34:41 +00:00
|
|
|
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class HeadersModel: public AddressableItemModel<QAbstractListModel>
|
2018-05-21 17:34:41 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-10-10 11:33:55 +00:00
|
|
|
friend HeadersWidget;
|
|
|
|
|
2018-05-21 17:34:41 +00:00
|
|
|
private:
|
|
|
|
QList<HeaderDescription> *headers;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Column { OffsetColumn = 0, NameColumn, ValueColumn, ColumnCount };
|
|
|
|
enum Role { HeaderDescriptionRole = Qt::UserRole };
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
HeadersModel(QList<HeaderDescription> *headers, QObject *parent = nullptr);
|
2018-05-21 17:34:41 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
2018-05-21 17:34:41 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
|
|
|
|
RVA address(const QModelIndex &index) const override;
|
|
|
|
QString name(const QModelIndex &index) const override;
|
2018-05-21 17:34:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class HeadersProxyModel : public AddressableFilterProxyModel
|
2018-05-21 17:34:41 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
HeadersProxyModel(HeadersModel *sourceModel, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class HeadersWidget : public ListDockWidget
|
2018-05-21 17:34:41 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-05-22 11:49:34 +00:00
|
|
|
explicit HeadersWidget(MainWindow *main);
|
2018-05-21 17:34:41 +00:00
|
|
|
~HeadersWidget();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void refreshHeaders();
|
|
|
|
|
|
|
|
private:
|
|
|
|
HeadersModel *headersModel;
|
|
|
|
HeadersProxyModel *headersProxyModel;
|
|
|
|
QList<HeaderDescription> headers;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // HEADERSWIDGET_H
|