Add ExportsWidget, Double Click in ImportsWidget (#174)

* Add QRCore::getAllExports()

* Add ExportsWidget

* ImportsWidget double click
This commit is contained in:
Florian Märkl 2017-05-19 09:45:26 +02:00 committed by Hugo Teso
parent 117d547570
commit 5d91e3c884
13 changed files with 468 additions and 104 deletions

View File

@ -50,6 +50,7 @@ SOURCES += \
widgets/stringswidget.cpp \ widgets/stringswidget.cpp \
widgets/flagswidget.cpp \ widgets/flagswidget.cpp \
widgets/memorywidget.cpp \ widgets/memorywidget.cpp \
widgets/exportswidget.cpp \
qrdisasm.cpp \ qrdisasm.cpp \
widgets/sdbdock.cpp \ widgets/sdbdock.cpp \
analthread.cpp \ analthread.cpp \
@ -87,6 +88,7 @@ HEADERS += \
widgets/stringswidget.h \ widgets/stringswidget.h \
widgets/flagswidget.h \ widgets/flagswidget.h \
widgets/memorywidget.h \ widgets/memorywidget.h \
widgets/exportswidget.h \
qrdisasm.h \ qrdisasm.h \
widgets/sdbdock.h \ widgets/sdbdock.h \
analthread.h \ analthread.h \
@ -119,6 +121,7 @@ FORMS += \
widgets/stringswidget.ui \ widgets/stringswidget.ui \
widgets/flagswidget.ui \ widgets/flagswidget.ui \
widgets/memorywidget.ui \ widgets/memorywidget.ui \
widgets/exportswidget.ui \
widgets/sdbdock.ui \ widgets/sdbdock.ui \
dialogs/commentsdialog.ui \ dialogs/commentsdialog.ui \
widgets/sidebar.ui \ widgets/sidebar.ui \

View File

@ -45,6 +45,7 @@
#include "widgets/sectionswidget.h" #include "widgets/sectionswidget.h"
#include "widgets/commentswidget.h" #include "widgets/commentswidget.h"
#include "widgets/importswidget.h" #include "widgets/importswidget.h"
#include "widgets/exportswidget.h"
#include "widgets/symbolswidget.h" #include "widgets/symbolswidget.h"
#include "widgets/stringswidget.h" #include "widgets/stringswidget.h"
#include "widgets/sectionsdock.h" #include "widgets/sectionsdock.h"
@ -94,6 +95,7 @@ MainWindow::MainWindow(QWidget *parent) :
graphicsBar(nullptr), graphicsBar(nullptr),
functionsDock(nullptr), functionsDock(nullptr),
importsDock(nullptr), importsDock(nullptr),
exportsDock(nullptr),
symbolsDock(nullptr), symbolsDock(nullptr),
relocsDock(nullptr), relocsDock(nullptr),
commentsDock(nullptr), commentsDock(nullptr),
@ -201,6 +203,10 @@ void MainWindow::initUI()
this->importsDock = new ImportsWidget(this); this->importsDock = new ImportsWidget(this);
dockWidgets.push_back(importsDock); dockWidgets.push_back(importsDock);
// Add exports DockWidget
this->exportsDock = new ExportsWidget(this);
dockWidgets.push_back(exportsDock);
// Add symbols DockWidget // Add symbols DockWidget
this->symbolsDock = new SymbolsWidget(this); this->symbolsDock = new SymbolsWidget(this);
dockWidgets.push_back(symbolsDock); dockWidgets.push_back(symbolsDock);
@ -479,7 +485,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
{ {
QMessageBox::StandardButton ret = QMessageBox::question(this, "Iaito", QMessageBox::StandardButton ret = QMessageBox::question(this, "Iaito",
"Do you really want to exit?\nSave your project before closing!", "Do you really want to exit?\nSave your project before closing!",
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); (QMessageBox::StandardButtons)(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel));
//qDebug() << ret; //qDebug() << ret;
if (ret == QMessageBox::Save) if (ret == QMessageBox::Save)
{ {
@ -665,119 +671,52 @@ void MainWindow::on_actionMem_triggered()
void MainWindow::on_actionFunctions_triggered() void MainWindow::on_actionFunctions_triggered()
{ {
if (this->functionsDock->isVisible()) toggleDockWidget(functionsDock);
{
this->functionsDock->close();
}
else
{
this->functionsDock->show();
this->functionsDock->raise();
}
} }
void MainWindow::on_actionImports_triggered() void MainWindow::on_actionImports_triggered()
{ {
if (this->importsDock->isVisible()) toggleDockWidget(importsDock);
{
this->importsDock->close();
} }
else
void MainWindow::on_actionExports_triggered()
{ {
this->importsDock->show(); toggleDockWidget(exportsDock);
this->importsDock->raise();
}
} }
void MainWindow::on_actionSymbols_triggered() void MainWindow::on_actionSymbols_triggered()
{ {
if (this->symbolsDock->isVisible()) toggleDockWidget(symbolsDock);
{
this->symbolsDock->close();
}
else
{
this->symbolsDock->show();
this->symbolsDock->raise();
}
} }
void MainWindow::on_actionReloc_triggered() void MainWindow::on_actionReloc_triggered()
{ {
if (this->relocsDock->isVisible()) toggleDockWidget(relocsDock);
{
this->relocsDock->close();
}
else
{
this->relocsDock->show();
this->relocsDock->raise();
}
} }
void MainWindow::on_actionStrings_triggered() void MainWindow::on_actionStrings_triggered()
{ {
if (this->stringsDock->isVisible()) toggleDockWidget(stringsDock);
{
this->stringsDock->close();
}
else
{
this->stringsDock->show();
this->stringsDock->raise();
}
} }
void MainWindow::on_actionSections_triggered() void MainWindow::on_actionSections_triggered()
{ {
if (this->sectionsDock->isVisible()) toggleDockWidget(sectionsDock);
{
this->sectionsDock->close();
}
else
{
this->sectionsDock->show();
this->sectionsDock->raise();
}
} }
void MainWindow::on_actionFlags_triggered() void MainWindow::on_actionFlags_triggered()
{ {
if (this->flagsDock->isVisible()) toggleDockWidget(flagsDock);
{
this->flagsDock->close();
}
else
{
this->flagsDock->show();
this->flagsDock->raise();
}
} }
void MainWindow::on_actionComents_triggered() void MainWindow::on_actionComents_triggered()
{ {
if (this->commentsDock->isVisible()) toggleDockWidget(commentsDock);
{
this->commentsDock->close();
}
else
{
this->commentsDock->show();
this->commentsDock->raise();
}
} }
void MainWindow::on_actionNotepad_triggered() void MainWindow::on_actionNotepad_triggered()
{ {
if (this->notepadDock->isVisible()) toggleDockWidget(notepadDock);
{
this->notepadDock->close();
}
else
{
this->notepadDock->show();
this->notepadDock->raise();
}
} }
void MainWindow::on_actionAbout_triggered() void MainWindow::on_actionAbout_triggered()
@ -791,6 +730,18 @@ void MainWindow::on_actionRefresh_Panels_triggered()
this->updateFrames(); this->updateFrames();
} }
void MainWindow::toggleDockWidget(DockWidget *dock_widget)
{
if (dock_widget->isVisible())
{
dock_widget->close();
}
else
{
dock_widget->show();
dock_widget->raise();
}
}
void MainWindow::seek(const QString &offset, const QString &name, bool raise_memory_dock) void MainWindow::seek(const QString &offset, const QString &name, bool raise_memory_dock)
{ {
@ -900,6 +851,7 @@ void MainWindow::restoreDocks()
this->tabifyDockWidget(this->dashboardDock, this->stringsDock); this->tabifyDockWidget(this->dashboardDock, this->stringsDock);
this->tabifyDockWidget(this->dashboardDock, this->relocsDock); this->tabifyDockWidget(this->dashboardDock, this->relocsDock);
this->tabifyDockWidget(this->dashboardDock, this->importsDock); this->tabifyDockWidget(this->dashboardDock, this->importsDock);
this->tabifyDockWidget(this->dashboardDock, this->exportsDock);
this->tabifyDockWidget(this->dashboardDock, this->symbolsDock); this->tabifyDockWidget(this->dashboardDock, this->symbolsDock);
this->tabifyDockWidget(this->dashboardDock, this->notepadDock); this->tabifyDockWidget(this->dashboardDock, this->notepadDock);
this->dashboardDock->raise(); this->dashboardDock->raise();
@ -1087,7 +1039,8 @@ void MainWindow::on_actionTabs_on_Top_triggered()
void MainWindow::on_actionReset_settings_triggered() void MainWindow::on_actionReset_settings_triggered()
{ {
QMessageBox::StandardButton ret = QMessageBox::question(this, "Iaito", QMessageBox::StandardButton ret =
(QMessageBox::StandardButton)QMessageBox::question(this, "Iaito",
"Do you really want to clear all settings?", "Do you really want to clear all settings?",
QMessageBox::Ok | QMessageBox::Cancel); QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Ok) if (ret == QMessageBox::Ok)

View File

@ -18,6 +18,7 @@ class AsciiHighlighter;
class GraphicsBar; class GraphicsBar;
class FunctionsWidget; class FunctionsWidget;
class ImportsWidget; class ImportsWidget;
class ExportsWidget;
class SymbolsWidget; class SymbolsWidget;
class RelocsWidget; class RelocsWidget;
class CommentsWidget; class CommentsWidget;
@ -89,21 +90,14 @@ public slots:
void def_theme(); void def_theme();
void on_actionFunctions_triggered(); void on_actionFunctions_triggered();
void on_actionImports_triggered(); void on_actionImports_triggered();
void on_actionExports_triggered();
void on_actionSymbols_triggered(); void on_actionSymbols_triggered();
void on_actionReloc_triggered(); void on_actionReloc_triggered();
void on_actionStrings_triggered(); void on_actionStrings_triggered();
void on_actionSections_triggered(); void on_actionSections_triggered();
void on_actionFlags_triggered(); void on_actionFlags_triggered();
void on_actionComents_triggered(); void on_actionComents_triggered();
void on_actionNotepad_triggered(); void on_actionNotepad_triggered();
void on_actionLock_triggered(); void on_actionLock_triggered();
@ -195,6 +189,7 @@ private:
GraphicsBar *graphicsBar; GraphicsBar *graphicsBar;
FunctionsWidget *functionsDock; FunctionsWidget *functionsDock;
ImportsWidget *importsDock; ImportsWidget *importsDock;
ExportsWidget *exportsDock;
SymbolsWidget *symbolsDock; SymbolsWidget *symbolsDock;
RelocsWidget *relocsDock; RelocsWidget *relocsDock;
CommentsWidget *commentsDock; CommentsWidget *commentsDock;
@ -213,6 +208,8 @@ private:
void openProject(const QString &project_name); void openProject(const QString &project_name);
void openNewFile(const QString &fn, int anal_level); void openNewFile(const QString &fn, int anal_level);
void toggleDockWidget(DockWidget *dock_widget);
public: public:
RVA getCursorAddress() const { return cursor_address; } RVA getCursorAddress() const { return cursor_address; }
void setCursorAddress(RVA addr); void setCursorAddress(RVA addr);

View File

@ -159,7 +159,7 @@ border-top: 0px;
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>725</width> <width>725</width>
<height>22</height> <height>23</height>
</rect> </rect>
</property> </property>
<property name="defaultUp"> <property name="defaultUp">
@ -171,10 +171,10 @@ border-top: 0px;
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>351</x> <x>2601</x>
<y>100</y> <y>136</y>
<width>125</width> <width>170</width>
<height>177</height> <height>214</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@ -249,6 +249,7 @@ border-top: 0px;
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionFunctions"/> <addaction name="actionFunctions"/>
<addaction name="actionImports"/> <addaction name="actionImports"/>
<addaction name="actionExports"/>
<addaction name="actionSymbols"/> <addaction name="actionSymbols"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionReloc"/> <addaction name="actionReloc"/>
@ -901,6 +902,14 @@ background: rgb(64, 64, 64);</string>
<string>Ctrl+Q</string> <string>Ctrl+Q</string>
</property> </property>
</action> </action>
<action name="actionExports">
<property name="text">
<string>Exports</string>
</property>
<property name="toolTip">
<string>Show/HIde Exports panel</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources> <resources>

View File

@ -913,6 +913,34 @@ QList<ImportDescription> QRCore::getAllImports()
} }
QList<ExportDescription> QRCore::getAllExports()
{
CORE_LOCK();
QList<ExportDescription> ret;
QJsonArray importsArray = cmdj("iEj").array();
foreach (QJsonValue value, importsArray)
{
QJsonObject importObject = value.toObject();
ExportDescription exp;
exp.vaddr = importObject["vaddr"].toVariant().toULongLong();
exp.paddr = importObject["paddr"].toVariant().toULongLong();
exp.size = importObject["size"].toVariant().toULongLong();
exp.type = importObject["type"].toString();
exp.name = importObject["name"].toString();
exp.flag_name = importObject["flagname"].toString();
ret << exp;
}
return ret;
}
QList<SymbolDescription> QRCore::getAllSymbols() QList<SymbolDescription> QRCore::getAllSymbols()
{ {
CORE_LOCK(); CORE_LOCK();

View File

@ -74,6 +74,16 @@ struct ImportDescription
QString name; QString name;
}; };
struct ExportDescription
{
RVA vaddr;
RVA paddr;
RVA size;
QString type;
QString name;
QString flag_name;
};
struct SymbolDescription struct SymbolDescription
{ {
RVA vaddr; RVA vaddr;
@ -126,6 +136,7 @@ struct SectionDescription
Q_DECLARE_METATYPE(FunctionDescription) Q_DECLARE_METATYPE(FunctionDescription)
Q_DECLARE_METATYPE(ImportDescription) Q_DECLARE_METATYPE(ImportDescription)
Q_DECLARE_METATYPE(ExportDescription)
Q_DECLARE_METATYPE(SymbolDescription) Q_DECLARE_METATYPE(SymbolDescription)
Q_DECLARE_METATYPE(CommentDescription) Q_DECLARE_METATYPE(CommentDescription)
Q_DECLARE_METATYPE(RelocDescription) Q_DECLARE_METATYPE(RelocDescription)
@ -207,6 +218,7 @@ public:
QList<FunctionDescription> getAllFunctions(); QList<FunctionDescription> getAllFunctions();
QList<ImportDescription> getAllImports(); QList<ImportDescription> getAllImports();
QList<ExportDescription> getAllExports();
QList<SymbolDescription> getAllSymbols(); QList<SymbolDescription> getAllSymbols();
QList<CommentDescription> getAllComments(const QString &filterType); QList<CommentDescription> getAllComments(const QString &filterType);
QList<RelocDescription> getAllRelocs(); QList<RelocDescription> getAllRelocs();

View File

@ -0,0 +1,189 @@
#include "exportswidget.h"
#include "ui_exportswidget.h"
#include "mainwindow.h"
#include "helpers.h"
ExportsModel::ExportsModel(QList<ExportDescription> *exports, QObject *parent)
: QAbstractListModel(parent),
exports(exports)
{
}
int ExportsModel::rowCount(const QModelIndex &) const
{
return exports->count();
}
int ExportsModel::columnCount(const QModelIndex &) const
{
return Columns::COUNT;
}
QVariant ExportsModel::data(const QModelIndex &index, int role) const
{
if(index.row() >= exports->count())
return QVariant();
const ExportDescription &exp = exports->at(index.row());
switch(role)
{
case Qt::DisplayRole:
switch(index.column())
{
case OFFSET:
return RAddressString(exp.vaddr);
case SIZE:
return RSizeString(exp.size);
case TYPE:
return exp.type;
case NAME:
return exp.name;
default:
return QVariant();
}
case ExportDescriptionRole:
return QVariant::fromValue(exp);
default:
return QVariant();
}
}
QVariant ExportsModel::headerData(int section, Qt::Orientation, int role) const
{
switch(role)
{
case Qt::DisplayRole:
switch(section)
{
case OFFSET:
return tr("Address");
case SIZE:
return tr("Size");
case TYPE:
return tr("Type");
case NAME:
return tr("Name");
default:
return QVariant();
}
default:
return QVariant();
}
}
void ExportsModel::beginReloadExports()
{
beginResetModel();
}
void ExportsModel::endReloadExports()
{
endResetModel();
}
ExportsSortFilterProxyModel::ExportsSortFilterProxyModel(ExportsModel *source_model, QObject *parent)
: QSortFilterProxyModel(parent)
{
setSourceModel(source_model);
}
bool ExportsSortFilterProxyModel::filterAcceptsRow(int row, const QModelIndex &parent) const
{
QModelIndex index = sourceModel()->index(row, 0, parent);
ExportDescription exp = index.data(ExportsModel::ExportDescriptionRole).value<ExportDescription>();
return exp.name.contains(filterRegExp());
}
bool ExportsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
ExportDescription left_exp = left.data(ExportsModel::ExportDescriptionRole).value<ExportDescription>();
ExportDescription right_exp = right.data(ExportsModel::ExportDescriptionRole).value<ExportDescription>();
switch(left.column())
{
case ExportsModel::SIZE:
if(left_exp.size != right_exp.size)
return left_exp.size < right_exp.size;
// fallthrough
case ExportsModel::OFFSET:
if(left_exp.vaddr != right_exp.vaddr)
return left_exp.vaddr < right_exp.vaddr;
// fallthrough
case ExportsModel::NAME:
return left_exp.name < right_exp.name;
case ExportsModel::TYPE:
if(left_exp.type != right_exp.type)
return left_exp.type < right_exp.type;
default:
break;
}
// fallback
return left_exp.vaddr < right_exp.vaddr;
}
ExportsWidget::ExportsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent),
ui(new Ui::ExportsWidget),
main(main)
{
ui->setupUi(this);
// Radare core found in:
this->main = main;
exports_model = new ExportsModel(&exports, this);
exports_proxy_model = new ExportsSortFilterProxyModel(exports_model, this);
ui->exportsTreeView->setModel(exports_proxy_model);
ui->exportsTreeView->sortByColumn(ExportsModel::OFFSET, Qt::AscendingOrder);
}
ExportsWidget::~ExportsWidget()
{
delete ui;
}
void ExportsWidget::setup()
{
setScrollMode();
refreshExports();
}
void ExportsWidget::refresh()
{
setup();
}
void ExportsWidget::refreshExports()
{
exports_model->beginReloadExports();
exports = main->core->getAllExports();
exports_model->endReloadExports();
ui->exportsTreeView->resizeColumnToContents(0);
ui->exportsTreeView->resizeColumnToContents(1);
ui->exportsTreeView->resizeColumnToContents(2);
}
void ExportsWidget::setScrollMode()
{
qhelpers::setVerticalScrollMode(ui->exportsTreeView);
}
void ExportsWidget::on_exportsTreeView_doubleClicked(const QModelIndex &index)
{
ExportDescription exp = index.data(ExportsModel::ExportDescriptionRole).value<ExportDescription>();
this->main->seek(exp.vaddr, exp.flag_name, true);
}

View File

@ -0,0 +1,89 @@
#ifndef EXPORTSWIDGET_H
#define EXPORTSWIDGET_H
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include "qrcore.h"
#include "dockwidget.h"
class MainWindow;
class QTreeWidget;
namespace Ui
{
class ExportsWidget;
}
class MainWindow;
class QTreeWidgetItem;
class ExportsModel: public QAbstractListModel
{
Q_OBJECT
private:
QList<ExportDescription> *exports;
public:
enum Columns { OFFSET = 0, SIZE, TYPE, NAME, COUNT };
static const int ExportDescriptionRole = Qt::UserRole;
ExportsModel(QList<ExportDescription> *exports, QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void beginReloadExports();
void endReloadExports();
};
class ExportsSortFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
ExportsSortFilterProxyModel(ExportsModel *source_model, QObject *parent = 0);
protected:
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class ExportsWidget : public DockWidget
{
Q_OBJECT
public:
explicit ExportsWidget(MainWindow *main, QWidget *parent = 0);
~ExportsWidget();
void setup() override;
void refresh() override;
private slots:
void on_exportsTreeView_doubleClicked(const QModelIndex &index);
private:
Ui::ExportsWidget *ui;
MainWindow *main;
ExportsModel *exports_model;
ExportsSortFilterProxyModel *exports_proxy_model;
QList<ExportDescription> exports;
void refreshExports();
void setScrollMode();
};
#endif // EXPORTSWIDGET_H

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExportsWidget</class>
<widget class="QDockWidget" name="ExportsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Exports</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTreeView" name="exportsTreeView">
<property name="styleSheet">
<string notr="true">QTreeView::item
{
padding-left:10px;
padding-top: 1px;
padding-bottom: 1px;
border-left: 10px;
}
QTreeView::item:hover
{
background: rgb(242, 246, 248);
color: black;
}
QTreeView::item:selected
{
background: gray;
color: white;
}</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="indentation">
<number>0</number>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -208,6 +208,8 @@ void FlagsWidget::refreshFlags()
ui->flagsTreeView->resizeColumnToContents(0); ui->flagsTreeView->resizeColumnToContents(0);
ui->flagsTreeView->resizeColumnToContents(1); ui->flagsTreeView->resizeColumnToContents(1);
// TODO: this is not a very good place for the following:
QStringList flagNames; QStringList flagNames;
for (auto i : flags) for (auto i : flags)
flagNames.append(i.name); flagNames.append(i.name);

View File

@ -92,15 +92,10 @@ private slots:
void showFunctionsContextMenu(const QPoint &pt); void showFunctionsContextMenu(const QPoint &pt);
void on_actionDisasAdd_comment_triggered(); void on_actionDisasAdd_comment_triggered();
void on_actionFunctionsRename_triggered(); void on_actionFunctionsRename_triggered();
void on_action_References_triggered(); void on_action_References_triggered();
void showTitleContextMenu(const QPoint &pt);
void on_actionHorizontal_triggered(); void on_actionHorizontal_triggered();
void on_actionVertical_triggered(); void on_actionVertical_triggered();
void show_filter(); void show_filter();
@ -109,6 +104,8 @@ private slots:
void on_closeFilterButton_clicked(); void on_closeFilterButton_clicked();
void showTitleContextMenu(const QPoint &pt);
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;

View File

@ -69,7 +69,10 @@ void ImportsWidget::fillImports()
{ {
ui->importsTreeWidget->clear(); ui->importsTreeWidget->clear();
for (auto i : this->main->core->getAllImports()) for (auto i : this->main->core->getAllImports())
qhelpers::appendRow(ui->importsTreeWidget, RAddressString(i.plt), i.type, "", i.name); {
QTreeWidgetItem *item = qhelpers::appendRow(ui->importsTreeWidget, RAddressString(i.plt), i.type, "", i.name);
item->setData(0, Qt::UserRole, QVariant::fromValue(i));
}
highlightUnsafe(); highlightUnsafe();
qhelpers::adjustColumns(ui->importsTreeWidget, 0, 10); qhelpers::adjustColumns(ui->importsTreeWidget, 0, 10);
@ -106,3 +109,9 @@ void ImportsWidget::setScrollMode()
{ {
qhelpers::setVerticalScrollMode(ui->importsTreeWidget); qhelpers::setVerticalScrollMode(ui->importsTreeWidget);
} }
void ImportsWidget::on_importsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int /* column */)
{
ImportDescription imp = item->data(0, Qt::UserRole).value<ImportDescription>();
this->main->seek(imp.plt, imp.name, true);
}

View File

@ -3,6 +3,7 @@
#include "dockwidget.h" #include "dockwidget.h"
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <QTreeWidgetItem>
class MainWindow; class MainWindow;
class QTreeWidget; class QTreeWidget;
@ -24,6 +25,9 @@ public:
void refresh() override; void refresh() override;
private slots:
void on_importsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
private: private:
Ui::ImportsWidget *ui; Ui::ImportsWidget *ui;
MainWindow *main; MainWindow *main;