cutter/src/widgets/StringsWidget.h

83 lines
1.9 KiB
C
Raw Normal View History

#ifndef STRINGSWIDGET_H
#define STRINGSWIDGET_H
2017-10-02 09:41:28 +00:00
#include <memory>
2018-03-04 17:42:02 +00:00
#include "Cutter.h"
#include "CutterDockWidget.h"
2018-05-28 20:06:24 +00:00
#include "utils/StringsTask.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidgetItem;
2018-03-21 20:32:32 +00:00
namespace Ui {
class StringsWidget;
}
class StringsModel: public QAbstractListModel
{
2018-03-21 20:32:32 +00:00
Q_OBJECT
private:
QList<StringDescription> *strings;
public:
2018-02-09 14:22:45 +00:00
enum Columns { OFFSET = 0, STRING, TYPE, LENGTH, SIZE, COUNT };
static const int StringDescriptionRole = Qt::UserRole;
StringsModel(QList<StringDescription> *strings, QObject *parent = nullptr);
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 beginReload();
void endReload();
};
class StringsSortFilterProxyModel : public QSortFilterProxyModel
{
2018-03-21 20:32:32 +00:00
Q_OBJECT
public:
StringsSortFilterProxyModel(StringsModel *source_model, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class StringsWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit StringsWidget(MainWindow *main, QAction *action = nullptr);
~StringsWidget();
private slots:
void on_stringsTreeView_doubleClicked(const QModelIndex &index);
void refreshStrings();
2018-05-28 20:06:24 +00:00
void stringSearchFinished(const QList<StringDescription> &strings);
private:
2017-10-02 09:41:28 +00:00
std::unique_ptr<Ui::StringsWidget> ui;
2018-05-28 20:06:24 +00:00
QSharedPointer<StringsTask> task;
StringsModel *model;
StringsSortFilterProxyModel *proxy_model;
QList<StringDescription> strings;
};
#endif // STRINGSWIDGET_H