2018-03-08 12:24:15 +00:00
|
|
|
#ifndef SEARCHWIDGET_H
|
|
|
|
#define SEARCHWIDGET_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
|
|
|
#include "Cutter.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2018-03-08 12:24:15 +00:00
|
|
|
|
|
|
|
class MainWindow;
|
|
|
|
class QTreeWidgetItem;
|
|
|
|
|
|
|
|
|
|
|
|
class SearchModel: public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<SearchDescription> *search;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Columns { OFFSET = 0, SIZE, CODE, DATA, COUNT };
|
|
|
|
static const int SearchDescriptionRole = Qt::UserRole;
|
|
|
|
|
2018-05-04 07:58:32 +00:00
|
|
|
SearchModel(QList<SearchDescription> *search, QObject *parent = nullptr);
|
2018-03-08 12:24:15 +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 beginReloadSearch();
|
|
|
|
void endReloadSearch();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SearchSortFilterProxyModel : public QSortFilterProxyModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
SearchSortFilterProxyModel(SearchModel *source_model, QObject *parent = nullptr);
|
2018-03-08 12:24:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class SearchWidget;
|
2018-03-08 12:24:15 +00:00
|
|
|
}
|
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class SearchWidget : public CutterDockWidget
|
2018-03-08 12:24:15 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit SearchWidget(MainWindow *main, QAction *action = nullptr);
|
2018-03-08 12:24:15 +00:00
|
|
|
~SearchWidget();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void on_searchTreeView_doubleClicked(const QModelIndex &index);
|
|
|
|
|
|
|
|
void searchChanged();
|
|
|
|
void refreshSearchspaces();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<Ui::SearchWidget> ui;
|
|
|
|
|
|
|
|
SearchModel *search_model;
|
|
|
|
SearchSortFilterProxyModel *search_proxy_model;
|
|
|
|
QList<SearchDescription> search;
|
|
|
|
|
|
|
|
void refreshSearch();
|
|
|
|
void setScrollMode();
|
2018-04-11 09:55:37 +00:00
|
|
|
void updatePlaceholderText(int index);
|
2018-03-08 12:24:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SEARCHWIDGET_H
|