cutter/src/widgets/StringsWidget.h

101 lines
2.3 KiB
C
Raw Normal View History

#ifndef STRINGSWIDGET_H
#define STRINGSWIDGET_H
2017-10-02 09:41:28 +00:00
#include <memory>
#include "core/Cutter.h"
#include "CutterDockWidget.h"
2018-10-17 07:55:53 +00:00
#include "common/StringsTask.h"
#include "CutterTreeWidget.h"
#include "AddressableItemModel.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidgetItem;
class StringsWidget;
2018-03-21 20:32:32 +00:00
namespace Ui {
class StringsWidget;
}
2021-01-24 14:50:13 +00:00
class StringsModel : public AddressableItemModel<QAbstractListModel>
{
2018-03-21 20:32:32 +00:00
Q_OBJECT
friend StringsWidget;
private:
QList<StringDescription> *strings;
public:
2021-01-24 14:50:13 +00:00
enum Column {
OffsetColumn = 0,
StringColumn,
TypeColumn,
LengthColumn,
SizeColumn,
SectionColumn,
CommentColumn,
ColumnCount
};
static const int StringDescriptionRole = Qt::UserRole;
StringsModel(QList<StringDescription> *strings, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
const StringDescription *description(const QModelIndex &index) const;
};
class StringsProxyModel : public AddressableFilterProxyModel
{
2018-03-21 20:32:32 +00:00
Q_OBJECT
friend StringsWidget;
public:
StringsProxyModel(StringsModel *sourceModel, QObject *parent = nullptr);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
QString selectedSection;
};
class StringsWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit StringsWidget(MainWindow *main);
~StringsWidget();
private slots:
void refreshStrings();
2018-05-28 20:06:24 +00:00
void stringSearchFinished(const QList<StringDescription> &strings);
void refreshSectionCombo();
void on_actionCopy();
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;
StringsProxyModel *proxyModel;
QList<StringDescription> strings;
2021-01-24 14:50:13 +00:00
CutterTreeWidget *tree;
};
#endif // STRINGSWIDGET_H