cutter/src/widgets/VTablesWidget.h

76 lines
1.8 KiB
C
Raw Normal View History

2018-02-26 22:26:18 +00:00
#ifndef VTABLESWIDGET_H
#define VTABLESWIDGET_H
#include <memory>
#include <QTreeView>
#include <QSortFilterProxyModel>
2018-03-04 17:42:02 +00:00
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
2018-02-26 22:26:18 +00:00
2018-03-21 20:32:32 +00:00
namespace Ui {
class VTablesWidget;
2018-02-26 22:26:18 +00:00
}
class MainWindow;
class VTablesWidget;
2018-02-26 22:26:18 +00:00
class VTableModel : public QAbstractItemModel
{
Q_OBJECT
friend VTablesWidget;
2018-02-26 22:26:18 +00:00
private:
QList<VTableDescription> *vtables;
public:
enum Columns { NAME = 0, ADDRESS, COUNT };
static const int VTableDescriptionRole = Qt::UserRole;
2018-02-26 22:26:18 +00:00
2018-03-21 20:32:32 +00:00
VTableModel(QList<VTableDescription> *vtables, QObject *parent = nullptr);
2018-02-26 22:26:18 +00:00
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
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 VTableSortFilterProxyModel : public QSortFilterProxyModel
{
public:
2018-03-21 20:32:32 +00:00
VTableSortFilterProxyModel(VTableModel *model, QObject *parent = nullptr);
2018-02-26 22:26:18 +00:00
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
};
class VTablesWidget : public CutterDockWidget
2018-02-26 22:26:18 +00:00
{
Q_OBJECT
public:
explicit VTablesWidget(MainWindow *main, QAction *action = nullptr);
2018-02-26 22:26:18 +00:00
~VTablesWidget();
private slots:
void refreshVTables();
void on_vTableTreeView_doubleClicked(const QModelIndex &index);
2018-02-26 22:26:18 +00:00
private:
std::unique_ptr<Ui::VTablesWidget> ui;
VTableModel *model;
QSortFilterProxyModel *proxy;
QList<VTableDescription> vtables;
CutterTreeWidget *tree;
2018-02-26 22:26:18 +00:00
};
#endif // VTABLESWIDGET_H