2017-10-02 16:18:40 +00:00
|
|
|
#include "SymbolsWidget.h"
|
|
|
|
#include "ui_SymbolsWidget.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-10-01 19:09:42 +00:00
|
|
|
#include "MainWindow.h"
|
|
|
|
#include "utils/Helpers.h"
|
2017-04-13 15:14:02 +00:00
|
|
|
|
|
|
|
#include <QTreeWidget>
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
SymbolsWidget::SymbolsWidget(MainWindow *main, QAction *action) :
|
|
|
|
CutterDockWidget(main, action),
|
2017-10-09 18:08:35 +00:00
|
|
|
ui(new Ui::SymbolsWidget)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2017-12-02 19:15:12 +00:00
|
|
|
ui->symbolsTreeWidget->sortByColumn(2, Qt::AscendingOrder);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
setScrollMode();
|
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillSymbols()));
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
SymbolsWidget::~SymbolsWidget() {}
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
2017-10-01 18:08:12 +00:00
|
|
|
Q_UNUSED(column);
|
2017-04-09 17:09:35 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
// Get offset and name of item double clicked
|
2017-04-28 13:09:40 +00:00
|
|
|
SymbolDescription symbol = item->data(0, Qt::UserRole).value<SymbolDescription>();
|
2017-10-09 18:08:35 +00:00
|
|
|
CutterCore::getInstance()->seek(symbol.vaddr);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
2017-04-13 15:14:02 +00:00
|
|
|
|
|
|
|
void SymbolsWidget::fillSymbols()
|
|
|
|
{
|
|
|
|
ui->symbolsTreeWidget->clear();
|
2017-10-09 18:08:35 +00:00
|
|
|
for (auto symbol : CutterCore::getInstance()->getAllSymbols())
|
2017-04-13 15:14:02 +00:00
|
|
|
{
|
2017-12-02 19:15:12 +00:00
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
|
|
|
item->setText(0, RAddressString(symbol.vaddr));
|
|
|
|
item->setText(1, QString("%1 %2").arg(symbol.bind, symbol.type).trimmed());
|
|
|
|
item->setText(2, symbol.name);
|
2017-04-28 13:09:40 +00:00
|
|
|
item->setData(0, Qt::UserRole, QVariant::fromValue(symbol));
|
2017-12-02 19:15:12 +00:00
|
|
|
ui->symbolsTreeWidget->addTopLevelItem(item);
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
2017-12-23 16:42:42 +00:00
|
|
|
qhelpers::adjustColumns(ui->symbolsTreeWidget, 0);
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SymbolsWidget::setScrollMode()
|
|
|
|
{
|
|
|
|
qhelpers::setVerticalScrollMode(ui->symbolsTreeWidget);
|
|
|
|
}
|