2017-03-29 10:18:37 +00:00
|
|
|
#ifndef SECTIONSWIDGET_H
|
|
|
|
#define SECTIONSWIDGET_H
|
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
#include <memory>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
#include "Cutter.h"
|
|
|
|
#include "CutterDockWidget.h"
|
|
|
|
|
|
|
|
class QTreeView;
|
|
|
|
class QAbstractItemView;
|
|
|
|
class MainWindow;
|
2017-05-03 09:09:57 +00:00
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
class SectionsModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
void beginReloadSections();
|
|
|
|
void endReloadSections();
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private:
|
2018-05-03 07:52:30 +00:00
|
|
|
QList<SectionDescription> sections;
|
|
|
|
SectionsModel *sectionsModel;
|
|
|
|
QTreeView *sectionsTable;
|
|
|
|
MainWindow *main;
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SECTIONSWIDGET_H
|