2017-03-29 10:18:37 +00:00
|
|
|
#ifndef FLAGSWIDGET_H
|
|
|
|
#define FLAGSWIDGET_H
|
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
2020-01-20 18:36:32 +00:00
|
|
|
#include <QStandardItemModel>
|
2017-11-19 12:56:10 +00:00
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2018-10-10 12:34:46 +00:00
|
|
|
#include "CutterTreeWidget.h"
|
2019-09-01 21:30:25 +00:00
|
|
|
#include "AddressableItemList.h"
|
|
|
|
#include "AddressableItemModel.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
class MainWindow;
|
2017-04-13 15:14:02 +00:00
|
|
|
class QTreeWidgetItem;
|
2018-10-10 11:33:55 +00:00
|
|
|
class FlagsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-05-04 14:16:21 +00:00
|
|
|
|
2019-09-01 21:30:25 +00:00
|
|
|
class FlagsModel: public AddressableItemModel<QAbstractListModel>
|
2017-05-04 14:16:21 +00:00
|
|
|
{
|
2018-10-10 11:33:55 +00:00
|
|
|
friend FlagsWidget;
|
|
|
|
|
2017-05-04 14:16:21 +00:00
|
|
|
private:
|
|
|
|
QList<FlagDescription> *flags;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Columns { OFFSET = 0, SIZE, NAME, COUNT };
|
|
|
|
static const int FlagDescriptionRole = Qt::UserRole;
|
|
|
|
|
2018-05-04 07:58:32 +00:00
|
|
|
FlagsModel(QList<FlagDescription> *flags, QObject *parent = nullptr);
|
2017-05-04 14:16:21 +00:00
|
|
|
|
2019-09-01 21:30:25 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
2017-05-04 14:16:21 +00:00
|
|
|
|
2019-09-01 21:30:25 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
2020-01-20 18:36:32 +00:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
|
|
int role = Qt::DisplayRole) const override;
|
2019-09-01 21:30:25 +00:00
|
|
|
|
|
|
|
RVA address(const QModelIndex &index) const override;
|
|
|
|
QString name(const QModelIndex &index) const override;
|
2020-01-20 18:36:32 +00:00
|
|
|
|
|
|
|
const FlagDescription *description(QModelIndex index) const;
|
2017-05-04 14:16:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-01 21:30:25 +00:00
|
|
|
class FlagsSortFilterProxyModel : public AddressableFilterProxyModel
|
2017-05-04 14:16:21 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
FlagsSortFilterProxyModel(FlagsModel *source_model, QObject *parent = nullptr);
|
2017-05-04 14:16:21 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class FlagsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class FlagsWidget : public CutterDockWidget
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit FlagsWidget(MainWindow *main, QAction *action = nullptr);
|
2017-03-29 10:18:37 +00:00
|
|
|
~FlagsWidget();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void on_flagspaceCombo_currentTextChanged(const QString &arg1);
|
|
|
|
|
2018-03-11 16:40:52 +00:00
|
|
|
void on_actionRename_triggered();
|
|
|
|
void on_actionDelete_triggered();
|
|
|
|
|
2017-07-11 11:05:42 +00:00
|
|
|
void flagsChanged();
|
2017-11-19 12:56:10 +00:00
|
|
|
void refreshFlagspaces();
|
2017-07-11 11:05:42 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private:
|
2017-10-02 09:41:28 +00:00
|
|
|
std::unique_ptr<Ui::FlagsWidget> ui;
|
2018-10-10 12:34:46 +00:00
|
|
|
MainWindow *main;
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2020-01-20 18:36:32 +00:00
|
|
|
bool disableFlagRefresh = false;
|
2017-05-04 14:16:21 +00:00
|
|
|
FlagsModel *flags_model;
|
|
|
|
FlagsSortFilterProxyModel *flags_proxy_model;
|
|
|
|
QList<FlagDescription> flags;
|
2018-10-10 12:34:46 +00:00
|
|
|
CutterTreeWidget *tree;
|
2017-05-04 14:16:21 +00:00
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
void refreshFlags();
|
|
|
|
void setScrollMode();
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FLAGSWIDGET_H
|