2017-03-29 10:18:37 +00:00
|
|
|
#ifndef FLAGSWIDGET_H
|
|
|
|
#define FLAGSWIDGET_H
|
|
|
|
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
2017-10-02 09:41:28 +00:00
|
|
|
#include <memory>
|
2017-09-25 12:55:41 +00:00
|
|
|
#include "cutter.h"
|
2017-10-02 16:18:40 +00:00
|
|
|
#include "DockWidget.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
class MainWindow;
|
2017-04-13 15:14:02 +00:00
|
|
|
class QTreeWidgetItem;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-05-04 14:16:21 +00:00
|
|
|
|
|
|
|
class FlagsModel: public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<FlagDescription> *flags;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Columns { OFFSET = 0, SIZE, NAME, COUNT };
|
|
|
|
static const int FlagDescriptionRole = Qt::UserRole;
|
|
|
|
|
2017-05-06 10:46:28 +00:00
|
|
|
FlagsModel(QList<FlagDescription> *flags, QObject *parent = 0);
|
2017-05-04 14:16:21 +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 beginReloadFlags();
|
|
|
|
void endReloadFlags();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FlagsSortFilterProxyModel : public QSortFilterProxyModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
FlagsSortFilterProxyModel(FlagsModel *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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class FlagsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
class FlagsWidget : public DockWidget
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit FlagsWidget(MainWindow *main, QWidget *parent = 0);
|
|
|
|
~FlagsWidget();
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
void setup() override;
|
|
|
|
void refresh() override;
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private slots:
|
2017-05-04 14:16:21 +00:00
|
|
|
void on_flagsTreeView_doubleClicked(const QModelIndex &index);
|
2017-03-29 10:18:37 +00:00
|
|
|
void on_flagspaceCombo_currentTextChanged(const QString &arg1);
|
|
|
|
|
2017-07-11 11:05:42 +00:00
|
|
|
void flagsChanged();
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private:
|
2017-10-02 09:41:28 +00:00
|
|
|
std::unique_ptr<Ui::FlagsWidget> ui;
|
2017-03-29 10:18:37 +00:00
|
|
|
MainWindow *main;
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2017-05-04 14:16:21 +00:00
|
|
|
FlagsModel *flags_model;
|
|
|
|
FlagsSortFilterProxyModel *flags_proxy_model;
|
|
|
|
QList<FlagDescription> flags;
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
void refreshFlags();
|
|
|
|
void refreshFlagspaces();
|
|
|
|
void setScrollMode();
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FLAGSWIDGET_H
|