cutter/src/widgets/HeadersWidget.h

85 lines
1.8 KiB
C
Raw Normal View History

2018-05-21 17:34:41 +00:00
#ifndef HEADERSWIDGET_H
#define HEADERSWIDGET_H
#include <memory>
#include "core/Cutter.h"
#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;
class HeadersWidget;
2018-05-21 17:34:41 +00:00
class HeadersModel: public AddressableItemModel<QAbstractListModel>
2018-05-21 17:34:41 +00:00
{
Q_OBJECT
friend HeadersWidget;
2018-05-21 17:34:41 +00:00
private:
QList<HeaderDescription> *headers;
public:
enum Column { OffsetColumn = 0, NameColumn, ValueColumn, CommentColumn, ColumnCount };
2018-05-21 17:34:41 +00:00
enum Role { HeaderDescriptionRole = Qt::UserRole };
HeadersModel(QList<HeaderDescription> *headers, QObject *parent = nullptr);
2018-05-21 17:34:41 +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
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
};
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;
};
class HeadersWidget : public ListDockWidget
2018-05-21 17:34:41 +00:00
{
Q_OBJECT
public:
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