cutter/src/widgets/MemoryMapWidget.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

86 lines
1.8 KiB
C++

#pragma once
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidget;
class MemoryMapWidget;
namespace Ui {
class MemoryMapWidget;
}
class MainWindow;
class QTreeWidgetItem;
class MemoryMapModel: public QAbstractListModel
{
Q_OBJECT
friend MemoryMapWidget;
private:
QList<MemoryMapDescription> *memoryMaps;
public:
enum Column { AddrStartColumn = 0, AddrEndColumn, NameColumn, PermColumn, ColumnCount };
enum Role { MemoryDescriptionRole = Qt::UserRole };
MemoryMapModel(QList<MemoryMapDescription> *memoryMaps, QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
};
class MemoryProxyModel : public QSortFilterProxyModel
{
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 CutterDockWidget
{
Q_OBJECT
public:
explicit MemoryMapWidget(MainWindow *main, QAction *action = nullptr);
~MemoryMapWidget();
private slots:
void on_memoryTreeView_doubleClicked(const QModelIndex &index);
void refreshMemoryMap();
private:
std::unique_ptr<Ui::MemoryMapWidget> ui;
MemoryMapModel *memoryModel;
MemoryProxyModel *memoryProxyModel;
QList<MemoryMapDescription> memoryMaps;
void setScrollMode();
RefreshDeferrer *refreshDeferrer;
};