cutter/src/widgets/FlagsWidget.h

88 lines
1.8 KiB
C
Raw Normal View History

#ifndef FLAGSWIDGET_H
#define FLAGSWIDGET_H
#include <memory>
#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include <QDockWidget>
2018-03-04 17:42:02 +00:00
#include "Cutter.h"
class MainWindow;
class QTreeWidgetItem;
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;
}
class FlagsWidget : public QDockWidget
{
Q_OBJECT
public:
explicit FlagsWidget(MainWindow *main, QWidget *parent = 0);
~FlagsWidget();
private slots:
2017-05-04 14:16:21 +00:00
void on_flagsTreeView_doubleClicked(const QModelIndex &index);
void on_flagspaceCombo_currentTextChanged(const QString &arg1);
void flagsChanged();
void refreshFlagspaces();
private:
2017-10-02 09:41:28 +00:00
std::unique_ptr<Ui::FlagsWidget> ui;
MainWindow *main;
2017-05-04 14:16:21 +00:00
FlagsModel *flags_model;
FlagsSortFilterProxyModel *flags_proxy_model;
QList<FlagDescription> flags;
void refreshFlags();
void setScrollMode();
};
#endif // FLAGSWIDGET_H