cutter/src/widgets/RelocsWidget.h

77 lines
1.7 KiB
C
Raw Normal View History

#ifndef RELOCSWIDGET_H
#define RELOCSWIDGET_H
2017-10-02 09:41:28 +00:00
#include <memory>
#include <QAbstractTableModel>
2018-04-24 18:40:40 +00:00
#include <QSortFilterProxyModel>
#include "CutterDockWidget.h"
#include "Cutter.h"
#include "CutterTreeWidget.h"
class MainWindow;
class RelocsWidget;
2018-03-21 20:32:32 +00:00
namespace Ui {
class RelocsWidget;
}
class RelocsModel : public QAbstractTableModel
{
Q_OBJECT
friend RelocsWidget;
private:
QList<RelocDescription> *relocs;
public:
2018-04-24 18:40:40 +00:00
enum Column { VAddrColumn = 0, TypeColumn, NameColumn, ColumnCount };
enum Role { RelocDescriptionRole = Qt::UserRole, AddressRole };
2018-09-30 20:00:53 +00:00
RelocsModel(QList<RelocDescription> *relocs, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
};
2018-04-24 18:40:40 +00:00
class RelocsProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
RelocsProxyModel(RelocsModel *sourceModel, QObject *parent = nullptr);
2018-04-24 18:40:40 +00:00
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class RelocsWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit RelocsWidget(MainWindow *main, QAction *action = nullptr);
~RelocsWidget();
private slots:
void on_relocsTreeView_doubleClicked(const QModelIndex &index);
void refreshRelocs();
private:
2017-10-02 09:41:28 +00:00
std::unique_ptr<Ui::RelocsWidget> ui;
2018-04-24 18:40:40 +00:00
RelocsModel *relocsModel;
RelocsProxyModel *relocsProxyModel;
QList<RelocDescription> relocs;
CutterTreeWidget *tree;
void setScrollMode();
};
#endif // RELOCSWIDGET_H