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 QSplitter;
|
|
|
|
class QTreeView;
|
|
|
|
class QAbstractItemView;
|
|
|
|
class QResizeEvent;
|
|
|
|
class MainWindow;
|
2017-05-03 09:09:57 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class SectionsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
class SectionsModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<SectionDescription> *sections;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, ColumnCount };
|
|
|
|
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
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
private slots:
|
2018-05-03 07:52:30 +00:00
|
|
|
void onSourceModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight,
|
|
|
|
const QVector<int>& roles);
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void refreshSections();
|
|
|
|
void showSectionsContextMenu(const QPoint &pt);
|
|
|
|
void on_actionVertical_triggered();
|
|
|
|
void on_actionHorizontal_triggered();
|
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
|
|
|
std::unique_ptr<Ui::SectionsWidget> ui;
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
QList<SectionDescription> sections;
|
|
|
|
SectionsModel *sectionsModel;
|
|
|
|
SectionsProxyModel *sectionsProxyModel;
|
|
|
|
QSplitter *splitter;
|
|
|
|
QTreeView *sectionsTable;
|
|
|
|
QAbstractItemView *sectionsPieChart;
|
|
|
|
MainWindow *main;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-05-03 07:52:30 +00:00
|
|
|
void setupViews();
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SECTIONSWIDGET_H
|