mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-23 05:16:11 +00:00
ebce2f1ac0
Kill PieChart (Fix #653)
70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
#ifndef SECTIONSWIDGET_H
|
|
#define SECTIONSWIDGET_H
|
|
|
|
#include <memory>
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QSortFilterProxyModel>
|
|
|
|
#include "Cutter.h"
|
|
#include "CutterDockWidget.h"
|
|
|
|
class QTreeView;
|
|
class QAbstractItemView;
|
|
class MainWindow;
|
|
|
|
class SectionsModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
private:
|
|
QList<SectionDescription> *sections;
|
|
|
|
public:
|
|
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, EntropyColumn, ColumnCount };
|
|
enum Role { SectionDescriptionRole = Qt::UserRole };
|
|
|
|
SectionsModel(QList<SectionDescription> *sections, QObject *parent = nullptr);
|
|
|
|
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
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
SectionsProxyModel(SectionsModel *sourceModel, QObject *parent = nullptr);
|
|
|
|
protected:
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
};
|
|
|
|
class SectionsWidget : public CutterDockWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SectionsWidget(MainWindow *main, QAction *action = nullptr);
|
|
~SectionsWidget();
|
|
|
|
private slots:
|
|
void refreshSections();
|
|
void onSectionsDoubleClicked(const QModelIndex &index);
|
|
|
|
private:
|
|
QList<SectionDescription> sections;
|
|
SectionsModel *sectionsModel;
|
|
QTreeView *sectionsTable;
|
|
MainWindow *main;
|
|
};
|
|
|
|
#endif // SECTIONSWIDGET_H
|