cutter/src/widgets/StringsWidget.cpp

55 lines
1.3 KiB
C++
Raw Normal View History

2017-09-25 12:55:41 +00:00
#include <QTreeWidget>
#include <QAbstractItemView>
#include "StringsWidget.h"
#include "ui_StringsWidget.h"
2017-10-01 19:09:42 +00:00
#include "MainWindow.h"
#include "utils/Helpers.h"
StringsWidget::StringsWidget(MainWindow *main, QWidget *parent) :
QDockWidget(parent),
ui(new Ui::StringsWidget),
main(main)
{
ui->setupUi(this);
setScrollMode();
2017-12-02 19:15:12 +00:00
ui->stringsTreeWidget->sortByColumn(1, Qt::AscendingOrder);
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillTreeWidget()));
}
StringsWidget::~StringsWidget() {}
void StringsWidget::on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
2017-10-01 18:08:12 +00:00
Q_UNUSED(column);
StringDescription str = item->data(0, Qt::UserRole).value<StringDescription>();
2017-10-09 18:08:35 +00:00
CutterCore::getInstance()->seek(str.vaddr);
}
void StringsWidget::fillTreeWidget()
{
ui->stringsTreeWidget->clear();
2017-10-09 18:08:35 +00:00
for (auto i : CutterCore::getInstance()->getAllStrings())
{
2017-12-02 19:15:12 +00:00
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, RAddressString(i.vaddr));
item->setText(1, i.string);
ui->stringsTreeWidget->insertTopLevelItem(0, item);
item->setData(0, Qt::UserRole, QVariant::fromValue(i));
}
qhelpers::adjustColumns(ui->stringsTreeWidget);
}
void StringsWidget::setScrollMode()
{
qhelpers::setVerticalScrollMode(ui->stringsTreeWidget);
}