2018-02-04 14:32:18 +00:00
|
|
|
#ifndef CLASSESWIDGET_H
|
|
|
|
#define CLASSESWIDGET_H
|
2017-12-23 16:42:42 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2018-03-04 17:42:02 +00:00
|
|
|
#include "Cutter.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2017-12-23 16:42:42 +00:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class ClassesWidget;
|
2017-12-23 16:42:42 +00:00
|
|
|
}
|
|
|
|
|
2018-02-04 14:32:18 +00:00
|
|
|
class QTreeWidget;
|
2017-12-23 16:42:42 +00:00
|
|
|
class QTreeWidgetItem;
|
2018-03-16 21:46:57 +00:00
|
|
|
class MainWindow;
|
2017-12-23 16:42:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ClassesModel: public QAbstractItemModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<ClassDescription> *classes;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Columns { NAME = 0, TYPE, OFFSET, COUNT };
|
|
|
|
enum RowType { CLASS = 0, METHOD = 1, FIELD = 2 };
|
|
|
|
|
|
|
|
static const int OffsetRole = Qt::UserRole;
|
|
|
|
static const int NameRole = Qt::UserRole + 1;
|
|
|
|
static const int TypeRole = Qt::UserRole + 2;
|
|
|
|
|
|
|
|
explicit ClassesModel(QList<ClassDescription> *classes, QObject *parent = 0);
|
|
|
|
|
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QModelIndex parent(const QModelIndex &index) const override;
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
2018-03-21 20:32:32 +00:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
|
|
int role = Qt::DisplayRole) const override;
|
2017-12-23 16:42:42 +00:00
|
|
|
|
|
|
|
void beginReload();
|
|
|
|
void endReload();
|
|
|
|
};
|
|
|
|
|
2018-02-04 14:32:18 +00:00
|
|
|
Q_DECLARE_METATYPE(ClassesModel::RowType)
|
2017-12-23 16:42:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ClassesSortFilterProxyModel : public QSortFilterProxyModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ClassesSortFilterProxyModel(ClassesModel *source_model, QObject *parent = 0);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class ClassesWidget : public CutterDockWidget
|
2017-12-23 16:42:42 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit ClassesWidget(MainWindow *main, QAction *action = nullptr);
|
2017-12-23 16:42:42 +00:00
|
|
|
~ClassesWidget();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void on_classesTreeView_doubleClicked(const QModelIndex &index);
|
|
|
|
|
|
|
|
void refreshClasses();
|
2018-03-11 15:57:38 +00:00
|
|
|
void flagsChanged();
|
2017-12-23 16:42:42 +00:00
|
|
|
|
|
|
|
private:
|
2018-03-11 15:57:38 +00:00
|
|
|
enum class Source { BIN, FLAGS };
|
|
|
|
|
|
|
|
Source getSource();
|
|
|
|
|
2017-12-23 16:42:42 +00:00
|
|
|
std::unique_ptr<Ui::ClassesWidget> ui;
|
|
|
|
|
|
|
|
ClassesModel *model;
|
|
|
|
ClassesSortFilterProxyModel *proxy_model;
|
|
|
|
QList<ClassDescription> classes;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-02-04 14:32:18 +00:00
|
|
|
#endif // CLASSESWIDGET_H
|