2018-03-06 17:21:48 +00:00
|
|
|
#ifndef TYPESWIDGET_H
|
|
|
|
#define TYPESWIDGET_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "Cutter.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2018-03-06 17:21:48 +00:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
|
|
|
class MainWindow;
|
|
|
|
class QTreeWidget;
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class TypesWidget;
|
2018-03-06 17:21:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MainWindow;
|
|
|
|
class QTreeWidgetItem;
|
|
|
|
|
|
|
|
|
|
|
|
class TypesModel: public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<TypeDescription> *types;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Columns { TYPE = 0, SIZE, FORMAT, COUNT };
|
|
|
|
static const int TypeDescriptionRole = Qt::UserRole;
|
|
|
|
|
2018-05-04 07:58:32 +00:00
|
|
|
TypesModel(QList<TypeDescription> *types, QObject *parent = nullptr);
|
2018-03-06 17:21:48 +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 beginReloadTypes();
|
|
|
|
void endReloadTypes();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TypesSortFilterProxyModel : public QSortFilterProxyModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
TypesSortFilterProxyModel(TypesModel *source_model, QObject *parent = nullptr);
|
2018-03-06 17:21:48 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class TypesWidget : public CutterDockWidget
|
2018-03-06 17:21:48 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit TypesWidget(MainWindow *main, QAction *action = nullptr);
|
2018-03-06 17:21:48 +00:00
|
|
|
~TypesWidget();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void on_typesTreeView_doubleClicked(const QModelIndex &index);
|
|
|
|
|
|
|
|
void refreshTypes();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<Ui::TypesWidget> ui;
|
|
|
|
|
|
|
|
TypesModel *types_model;
|
|
|
|
TypesSortFilterProxyModel *types_proxy_model;
|
|
|
|
QList<TypeDescription> types;
|
|
|
|
|
|
|
|
void setScrollMode();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // TYPESWIDGET_H
|