diff --git a/src/widgets/VTablesWidget.cpp b/src/widgets/VTablesWidget.cpp index 5f85a93a..ad6c8026 100644 --- a/src/widgets/VTablesWidget.cpp +++ b/src/widgets/VTablesWidget.cpp @@ -1,4 +1,5 @@ #include +#include #include "VTablesWidget.h" #include "ui_VTablesWidget.h" @@ -48,6 +49,8 @@ QVariant VTableModel::data(const QModelIndex &index, int role) const default: break; } + case VTableDescriptionRole: + return QVariant::fromValue(res); default: break; } @@ -65,6 +68,11 @@ QVariant VTableModel::data(const QModelIndex &index, int role) const default: break; } + case VTableDescriptionRole: + { + const VTableDescription &res = vtables->at(index.row()); + return QVariant::fromValue(res); + } default: break; } @@ -177,3 +185,12 @@ void VTablesWidget::refreshVTables() ui->vTableTreeView->setColumnWidth(0, 200); } + +void VTablesWidget::on_vTableTreeView_doubleClicked(const QModelIndex &index) +{ + QModelIndex parent = index.parent(); + if(parent.isValid()) + CutterCore::getInstance()->seek(index.data(VTableModel::VTableDescriptionRole).value().addr); + else + CutterCore::getInstance()->seek(index.data(VTableModel::VTableDescriptionRole).value().addr); +} diff --git a/src/widgets/VTablesWidget.h b/src/widgets/VTablesWidget.h index fe549094..ceeb13c2 100644 --- a/src/widgets/VTablesWidget.h +++ b/src/widgets/VTablesWidget.h @@ -23,6 +23,7 @@ private: public: enum Columns { NAME = 0, ADDRESS, COUNT }; + static const int VTableDescriptionRole = Qt::UserRole; VTableModel(QList *vtables, QObject* parent = nullptr); @@ -58,6 +59,7 @@ public: private slots: void refreshVTables(); + void on_vTableTreeView_doubleClicked(const QModelIndex &index); private: std::unique_ptr ui;