cutter/src/widgets/RelocsWidget.h
xarkes ab27e09b91 Splitted Cutter.h and moved everything in core (#1201)
Sometimes it is not necessary to include the whole Cutter.h file
Hence, it's been splitted so you can include only what you require
E.g. #include "core/CutterCommon.h" to have access to the common types
2019-02-22 17:50:45 +01:00

77 lines
1.7 KiB
C++

#ifndef RELOCSWIDGET_H
#define RELOCSWIDGET_H
#include <memory>
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include "CutterDockWidget.h"
#include "core/Cutter.h"
#include "CutterTreeWidget.h"
class MainWindow;
class RelocsWidget;
namespace Ui {
class RelocsWidget;
}
class RelocsModel : public QAbstractTableModel
{
Q_OBJECT
friend RelocsWidget;
private:
QList<RelocDescription> *relocs;
public:
enum Column { VAddrColumn = 0, TypeColumn, NameColumn, ColumnCount };
enum Role { RelocDescriptionRole = Qt::UserRole, AddressRole };
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;
};
class RelocsProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
RelocsProxyModel(RelocsModel *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 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:
std::unique_ptr<Ui::RelocsWidget> ui;
RelocsModel *relocsModel;
RelocsProxyModel *relocsProxyModel;
QList<RelocDescription> relocs;
CutterTreeWidget *tree;
void setScrollMode();
};
#endif // RELOCSWIDGET_H