2017-03-29 10:18:37 +00:00
|
|
|
#ifndef SECTIONSWIDGET_H
|
|
|
|
#define SECTIONSWIDGET_H
|
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
#include <memory>
|
2018-11-12 08:22:28 +00:00
|
|
|
#include <map>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-11-26 11:09:35 +00:00
|
|
|
#include <QtWidgets/QToolButton>
|
2018-05-03 07:52:30 +00:00
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
2018-11-12 08:22:28 +00:00
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QHash>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
#include "Cutter.h"
|
|
|
|
#include "CutterDockWidget.h"
|
|
|
|
|
2018-11-10 09:17:52 +00:00
|
|
|
class CutterTreeView;
|
2018-05-03 07:52:30 +00:00
|
|
|
class QAbstractItemView;
|
|
|
|
class MainWindow;
|
2018-10-10 11:33:55 +00:00
|
|
|
class SectionsWidget;
|
2018-11-12 08:22:28 +00:00
|
|
|
class SectionAddrDock;
|
2018-10-20 18:20:06 +00:00
|
|
|
class QuickFilterView;
|
2018-11-12 08:22:28 +00:00
|
|
|
class QGraphicsView;
|
|
|
|
class QGraphicsRectItem;
|
2017-05-03 09:09:57 +00:00
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
class SectionsModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-10-10 11:33:55 +00:00
|
|
|
friend SectionsWidget;
|
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
private:
|
|
|
|
QList<SectionDescription> *sections;
|
|
|
|
|
|
|
|
public:
|
2018-05-05 10:11:44 +00:00
|
|
|
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, EntropyColumn, ColumnCount };
|
2018-05-03 07:52:30 +00:00
|
|
|
enum Role { SectionDescriptionRole = Qt::UserRole };
|
|
|
|
|
2018-05-04 07:58:32 +00:00
|
|
|
SectionsModel(QList<SectionDescription> *sections, QObject *parent = nullptr);
|
2018-05-03 07:52:30 +00:00
|
|
|
|
|
|
|
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 SectionsProxyModel : public QSortFilterProxyModel
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
SectionsProxyModel(SectionsModel *sourceModel, QObject *parent = nullptr);
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
protected:
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SectionsWidget : public CutterDockWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
explicit SectionsWidget(MainWindow *main, QAction *action = nullptr);
|
2018-05-03 07:52:30 +00:00
|
|
|
~SectionsWidget();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void refreshSections();
|
2018-02-02 15:56:39 +00:00
|
|
|
void onSectionsDoubleClicked(const QModelIndex &index);
|
2018-11-12 08:22:28 +00:00
|
|
|
void onSectionsSeekChanged(RVA addr);
|
2018-02-02 15:56:39 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private:
|
2018-05-03 07:52:30 +00:00
|
|
|
QList<SectionDescription> sections;
|
|
|
|
SectionsModel *sectionsModel;
|
2018-11-12 08:22:28 +00:00
|
|
|
SectionsProxyModel *proxyModel;
|
2018-11-10 09:17:52 +00:00
|
|
|
CutterTreeView *sectionsTable;
|
2018-05-03 07:52:30 +00:00
|
|
|
MainWindow *main;
|
2018-10-20 18:20:06 +00:00
|
|
|
QWidget *dockWidgetContents;
|
|
|
|
QuickFilterView *quickFilterView;
|
2018-11-12 08:22:28 +00:00
|
|
|
|
2018-11-26 11:09:35 +00:00
|
|
|
QWidget *addrDockWidget;
|
2018-11-12 08:22:28 +00:00
|
|
|
SectionAddrDock *rawAddrDock;
|
|
|
|
SectionAddrDock *virtualAddrDock;
|
2018-11-26 11:09:35 +00:00
|
|
|
QToolButton *toggleButton;
|
2018-11-12 08:22:28 +00:00
|
|
|
|
|
|
|
int indicatorWidth;
|
|
|
|
int indicatorHeight;
|
|
|
|
int indicatorParamPosY;
|
|
|
|
void drawIndicatorOnAddrDocks();
|
|
|
|
void updateIndicator(SectionAddrDock *targetDock, QString name, float ratio);
|
2018-11-26 11:09:35 +00:00
|
|
|
void updateToggle();
|
2018-11-12 08:22:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SectionAddrDock : public QDockWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-11-23 07:21:49 +00:00
|
|
|
friend SectionsWidget;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void updateDock();
|
|
|
|
void addTextItem(QColor color, QPoint pos, QString string);
|
|
|
|
|
|
|
|
private:
|
2018-11-12 08:22:28 +00:00
|
|
|
enum AddrType { Raw = 0, Virtual };
|
|
|
|
int heightThreshold;
|
|
|
|
int rectOffset;
|
|
|
|
int rectWidth;
|
|
|
|
QColor indicatorColor;
|
|
|
|
explicit SectionAddrDock(SectionsModel *model, AddrType type, QWidget *parent = nullptr);
|
|
|
|
QGraphicsScene *graphicsScene;
|
2018-11-23 07:21:49 +00:00
|
|
|
QGraphicsView *graphicsView;
|
2018-11-12 08:22:28 +00:00
|
|
|
SectionsProxyModel *proxyModel;
|
|
|
|
AddrType addrType;
|
|
|
|
QHash<QString, int> namePosYMap;
|
|
|
|
QHash<QString, int> nameHeightMap;
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SECTIONSWIDGET_H
|