2017-09-25 12:55:41 +00:00
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QAbstractItemView>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include "stringswidget.h"
|
|
|
|
#include "ui_stringswidget.h"
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
2017-04-13 15:14:02 +00:00
|
|
|
#include "helpers.h"
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
StringsWidget::StringsWidget(MainWindow *main, QWidget *parent) :
|
2017-04-13 15:14:02 +00:00
|
|
|
DockWidget(parent),
|
|
|
|
ui(new Ui::StringsWidget),
|
|
|
|
main(main)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
ui->stringsTreeWidget->hideColumn(0);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StringsWidget::~StringsWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
void StringsWidget::setup()
|
|
|
|
{
|
|
|
|
setScrollMode();
|
|
|
|
|
|
|
|
fillTreeWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StringsWidget::refresh()
|
|
|
|
{
|
|
|
|
setup();
|
|
|
|
}
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void StringsWidget::on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
2017-09-25 12:55:41 +00:00
|
|
|
CUTTERNOTUSED(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
|
|
|
|
// TODO: use this info to change disasm contents
|
2017-04-28 13:09:40 +00:00
|
|
|
StringDescription str = item->data(0, Qt::UserRole).value<StringDescription>();
|
|
|
|
this->main->seek(str.vaddr, NULL, true);
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StringsWidget::fillTreeWidget()
|
|
|
|
{
|
|
|
|
ui->stringsTreeWidget->clear();
|
2017-04-28 13:09:40 +00:00
|
|
|
for (auto i : main->core->getAllStrings())
|
2017-04-13 15:14:02 +00:00
|
|
|
{
|
2017-04-28 13:09:40 +00:00
|
|
|
QTreeWidgetItem *item = qhelpers::appendRow(ui->stringsTreeWidget, RAddressString(i.vaddr), i.string);
|
|
|
|
item->setData(0, Qt::UserRole, QVariant::fromValue(i));
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
|
|
|
qhelpers::adjustColumns(ui->stringsTreeWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StringsWidget::setScrollMode()
|
|
|
|
{
|
|
|
|
qhelpers::setVerticalScrollMode(ui->stringsTreeWidget);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|