2018-05-24 15:37:37 +00:00
|
|
|
#ifndef ZIGNATURESWIDGET_H
|
|
|
|
#define ZIGNATURESWIDGET_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "Cutter.h"
|
|
|
|
#include "CutterDockWidget.h"
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
|
|
|
class MainWindow;
|
|
|
|
class QTreeWidget;
|
|
|
|
class QTreeWidgetItem;
|
2018-10-10 11:33:55 +00:00
|
|
|
class ZignaturesWidget;
|
2018-05-24 15:37:37 +00:00
|
|
|
|
2018-09-30 20:00:53 +00:00
|
|
|
namespace Ui {
|
|
|
|
class ZignaturesWidget;
|
2018-05-24 15:37:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class ZignaturesModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-10-10 11:33:55 +00:00
|
|
|
friend ZignaturesWidget;
|
|
|
|
|
2018-05-24 15:37:37 +00:00
|
|
|
public:
|
|
|
|
enum Column { OffsetColumn = 0, NameColumn, ValueColumn, ColumnCount };
|
|
|
|
enum Role { ZignatureDescriptionRole = Qt::UserRole };
|
|
|
|
|
|
|
|
ZignaturesModel(QList<ZignatureDescription> *zignatures, QObject *parent = 0);
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<ZignatureDescription> *zignatures;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ZignaturesProxyModel : public QSortFilterProxyModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ZignaturesProxyModel(ZignaturesModel *sourceModel, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ZignaturesWidget : public CutterDockWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ZignaturesWidget(MainWindow *main, QAction *action = nullptr);
|
|
|
|
~ZignaturesWidget();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void on_zignaturesTreeView_doubleClicked(const QModelIndex &index);
|
|
|
|
|
|
|
|
void refreshZignatures();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<Ui::ZignaturesWidget> ui;
|
|
|
|
|
|
|
|
ZignaturesModel *zignaturesModel;
|
|
|
|
ZignaturesProxyModel *zignaturesProxyModel;
|
|
|
|
QList<ZignatureDescription> zignatures;
|
|
|
|
|
|
|
|
void setScrollMode();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ZIGNATURESWIDGET_H
|