cutter/src/widgets/StringsWidget.h

94 lines
2.2 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 <QAbstractListModel>
#include <QSortFilterProxyModel>
class MainWindow;
class QTreeWidgetItem;
class StringsWidget;
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
friend StringsWidget;
private:
QList<StringDescription> *strings;
public:
enum Column { OffsetColumn = 0, StringColumn, TypeColumn, LengthColumn, SizeColumn, SectionColumn, ColumnCount };
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;
};
class StringsProxyModel : public QSortFilterProxyModel
{
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, 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);
void refreshSectionCombo();
void showStringsContextMenu(const QPoint &pt);
void on_actionX_refs_triggered();
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;
CutterTreeWidget *tree;
};
#endif // STRINGSWIDGET_H