cutter/src/widgets/FlagsWidget.h

95 lines
2.1 KiB
C
Raw Normal View History

#ifndef FLAGSWIDGET_H
#define FLAGSWIDGET_H
#include <memory>
#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
class MainWindow;
class QTreeWidgetItem;
class FlagsWidget;
2017-05-04 14:16:21 +00:00
class FlagsModel: public QAbstractListModel
{
Q_OBJECT
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;
FlagsModel(QList<FlagDescription> *flags, QObject *parent = nullptr);
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;
};
class FlagsSortFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
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;
}
class FlagsWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit FlagsWidget(MainWindow *main, QAction *action = nullptr);
~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);
2018-03-11 16:40:52 +00:00
void on_actionRename_triggered();
void on_actionDelete_triggered();
void on_actionXrefs_triggered();
2018-03-11 16:40:52 +00:00
void showContextMenu(const QPoint &pt);
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;
CutterTreeWidget *tree;
2017-05-04 14:16:21 +00:00
void refreshFlags();
void setScrollMode();
};
#endif // FLAGSWIDGET_H