cutter/src/widgets/VTablesWidget.h
xarkes ab27e09b91 Splitted Cutter.h and moved everything in core (#1201)
Sometimes it is not necessary to include the whole Cutter.h file
Hence, it's been splitted so you can include only what you require
E.g. #include "core/CutterCommon.h" to have access to the common types
2019-02-22 17:50:45 +01:00

76 lines
1.8 KiB
C++

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