cutter/src/widgets/SymbolsWidget.cpp

62 lines
1.4 KiB
C++
Raw Normal View History

#include "SymbolsWidget.h"
#include "ui_SymbolsWidget.h"
2017-10-01 19:09:42 +00:00
#include "MainWindow.h"
#include "utils/Helpers.h"
#include <QTreeWidget>
SymbolsWidget::SymbolsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent),
ui(new Ui::SymbolsWidget),
main(main)
{
ui->setupUi(this);
ui->symbolsTreeWidget->hideColumn(0);
}
2017-10-02 09:41:28 +00:00
SymbolsWidget::~SymbolsWidget() {}
void SymbolsWidget::setup()
2017-04-09 19:55:06 +00:00
{
setScrollMode();
fillSymbols();
}
void SymbolsWidget::refresh()
{
setup();
}
void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
2017-10-01 18:08:12 +00:00
Q_UNUSED(column);
// Get offset and name of item double clicked
SymbolDescription symbol = item->data(0, Qt::UserRole).value<SymbolDescription>();
this->main->seek(symbol.vaddr, symbol.name, true);
}
void SymbolsWidget::fillSymbols()
{
ui->symbolsTreeWidget->clear();
for (auto symbol : this->main->core->getAllSymbols())
{
QTreeWidgetItem *item = qhelpers::appendRow(ui->symbolsTreeWidget,
2017-06-03 12:27:23 +00:00
RAddressString(symbol.vaddr),
QString("%1 %2").arg(symbol.bind, symbol.type).trimmed(),
symbol.name);
item->setData(0, Qt::UserRole, QVariant::fromValue(symbol));
}
qhelpers::adjustColumns(ui->symbolsTreeWidget);
}
void SymbolsWidget::setScrollMode()
{
qhelpers::setVerticalScrollMode(ui->symbolsTreeWidget);
}