cutter/src/widgets/MemoryMapWidget.h

86 lines
1.9 KiB
C
Raw Normal View History

2018-06-12 08:43:14 +00:00
#pragma once
#include <memory>
#include "core/Cutter.h"
2018-06-12 08:43:14 +00:00
#include "CutterDockWidget.h"
#include "ListDockWidget.h"
2018-06-12 08:43:14 +00:00
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
class MemoryMapWidget;
2018-06-12 08:43:14 +00:00
2018-09-30 20:00:53 +00:00
namespace Ui {
class MemoryMapWidget;
2018-06-12 08:43:14 +00:00
}
class MainWindow;
class QTreeWidgetItem;
2021-01-24 14:50:13 +00:00
class MemoryMapModel : public AddressableItemModel<QAbstractListModel>
2018-06-12 08:43:14 +00:00
{
Q_OBJECT
friend MemoryMapWidget;
2018-06-12 08:43:14 +00:00
private:
QList<MemoryMapDescription> *memoryMaps;
public:
2021-01-24 14:50:13 +00:00
enum Column {
AddrStartColumn = 0,
AddrEndColumn,
NameColumn,
PermColumn,
CommentColumn,
ColumnCount
};
2018-06-12 08:43:14 +00:00
enum Role { MemoryDescriptionRole = Qt::UserRole };
MemoryMapModel(QList<MemoryMapDescription> *memoryMaps, QObject *parent = nullptr);
2018-06-12 08:43:14 +00:00
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
2018-06-12 08:43:14 +00:00
QVariant data(const QModelIndex &index, int role) const override;
2021-01-24 14:50:13 +00:00
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
2018-06-12 08:43:14 +00:00
};
class MemoryProxyModel : public AddressableFilterProxyModel
2018-06-12 08:43:14 +00:00
{
Q_OBJECT
public:
MemoryProxyModel(MemoryMapModel *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 MemoryMapWidget : public ListDockWidget
2018-06-12 08:43:14 +00:00
{
Q_OBJECT
public:
explicit MemoryMapWidget(MainWindow *main);
2018-06-12 08:43:14 +00:00
~MemoryMapWidget();
private slots:
void refreshMemoryMap();
private:
MemoryMapModel *memoryModel;
MemoryProxyModel *memoryProxyModel;
QList<MemoryMapDescription> memoryMaps;
RefreshDeferrer *refreshDeferrer;
2018-06-12 08:43:14 +00:00
};