cutter/src/widgets/RelocsWidget.cpp

54 lines
1.3 KiB
C++
Raw Normal View History

2017-09-25 12:55:41 +00:00
#include <QTreeWidget>
#include "RelocsWidget.h"
#include "ui_RelocsWidget.h"
2017-10-01 19:09:42 +00:00
#include "MainWindow.h"
#include "utils/Helpers.h"
RelocsWidget::RelocsWidget(MainWindow *main, QWidget *parent) :
QDockWidget(parent),
ui(new Ui::RelocsWidget),
main(main)
{
ui->setupUi(this);
// Radare core found in:
this->main = main;
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillTreeWidget()));
}
RelocsWidget::~RelocsWidget() {}
void RelocsWidget::on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
2017-10-01 18:08:12 +00:00
Q_UNUSED(column);
// Get offset and name of item double clicked
RelocDescription reloc = item->data(0, Qt::UserRole).value<RelocDescription>();
2017-10-09 18:08:35 +00:00
CutterCore::getInstance()->seek(reloc.vaddr);
}
void RelocsWidget::fillTreeWidget()
{
ui->relocsTreeWidget->clear();
2017-10-09 18:08:35 +00:00
for (auto i : CutterCore::getInstance()->getAllRelocs())
{
2017-12-02 19:15:12 +00:00
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, RAddressString(i.vaddr));
item->setText(1, i.type);
item->setText(2, i.name);
item->setData(0, Qt::UserRole, QVariant::fromValue(i));
2017-12-02 19:15:12 +00:00
ui->relocsTreeWidget->addTopLevelItem(item);
}
2017-12-23 16:42:42 +00:00
qhelpers::adjustColumns(ui->relocsTreeWidget, 0);
}
void RelocsWidget::setScrollMode()
{
qhelpers::setVerticalScrollMode(ui->relocsTreeWidget);
}