Add double click function to VTables (#343) (#349)

This commit is contained in:
Boris Ryutin 2018-03-03 14:23:53 +03:00 committed by xarkes
parent efc7a7e90e
commit 17f7c0b593
2 changed files with 19 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include <QShortcut>
#include <QModelIndex>
#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<ClassMethodDescription>().addr);
else
CutterCore::getInstance()->seek(index.data(VTableModel::VTableDescriptionRole).value<VTableDescription>().addr);
}

View File

@ -23,6 +23,7 @@ private:
public:
enum Columns { NAME = 0, ADDRESS, COUNT };
static const int VTableDescriptionRole = Qt::UserRole;
VTableModel(QList<VTableDescription> *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::VTablesWidget> ui;