2017-03-29 10:18:37 +00:00
|
|
|
#ifndef STRINGSWIDGET_H
|
|
|
|
#define STRINGSWIDGET_H
|
|
|
|
|
2017-10-02 09:41:28 +00:00
|
|
|
#include <memory>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2018-10-17 07:55:53 +00:00
|
|
|
#include "common/StringsTask.h"
|
2018-10-10 12:34:46 +00:00
|
|
|
#include "CutterTreeWidget.h"
|
2019-09-01 21:30:25 +00:00
|
|
|
#include "AddressableItemModel.h"
|
2017-12-19 18:05:57 +00:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
2017-11-19 12:56:10 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
class MainWindow;
|
2017-04-13 15:14:02 +00:00
|
|
|
class QTreeWidgetItem;
|
2018-10-10 11:33:55 +00:00
|
|
|
class StringsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class StringsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2019-09-01 21:30:25 +00:00
|
|
|
class StringsModel: public AddressableItemModel<QAbstractListModel>
|
2017-12-19 18:05:57 +00:00
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
Q_OBJECT
|
2017-12-19 18:05:57 +00:00
|
|
|
|
2018-10-10 11:33:55 +00:00
|
|
|
friend StringsWidget;
|
|
|
|
|
2017-12-19 18:05:57 +00:00
|
|
|
private:
|
|
|
|
QList<StringDescription> *strings;
|
|
|
|
|
|
|
|
public:
|
2018-11-17 19:17:16 +00:00
|
|
|
enum Column { OffsetColumn = 0, StringColumn, TypeColumn, LengthColumn, SizeColumn, SectionColumn, ColumnCount };
|
2017-12-19 18:05:57 +00:00
|
|
|
static const int StringDescriptionRole = Qt::UserRole;
|
|
|
|
|
2018-05-04 07:58:32 +00:00
|
|
|
StringsModel(QList<StringDescription> *strings, QObject *parent = nullptr);
|
2017-12-19 18:05:57 +00:00
|
|
|
|
2019-09-01 21:30:25 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
2017-12-19 18:05:57 +00:00
|
|
|
|
2019-09-01 21:30:25 +00:00
|
|
|
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;
|
2017-12-19 18:05:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-01 21:30:25 +00:00
|
|
|
class StringsProxyModel : public AddressableFilterProxyModel
|
2017-12-19 18:05:57 +00:00
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
Q_OBJECT
|
2017-12-19 18:05:57 +00:00
|
|
|
|
2018-11-17 19:17:16 +00:00
|
|
|
friend StringsWidget;
|
|
|
|
|
2017-12-19 18:05:57 +00:00
|
|
|
public:
|
2018-11-17 19:17:16 +00:00
|
|
|
StringsProxyModel(StringsModel *sourceModel, QObject *parent = nullptr);
|
2017-12-19 18:05:57 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
2018-11-17 19:17:16 +00:00
|
|
|
|
|
|
|
QString selectedSection;
|
2017-12-19 18:05:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class StringsWidget : public CutterDockWidget
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit StringsWidget(MainWindow *main, QAction *action = nullptr);
|
2017-03-29 10:18:37 +00:00
|
|
|
~StringsWidget();
|
|
|
|
|
|
|
|
private slots:
|
2017-12-19 18:05:57 +00:00
|
|
|
void refreshStrings();
|
2018-05-28 20:06:24 +00:00
|
|
|
void stringSearchFinished(const QList<StringDescription> &strings);
|
2018-11-17 19:17:16 +00:00
|
|
|
void refreshSectionCombo();
|
2017-11-19 12:56:10 +00:00
|
|
|
|
2018-10-15 09:06:15 +00:00
|
|
|
void on_actionCopy();
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private:
|
2017-10-02 09:41:28 +00:00
|
|
|
std::unique_ptr<Ui::StringsWidget> ui;
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2018-05-28 20:06:24 +00:00
|
|
|
QSharedPointer<StringsTask> task;
|
|
|
|
|
2017-12-19 18:05:57 +00:00
|
|
|
StringsModel *model;
|
2018-11-17 19:17:16 +00:00
|
|
|
StringsProxyModel *proxyModel;
|
2017-12-19 18:05:57 +00:00
|
|
|
QList<StringDescription> strings;
|
2018-10-10 12:34:46 +00:00
|
|
|
CutterTreeWidget *tree;
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // STRINGSWIDGET_H
|