2018-10-20 18:20:06 +00:00
|
|
|
#ifndef SEGMENTSWIDGET_H
|
|
|
|
#define SEGMENTSWIDGET_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2019-08-19 13:35:25 +00:00
|
|
|
#include "widgets/ListDockWidget.h"
|
2018-10-20 18:20:06 +00:00
|
|
|
|
|
|
|
class QAbstractItemView;
|
|
|
|
class SegmentsWidget;
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class SegmentsModel : public AddressableItemModel<QAbstractListModel>
|
2018-10-20 18:20:06 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
friend SegmentsWidget;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<SegmentDescription> *segments;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, PermColumn, ColumnCount };
|
|
|
|
enum Role { SegmentDescriptionRole = Qt::UserRole };
|
|
|
|
|
|
|
|
SegmentsModel(QList<SegmentDescription> *segments, QObject *parent = nullptr);
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
2018-10-20 18:20:06 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
QVariant headerData(int segment, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
|
|
|
|
RVA address(const QModelIndex &index) const override;
|
|
|
|
QString name(const QModelIndex &index) const override;
|
2018-10-20 18:20:06 +00:00
|
|
|
};
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class SegmentsProxyModel : public AddressableFilterProxyModel
|
2018-10-20 18:20:06 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
SegmentsProxyModel(SegmentsModel *sourceModel, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class SegmentsWidget : public ListDockWidget
|
2018-10-20 18:20:06 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit SegmentsWidget(MainWindow *main, QAction *action = nullptr);
|
|
|
|
~SegmentsWidget();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void refreshSegments();
|
|
|
|
private:
|
|
|
|
QList<SegmentDescription> segments;
|
|
|
|
SegmentsModel *segmentsModel;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SEGMENTSWIDGET_H
|