Replace DockWidget with CutterCore::refreshAll() signal

This commit is contained in:
Florian Märkl 2017-11-19 13:56:10 +01:00
parent a8cf0cbe19
commit 61fd2b3058
42 changed files with 225 additions and 439 deletions

View File

@ -303,7 +303,7 @@ void MainWindow::initUI()
connect(commands_shortcut, SIGNAL(activated()), this->omnibar, SLOT(showCommands())); connect(commands_shortcut, SIGNAL(activated()), this->omnibar, SLOT(showCommands()));
QShortcut *refresh_shortcut = new QShortcut(QKeySequence(QKeySequence::Refresh), this); QShortcut *refresh_shortcut = new QShortcut(QKeySequence(QKeySequence::Refresh), this);
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshVisibleDockWidgets())); connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshAll()));
connect(core, SIGNAL(projectSaved(const QString &)), this, SLOT(projectSaved(const QString &))); connect(core, SIGNAL(projectSaved(const QString &)), this, SLOT(projectSaved(const QString &)));
} }
@ -343,7 +343,7 @@ void MainWindow::finalizeOpen()
// FIXME: initialization order frakup. the next line is needed so that the // FIXME: initialization order frakup. the next line is needed so that the
// comments widget displays the function names. // comments widget displays the function names.
core->cmd("fs sections"); core->cmd("fs sections");
updateFrames(); refreshAll();
if (core->getNotes().isEmpty()) if (core->getNotes().isEmpty())
{ {
@ -480,61 +480,10 @@ void MainWindow::def_theme()
// TODO: emit a signal for theme // TODO: emit a signal for theme
} }
/*
* Refresh widget functions
*/
void MainWindow::refreshFunctions() void MainWindow::refreshAll()
{ {
functionsDock->refresh(); Core()->triggerRefreshAll();
}
void MainWindow::refreshComments()
{
commentsDock->refresh();
}
void MainWindow::updateFrames()
{
/* TODO Widgets are independants and responsible to update their own
* content right? Just send a signal.*/
if (core == NULL)
return;
static bool first_time = true;
//TODO Send signal rather than that
disassemblyDock->refreshDisasm(core->getOffset());
if (first_time)
{
for (auto W : dockWidgets)
{
// Temporary hack
DockWidget *w = dynamic_cast<DockWidget *>(W);
if (w)
{
w->setup();
}
}
first_time = false;
}
else
{
for (auto W : dockWidgets)
{
// Temporary hack
DockWidget *w = dynamic_cast<DockWidget *>(W);
if (w)
{
w->refresh();
}
}
}
// graphicsBar->refreshColorBar();
graphicsBar->fillData();
} }
void MainWindow::on_actionLock_triggered() void MainWindow::on_actionLock_triggered()
@ -683,7 +632,7 @@ void MainWindow::on_actionAbout_triggered()
void MainWindow::on_actionRefresh_Panels_triggered() void MainWindow::on_actionRefresh_Panels_triggered()
{ {
this->updateFrames(); this->refreshAll();
} }
void MainWindow::toggleDockWidget(QDockWidget *dock_widget) void MainWindow::toggleDockWidget(QDockWidget *dock_widget)
@ -953,33 +902,9 @@ void MainWindow::on_actionQuit_triggered()
close(); close();
} }
void MainWindow::refreshVisibleDockWidgets()
{
/* TODO Just send a signal no? */
// There seems to be no convenience function to check if a QDockWidget
// is really visible or hidden in a tabbed dock. So:
auto isDockVisible = [](const QDockWidget * const pWidget)
{
return pWidget != nullptr && !pWidget->visibleRegion().isEmpty();
};
for (auto W : dockWidgets)
{
if (isDockVisible(W))
{
// Temporary hack
DockWidget *w = dynamic_cast<DockWidget *>(W);
if (w)
{
w->setup();
}
}
}
}
void MainWindow::on_actionRefresh_contents_triggered() void MainWindow::on_actionRefresh_contents_triggered()
{ {
refreshVisibleDockWidgets(); refreshAll();
} }
void MainWindow::on_actionAsmOptions_triggered() void MainWindow::on_actionAsmOptions_triggered()

View File

@ -14,7 +14,6 @@
#include <QList> #include <QList>
class CutterCore; class CutterCore;
class DockWidget;
class Omnibar; class Omnibar;
class PreviewWidget; class PreviewWidget;
class Notepad; class Notepad;
@ -77,9 +76,6 @@ public:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
void readSettings(); void readSettings();
void setFilename(const QString &fn); void setFilename(const QString &fn);
void updateFrames();
void refreshFunctions();
void refreshComments();
void addOutput(const QString &msg); void addOutput(const QString &msg);
void addDebugOutput(const QString &msg); void addDebugOutput(const QString &msg);
void sendToNotepad(const QString &txt); void sendToNotepad(const QString &txt);
@ -88,6 +84,8 @@ public:
public slots: public slots:
void refreshAll();
void dark(); void dark();
void def_theme(); void def_theme();
@ -124,8 +122,6 @@ public slots:
void backButton_clicked(); void backButton_clicked();
void refreshVisibleDockWidgets();
private slots: private slots:
void on_actionMem_triggered(); void on_actionMem_triggered();

View File

@ -547,6 +547,11 @@ bool CutterCore::getConfigb(const QString &k)
return r_config_get_i(core_->config, k.toUtf8().constData()) != 0; return r_config_get_i(core_->config, k.toUtf8().constData()) != 0;
} }
void CutterCore::triggerRefreshAll()
{
emit refreshAll();
}
void CutterCore::triggerAsmOptionsChanged() void CutterCore::triggerAsmOptionsChanged()
{ {
emit asmOptionsChanged(); emit asmOptionsChanged();

View File

@ -300,6 +300,8 @@ public:
void addFlag(RVA offset, QString name, RVA size); void addFlag(RVA offset, QString name, RVA size);
void triggerRefreshAll();
void triggerAsmOptionsChanged(); void triggerAsmOptionsChanged();
void resetDefaultAsmOptions(); void resetDefaultAsmOptions();
@ -312,7 +314,8 @@ public:
Sdb *db; Sdb *db;
signals: signals:
// TODO: create a more sophisticated update-event system void refreshAll();
void functionRenamed(QString prev_name, QString new_name); void functionRenamed(QString prev_name, QString new_name);
void flagsChanged(); void flagsChanged();
void commentsChanged(); void commentsChanged();

View File

@ -106,7 +106,6 @@ HEADERS += \
widgets/CommentsWidget.h \ widgets/CommentsWidget.h \
widgets/ConsoleWidget.h \ widgets/ConsoleWidget.h \
widgets/Dashboard.h \ widgets/Dashboard.h \
widgets/DockWidget.h \
widgets/EntrypointWidget.h \ widgets/EntrypointWidget.h \
widgets/ExportsWidget.h \ widgets/ExportsWidget.h \
widgets/FlagsWidget.h \ widgets/FlagsWidget.h \

View File

@ -227,7 +227,7 @@ void CreateNewDialog::on_buttonCreate_clicked()
close(); close();
core->seek(0); core->seek(0);
w->updateFrames(); w->refreshAll();
w->setFilename("-"); w->setFilename("-");
w->addOutput(tr("Finished, check its contents")); w->addOutput(tr("Finished, check its contents"));
w->showMaximized(); w->showMaximized();

View File

@ -39,6 +39,8 @@ GraphicsBar::GraphicsBar(MainWindow *main, QWidget *parent) :
*/ */
addWidget(this->codeGraphic); addWidget(this->codeGraphic);
//addWidget(addsCombo); //addWidget(addsCombo);
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillData()));
} }
void GraphicsBar::paintEvent(QPaintEvent *event) void GraphicsBar::paintEvent(QPaintEvent *event)
@ -51,7 +53,6 @@ void GraphicsBar::paintEvent(QPaintEvent *event)
void GraphicsBar::fillData() void GraphicsBar::fillData()
{ {
// Prepare the graph scene // Prepare the graph scene
int w = this->codeGraphic->width(); int w = this->codeGraphic->width();
int h = this->codeGraphic->height(); int h = this->codeGraphic->height();
@ -66,65 +67,57 @@ void GraphicsBar::fillData()
this->codeGraphic->setToolTip("gap"); this->codeGraphic->setToolTip("gap");
// Parse JSON data // Parse JSON data
QString jsonData = CutterCore::getInstance()->cmd("p-j"); QJsonDocument doc = Core()->cmdj("p-j");
QJsonDocument doc = QJsonDocument::fromJson(jsonData.toUtf8());
if (doc.isNull()) //get the jsonObject
QJsonObject jObject = doc.object();
//convert the json object to variantmap
QVariantMap mainMap = jObject.toVariantMap();
int from = mainMap["from"].toInt();
int to = mainMap["to"].toInt();
int block = mainMap["blocksize"].toInt();
int size = (to - from);
int num = size / block;
if (num < 1)
{ {
qDebug() << "Invalid json in p-j command"; num = 1;
} }
else if (doc.isObject()) int graph_block = w / num;
int counter = 0;
for (auto i : mainMap["blocks"].toList())
{ {
//get the jsonObject QMap<QString, QVariant> map = i.toMap();
QJsonObject jObject = doc.object(); if (map.empty())
//convert the json object to variantmap
QVariantMap mainMap = jObject.toVariantMap();
int from = mainMap["from"].toInt();
int to = mainMap["to"].toInt();
int block = mainMap["blocksize"].toInt();
int size = (to - from);
int num = size / block;
if (num < 1)
{ {
num = 1; // Fill empty color
// addRect(qreal x, qreal y, qreal w, qreal h, const QPen &pen = QPen(), const QBrush &brush = QBrush())
//scene->addRect(counter * graph_block, 0, graph_block ,h, QPen(Qt::NoPen), QBrush(QColor(252, 249, 190)));
QGraphicsRectItem *rect = new QGraphicsRectItem(counter * graph_block, 0, graph_block, h);
rect->setPen(Qt::NoPen);
rect->setBrush(QBrush(QColor(252, 249, 190)));
rect->setToolTip("Data");
scene->addItem(rect);
} }
int graph_block = w / num; else
int counter = 0;
for (auto i : mainMap["blocks"].toList())
{ {
QMap<QString, QVariant> map = i.toMap(); // Fill type of color
if (map.empty()) //scene->addRect(counter * graph_block, 0, graph_block ,h, QPen(Qt::NoPen), QBrush(QColor(69, 104, 229)));
QGraphicsRectItem *rect = new QGraphicsRectItem(counter * graph_block, 0, graph_block, h);
rect->setPen(Qt::NoPen);
if (i.toMap()["functions"].toInt() == 0)
{ {
// Fill empty color rect->setBrush(QBrush(QColor(190, 190, 190)));
// addRect(qreal x, qreal y, qreal w, qreal h, const QPen &pen = QPen(), const QBrush &brush = QBrush())
//scene->addRect(counter * graph_block, 0, graph_block ,h, QPen(Qt::NoPen), QBrush(QColor(252, 249, 190)));
QGraphicsRectItem *rect = new QGraphicsRectItem(counter * graph_block, 0, graph_block, h);
rect->setPen(Qt::NoPen);
rect->setBrush(QBrush(QColor(252, 249, 190)));
rect->setToolTip("Data");
scene->addItem(rect);
} }
else else
{ {
// Fill type of color rect->setBrush(QBrush(QColor(69, 104, 229)));
//scene->addRect(counter * graph_block, 0, graph_block ,h, QPen(Qt::NoPen), QBrush(QColor(69, 104, 229)));
QGraphicsRectItem *rect = new QGraphicsRectItem(counter * graph_block, 0, graph_block, h);
rect->setPen(Qt::NoPen);
if (i.toMap()["functions"].toInt() == 0)
{
rect->setBrush(QBrush(QColor(190, 190, 190)));
}
else
{
rect->setBrush(QBrush(QColor(69, 104, 229)));
}
rect->setToolTip("Offset: 0x" + QString::number(i.toMap()["offset"].toInt(), 16) + "\nFunctions: " + QString::number(i.toMap()["functions"].toInt()) + "\nFlags: " + QString::number(i.toMap()["flags"].toInt()));
scene->addItem(rect);
} }
counter += 1; rect->setToolTip("Offset: 0x" + QString::number(i.toMap()["offset"].toInt(), 16) + "\nFunctions: " + QString::number(i.toMap()["functions"].toInt()) + "\nFlags: " + QString::number(i.toMap()["flags"].toInt()));
scene->addItem(rect);
} }
counter += 1;
} }
} }

View File

@ -15,6 +15,8 @@ public:
public slots: public slots:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
private slots:
void fillData(); void fillData();
private: private:

View File

@ -8,7 +8,7 @@
#include "utils/Helpers.h" #include "utils/Helpers.h"
CommentsWidget::CommentsWidget(MainWindow *main, QWidget *parent) : CommentsWidget::CommentsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::CommentsWidget), ui(new Ui::CommentsWidget),
main(main) main(main)
{ {
@ -26,7 +26,8 @@ CommentsWidget::CommentsWidget(MainWindow *main, QWidget *parent) :
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showTitleContextMenu(const QPoint &))); this, SLOT(showTitleContextMenu(const QPoint &)));
connect(CutterCore::getInstance(), SIGNAL(commentsChanged()), this, SLOT(refreshTree())); connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshTree()));
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshTree()));
// Hide the buttons frame // Hide the buttons frame
ui->frame->hide(); ui->frame->hide();
@ -34,16 +35,6 @@ CommentsWidget::CommentsWidget(MainWindow *main, QWidget *parent) :
CommentsWidget::~CommentsWidget() {} CommentsWidget::~CommentsWidget() {}
void CommentsWidget::setup()
{
refreshTree();
}
void CommentsWidget::refresh()
{
refreshTree();
}
void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {
Q_UNUSED(column); Q_UNUSED(column);

View File

@ -1,9 +1,10 @@
#ifndef COMMENTSWIDGET_H #ifndef COMMENTSWIDGET_H
#define COMMENTSWIDGET_H #define COMMENTSWIDGET_H
#include "DockWidget.h"
#include <memory> #include <memory>
#include <QDockWidget>
class MainWindow; class MainWindow;
class QTreeWidgetItem; class QTreeWidgetItem;
@ -12,7 +13,7 @@ namespace Ui
class CommentsWidget; class CommentsWidget;
} }
class CommentsWidget : public DockWidget class CommentsWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -20,10 +21,6 @@ public:
explicit CommentsWidget(MainWindow *main, QWidget *parent = 0); explicit CommentsWidget(MainWindow *main, QWidget *parent = 0);
~CommentsWidget(); ~CommentsWidget();
void setup() override;
void refresh() override;
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
@ -31,15 +28,13 @@ private slots:
void on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column); void on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void on_toolButton_clicked(); void on_toolButton_clicked();
void on_toolButton_2_clicked(); void on_toolButton_2_clicked();
void showTitleContextMenu(const QPoint &pt);
void on_actionHorizontal_triggered(); void on_actionHorizontal_triggered();
void on_actionVertical_triggered(); void on_actionVertical_triggered();
void showTitleContextMenu(const QPoint &pt);
void refreshTree(); void refreshTree();
private: private:

View File

@ -13,27 +13,17 @@
Dashboard::Dashboard(MainWindow *main, QWidget *parent) : Dashboard::Dashboard(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::Dashboard), ui(new Ui::Dashboard),
main(main) main(main)
{ {
ui->setupUi(this); ui->setupUi(this);
//this->updateContents(); connect(Core(), SIGNAL(refreshAll()), this, SLOT(updateContents()));
} }
Dashboard::~Dashboard() {} Dashboard::~Dashboard() {}
void Dashboard::setup()
{
updateContents();
}
void Dashboard::refresh()
{
updateContents();
}
void Dashboard::updateContents() void Dashboard::updateContents()
{ {
// Parse and add JSON file info // Parse and add JSON file info

View File

@ -1,9 +1,10 @@
#ifndef DASHBOARD_H #ifndef DASHBOARD_H
#define DASHBOARD_H #define DASHBOARD_H
#include "DockWidget.h"
#include <memory> #include <memory>
#include <QDockWidget>
class MainWindow; class MainWindow;
namespace Ui namespace Ui
@ -11,7 +12,7 @@ namespace Ui
class Dashboard; class Dashboard;
} }
class Dashboard : public DockWidget class Dashboard : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -19,13 +20,10 @@ public:
explicit Dashboard(MainWindow *main, QWidget *parent = 0); explicit Dashboard(MainWindow *main, QWidget *parent = 0);
~Dashboard(); ~Dashboard();
void setup() override; private slots:
void refresh() override;
private:
void updateContents(); void updateContents();
private:
std::unique_ptr<Ui::Dashboard> ui; std::unique_ptr<Ui::Dashboard> ui;
MainWindow *main; MainWindow *main;
}; };

View File

@ -74,6 +74,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
}); });
//Connect to bridge //Connect to bridge
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshView()));
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSeekChanged(RVA))); connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSeekChanged(RVA)));
connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshView())); connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshView()));
//connect(Bridge::getBridge(), SIGNAL(loadGraph(BridgeCFGraphList*, duint)), this, SLOT(loadGraphSlot(BridgeCFGraphList*, duint))); //connect(Bridge::getBridge(), SIGNAL(loadGraph(BridgeCFGraphList*, duint)), this, SLOT(loadGraphSlot(BridgeCFGraphList*, duint)));

View File

@ -88,6 +88,10 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent)
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly); Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
} }
}); });
connect(Core(), &CutterCore::refreshAll, this, [this]() {
refreshDisasm(Core()->getOffset());
});
} }
DisassemblyWidget::DisassemblyWidget(const QString &title, QWidget *parent) : DisassemblyWidget::DisassemblyWidget(const QString &title, QWidget *parent) :

View File

@ -1,18 +0,0 @@
#ifndef DOCKWIDGET_H
#define DOCKWIDGET_H
#include <QDockWidget>
class DockWidget : public QDockWidget
{
public:
explicit DockWidget(QWidget *parent = nullptr) :
QDockWidget(parent) {}
virtual ~DockWidget() {}
virtual void setup() = 0;
virtual void refresh() = 0;
};
#endif // DOCKWIDGET_H

View File

@ -13,7 +13,7 @@
*/ */
EntrypointWidget::EntrypointWidget(MainWindow *main, QWidget *parent) : EntrypointWidget::EntrypointWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::EntrypointWidget), ui(new Ui::EntrypointWidget),
main(main) main(main)
{ {
@ -24,22 +24,14 @@ EntrypointWidget::EntrypointWidget(MainWindow *main, QWidget *parent) :
//ui->importsTreeWidget->setItemDelegate(delegate); //ui->importsTreeWidget->setItemDelegate(delegate);
ui->entrypointTreeWidget->hideColumn(0); ui->entrypointTreeWidget->hideColumn(0);
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillEntrypoint()));
} }
EntrypointWidget::~EntrypointWidget() {} EntrypointWidget::~EntrypointWidget() {}
void EntrypointWidget::setup()
{
setScrollMode();
fillEntrypoint();
}
void EntrypointWidget::refresh()
{
setup();
}
void EntrypointWidget::fillEntrypoint() void EntrypointWidget::fillEntrypoint()
{ {
ui->entrypointTreeWidget->clear(); ui->entrypointTreeWidget->clear();

View File

@ -1,10 +1,11 @@
#ifndef ENTRYPOINTWIDGET_H #ifndef ENTRYPOINTWIDGET_H
#define ENTRYPOINTWIDGET_H #define ENTRYPOINTWIDGET_H
#include "DockWidget.h" #include <memory>
#include <QDockWidget>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <memory>
class MainWindow; class MainWindow;
class QTreeWidget; class QTreeWidget;
@ -14,7 +15,7 @@ namespace Ui
class EntrypointWidget; class EntrypointWidget;
} }
class EntrypointWidget : public DockWidget class EntrypointWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -22,18 +23,15 @@ public:
explicit EntrypointWidget(MainWindow *main, QWidget *parent = 0); explicit EntrypointWidget(MainWindow *main, QWidget *parent = 0);
~EntrypointWidget(); ~EntrypointWidget();
void setup() override;
void refresh() override;
private slots: private slots:
void on_entrypointTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column); void on_entrypointTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void fillEntrypoint();
private: private:
std::unique_ptr<Ui::EntrypointWidget> ui; std::unique_ptr<Ui::EntrypointWidget> ui;
MainWindow *main; MainWindow *main;
void fillEntrypoint();
void setScrollMode(); void setScrollMode();
}; };

View File

@ -130,7 +130,7 @@ bool ExportsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModel
ExportsWidget::ExportsWidget(MainWindow *main, QWidget *parent) : ExportsWidget::ExportsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::ExportsWidget), ui(new Ui::ExportsWidget),
main(main) main(main)
{ {
@ -143,22 +143,14 @@ ExportsWidget::ExportsWidget(MainWindow *main, QWidget *parent) :
exports_proxy_model = new ExportsSortFilterProxyModel(exports_model, this); exports_proxy_model = new ExportsSortFilterProxyModel(exports_model, this);
ui->exportsTreeView->setModel(exports_proxy_model); ui->exportsTreeView->setModel(exports_proxy_model);
ui->exportsTreeView->sortByColumn(ExportsModel::OFFSET, Qt::AscendingOrder); ui->exportsTreeView->sortByColumn(ExportsModel::OFFSET, Qt::AscendingOrder);
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshExports()));
} }
ExportsWidget::~ExportsWidget() {} ExportsWidget::~ExportsWidget() {}
void ExportsWidget::setup()
{
setScrollMode();
refreshExports();
}
void ExportsWidget::refresh()
{
setup();
}
void ExportsWidget::refreshExports() void ExportsWidget::refreshExports()
{ {
exports_model->beginReloadExports(); exports_model->beginReloadExports();

View File

@ -1,11 +1,13 @@
#ifndef EXPORTSWIDGET_H #ifndef EXPORTSWIDGET_H
#define EXPORTSWIDGET_H #define EXPORTSWIDGET_H
#include <memory>
#include "cutter.h" #include "cutter.h"
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <memory> #include <QDockWidget>
#include "DockWidget.h"
class MainWindow; class MainWindow;
class QTreeWidget; class QTreeWidget;
@ -59,7 +61,7 @@ protected:
class ExportsWidget : public DockWidget class ExportsWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -67,12 +69,11 @@ public:
explicit ExportsWidget(MainWindow *main, QWidget *parent = 0); explicit ExportsWidget(MainWindow *main, QWidget *parent = 0);
~ExportsWidget(); ~ExportsWidget();
void setup() override;
void refresh() override;
private slots: private slots:
void on_exportsTreeView_doubleClicked(const QModelIndex &index); void on_exportsTreeView_doubleClicked(const QModelIndex &index);
void refreshExports();
private: private:
std::unique_ptr<Ui::ExportsWidget> ui; std::unique_ptr<Ui::ExportsWidget> ui;
MainWindow *main; MainWindow *main;
@ -81,7 +82,6 @@ private:
ExportsSortFilterProxyModel *exports_proxy_model; ExportsSortFilterProxyModel *exports_proxy_model;
QList<ExportDescription> exports; QList<ExportDescription> exports;
void refreshExports();
void setScrollMode(); void setScrollMode();
}; };

View File

@ -125,7 +125,7 @@ bool FlagsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIn
FlagsWidget::FlagsWidget(MainWindow *main, QWidget *parent) : FlagsWidget::FlagsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::FlagsWidget), ui(new Ui::FlagsWidget),
main(main) main(main)
{ {
@ -137,23 +137,14 @@ FlagsWidget::FlagsWidget(MainWindow *main, QWidget *parent) :
ui->flagsTreeView->setModel(flags_proxy_model); ui->flagsTreeView->setModel(flags_proxy_model);
ui->flagsTreeView->sortByColumn(FlagsModel::OFFSET, Qt::AscendingOrder); ui->flagsTreeView->sortByColumn(FlagsModel::OFFSET, Qt::AscendingOrder);
connect(CutterCore::getInstance(), SIGNAL(flagsChanged()), this, SLOT(flagsChanged())); setScrollMode();
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(flagsChanged()));
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshFlagspaces()));
} }
FlagsWidget::~FlagsWidget() {} FlagsWidget::~FlagsWidget() {}
void FlagsWidget::setup()
{
setScrollMode();
refreshFlagspaces();
}
void FlagsWidget::refresh()
{
refreshFlagspaces();
}
void FlagsWidget::on_flagsTreeView_doubleClicked(const QModelIndex &index) void FlagsWidget::on_flagsTreeView_doubleClicked(const QModelIndex &index)
{ {
FlagDescription flag = index.data(FlagsModel::FlagDescriptionRole).value<FlagDescription>(); FlagDescription flag = index.data(FlagsModel::FlagDescriptionRole).value<FlagDescription>();

View File

@ -1,11 +1,13 @@
#ifndef FLAGSWIDGET_H #ifndef FLAGSWIDGET_H
#define FLAGSWIDGET_H #define FLAGSWIDGET_H
#include <memory>
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <memory> #include <QDockWidget>
#include "cutter.h" #include "cutter.h"
#include "DockWidget.h"
class MainWindow; class MainWindow;
class QTreeWidgetItem; class QTreeWidgetItem;
@ -55,7 +57,7 @@ namespace Ui
class FlagsWidget; class FlagsWidget;
} }
class FlagsWidget : public DockWidget class FlagsWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -63,14 +65,12 @@ public:
explicit FlagsWidget(MainWindow *main, QWidget *parent = 0); explicit FlagsWidget(MainWindow *main, QWidget *parent = 0);
~FlagsWidget(); ~FlagsWidget();
void setup() override;
void refresh() override;
private slots: private slots:
void on_flagsTreeView_doubleClicked(const QModelIndex &index); void on_flagsTreeView_doubleClicked(const QModelIndex &index);
void on_flagspaceCombo_currentTextChanged(const QString &arg1); void on_flagspaceCombo_currentTextChanged(const QString &arg1);
void flagsChanged(); void flagsChanged();
void refreshFlagspaces();
private: private:
std::unique_ptr<Ui::FlagsWidget> ui; std::unique_ptr<Ui::FlagsWidget> ui;
@ -81,7 +81,6 @@ private:
QList<FlagDescription> flags; QList<FlagDescription> flags;
void refreshFlags(); void refreshFlags();
void refreshFlagspaces();
void setScrollMode(); void setScrollMode();
}; };

View File

@ -326,7 +326,7 @@ bool FunctionSortFilterProxyModel::lessThan(const QModelIndex &left, const QMode
FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) : FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::FunctionsWidget), ui(new Ui::FunctionsWidget),
main(main) main(main)
{ {
@ -362,6 +362,7 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
connect(ui->filterLineEdit, SIGNAL(textChanged(const QString &)), nested_function_proxy_model, SLOT(setFilterWildcard(const QString &))); connect(ui->filterLineEdit, SIGNAL(textChanged(const QString &)), nested_function_proxy_model, SLOT(setFilterWildcard(const QString &)));
ui->nestedFunctionsTreeView->setModel(nested_function_proxy_model); ui->nestedFunctionsTreeView->setModel(nested_function_proxy_model);
setScrollMode();
// Set Functions context menu // Set Functions context menu
connect(ui->functionsTreeView, SIGNAL(customContextMenuRequested(const QPoint &)), connect(ui->functionsTreeView, SIGNAL(customContextMenuRequested(const QPoint &)),
@ -383,21 +384,12 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
this->setContextMenuPolicy(Qt::CustomContextMenu); this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showTitleContextMenu(const QPoint &))); this, SLOT(showTitleContextMenu(const QPoint &)));
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshTree()));
} }
FunctionsWidget::~FunctionsWidget() {} FunctionsWidget::~FunctionsWidget() {}
void FunctionsWidget::setup()
{
setScrollMode();
refreshTree();
}
void FunctionsWidget::refresh()
{
setup();
}
void FunctionsWidget::refreshTree() void FunctionsWidget::refreshTree()
{ {
function_model->beginReloadFunctions(); function_model->beginReloadFunctions();
@ -470,7 +462,6 @@ void FunctionsWidget::on_actionDisasAdd_comment_triggered()
CutterCore::getInstance()->seek(function.offset); CutterCore::getInstance()->seek(function.offset);
// TODO: Refresh functions tree widget // TODO: Refresh functions tree widget
} }
this->main->refreshComments();
} }
void FunctionsWidget::on_actionFunctionsRename_triggered() void FunctionsWidget::on_actionFunctionsRename_triggered()

View File

@ -1,11 +1,13 @@
#ifndef FUNCTIONSWIDGET_H #ifndef FUNCTIONSWIDGET_H
#define FUNCTIONSWIDGET_H #define FUNCTIONSWIDGET_H
#include <memory>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QTreeView> #include <QTreeView>
#include <memory> #include <QDockWidget>
#include "cutter.h" #include "cutter.h"
#include "DockWidget.h"
class MainWindow; class MainWindow;
class QTreeWidgetItem; class QTreeWidgetItem;
@ -78,7 +80,7 @@ protected:
class FunctionsWidget : public DockWidget class FunctionsWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -86,10 +88,6 @@ public:
explicit FunctionsWidget(MainWindow *main, QWidget *parent = 0); explicit FunctionsWidget(MainWindow *main, QWidget *parent = 0);
~FunctionsWidget(); ~FunctionsWidget();
void setup() override;
void refresh() override;
private slots: private slots:
void functionsTreeView_doubleClicked(const QModelIndex &index); void functionsTreeView_doubleClicked(const QModelIndex &index);
void showFunctionsContextMenu(const QPoint &pt); void showFunctionsContextMenu(const QPoint &pt);
@ -109,6 +107,8 @@ private slots:
void showTitleContextMenu(const QPoint &pt); void showTitleContextMenu(const QPoint &pt);
void refreshTree();
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
@ -127,7 +127,6 @@ private:
FunctionModel *nested_function_model; FunctionModel *nested_function_model;
FunctionSortFilterProxyModel *nested_function_proxy_model; FunctionSortFilterProxyModel *nested_function_proxy_model;
void refreshTree();
void setScrollMode(); void setScrollMode();
}; };

View File

@ -68,6 +68,10 @@ HexdumpWidget::HexdumpWidget(QWidget *parent, Qt::WindowFlags flags) :
} }
}); });
connect(Core(), &CutterCore::refreshAll, this, [this]() {
refresh(Core()->getOffset());
});
fillPlugins(); fillPlugins();
} }

View File

@ -33,7 +33,7 @@ void CMyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c
*/ */
ImportsWidget::ImportsWidget(MainWindow *main, QWidget *parent) : ImportsWidget::ImportsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::ImportsWidget), ui(new Ui::ImportsWidget),
main(main) main(main)
{ {
@ -44,22 +44,14 @@ ImportsWidget::ImportsWidget(MainWindow *main, QWidget *parent) :
//ui->importsTreeWidget->setItemDelegate(delegate); //ui->importsTreeWidget->setItemDelegate(delegate);
ui->importsTreeWidget->hideColumn(0); ui->importsTreeWidget->hideColumn(0);
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillImports()));
} }
ImportsWidget::~ImportsWidget() {} ImportsWidget::~ImportsWidget() {}
void ImportsWidget::setup()
{
setScrollMode();
fillImports();
}
void ImportsWidget::refresh()
{
setup();
}
void ImportsWidget::fillImports() void ImportsWidget::fillImports()
{ {
ui->importsTreeWidget->clear(); ui->importsTreeWidget->clear();

View File

@ -1,10 +1,11 @@
#ifndef IMPORTSWIDGET_H #ifndef IMPORTSWIDGET_H
#define IMPORTSWIDGET_H #define IMPORTSWIDGET_H
#include "DockWidget.h" #include <memory>
#include <QDockWidget>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <memory>
class MainWindow; class MainWindow;
class QTreeWidget; class QTreeWidget;
@ -14,7 +15,7 @@ namespace Ui
class ImportsWidget; class ImportsWidget;
} }
class ImportsWidget : public DockWidget class ImportsWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -22,18 +23,15 @@ public:
explicit ImportsWidget(MainWindow *main, QWidget *parent = 0); explicit ImportsWidget(MainWindow *main, QWidget *parent = 0);
~ImportsWidget(); ~ImportsWidget();
void setup() override;
void refresh() override;
private slots: private slots:
void on_importsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column); void on_importsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void fillImports();
private: private:
std::unique_ptr<Ui::ImportsWidget> ui; std::unique_ptr<Ui::ImportsWidget> ui;
MainWindow *main; MainWindow *main;
void fillImports();
void highlightUnsafe(); void highlightUnsafe();
void setScrollMode(); void setScrollMode();
}; };

View File

@ -141,7 +141,7 @@ void Omnibar::on_gotoEntry_returnPressed()
} }
else if (str.contains("Refresh")) else if (str.contains("Refresh"))
{ {
this->main->refreshVisibleDockWidgets(); this->main->refreshAll();
} }
else if (str.contains("Relocs")) else if (str.contains("Relocs"))
{ {

View File

@ -5,7 +5,7 @@
#include "utils/Helpers.h" #include "utils/Helpers.h"
RelocsWidget::RelocsWidget(MainWindow *main, QWidget *parent) : RelocsWidget::RelocsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::RelocsWidget), ui(new Ui::RelocsWidget),
main(main) main(main)
{ {
@ -15,22 +15,14 @@ RelocsWidget::RelocsWidget(MainWindow *main, QWidget *parent) :
this->main = main; this->main = main;
ui->relocsTreeWidget->hideColumn(0); ui->relocsTreeWidget->hideColumn(0);
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillTreeWidget()));
} }
RelocsWidget::~RelocsWidget() {} RelocsWidget::~RelocsWidget() {}
void RelocsWidget::setup()
{
setScrollMode();
fillTreeWidget();
}
void RelocsWidget::refresh()
{
setup();
}
void RelocsWidget::on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void RelocsWidget::on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {
Q_UNUSED(column); Q_UNUSED(column);

View File

@ -1,9 +1,10 @@
#ifndef RELOCSWIDGET_H #ifndef RELOCSWIDGET_H
#define RELOCSWIDGET_H #define RELOCSWIDGET_H
#include "Dashboard.h"
#include <memory> #include <memory>
#include <QDockWidget>
class MainWindow; class MainWindow;
class QTreeWidgetItem; class QTreeWidgetItem;
@ -12,7 +13,7 @@ namespace Ui
class RelocsWidget; class RelocsWidget;
} }
class RelocsWidget : public DockWidget class RelocsWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -20,18 +21,15 @@ public:
explicit RelocsWidget(MainWindow *main, QWidget *parent = 0); explicit RelocsWidget(MainWindow *main, QWidget *parent = 0);
~RelocsWidget(); ~RelocsWidget();
void setup() override;
void refresh() override;
private slots: private slots:
void on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column); void on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void fillTreeWidget();
private: private:
std::unique_ptr<Ui::RelocsWidget> ui; std::unique_ptr<Ui::RelocsWidget> ui;
MainWindow *main; MainWindow *main;
void fillTreeWidget();
void setScrollMode(); void setScrollMode();
}; };

View File

@ -7,21 +7,25 @@
#include <QTreeWidget> #include <QTreeWidget>
SdbDock::SdbDock(MainWindow *main, QWidget *parent) : SdbDock::SdbDock(QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::SdbDock) ui(new Ui::SdbDock)
{ {
ui->setupUi(this); ui->setupUi(this);
// Radare core found in:
this->main = main; path = "";
this->path = "";
reload(""); connect(Core(), SIGNAL(refreshAll()), this, SLOT(reload()));
} }
void SdbDock::reload(QString path) void SdbDock::reload(QString _path)
{ {
if (!_path.isNull())
{
path = _path;
}
ui->lineEdit->setText(path); ui->lineEdit->setText(path);
this->path = path;
/* insert root sdb keyvalue pairs */ /* insert root sdb keyvalue pairs */
ui->treeWidget->clear(); ui->treeWidget->clear();
@ -95,18 +99,6 @@ void SdbDock::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
SdbDock::~SdbDock() {} SdbDock::~SdbDock() {}
void SdbDock::setup()
{
// TODO: implement
eprintf("%s - not implemented\n", Q_FUNC_INFO);
}
void SdbDock::refresh()
{
// TODO: implement
eprintf("%s - not implemented\n", Q_FUNC_INFO);
}
void SdbDock::on_lockButton_clicked() void SdbDock::on_lockButton_clicked()
{ {
if (ui->lockButton->isChecked()) if (ui->lockButton->isChecked())

View File

@ -1,9 +1,10 @@
#ifndef SDBDOCK_H #ifndef SDBDOCK_H
#define SDBDOCK_H #define SDBDOCK_H
#include "DockWidget.h"
#include <memory> #include <memory>
#include <QDockWidget>
class MainWindow; class MainWindow;
class QTreeWidgetItem; class QTreeWidgetItem;
@ -12,31 +13,25 @@ namespace Ui
class SdbDock; class SdbDock;
} }
class SdbDock : public DockWidget class SdbDock : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SdbDock(MainWindow *main, QWidget *parent = 0); explicit SdbDock(QWidget *parent = 0);
~SdbDock(); ~SdbDock();
void setup() override;
void refresh() override;
private slots: private slots:
void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column); void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void on_lockButton_clicked(); void on_lockButton_clicked();
void on_treeWidget_itemChanged(QTreeWidgetItem *item, int column); void on_treeWidget_itemChanged(QTreeWidgetItem *item, int column);
void reload(QString _path = nullptr);
private: private:
std::unique_ptr<Ui::SdbDock> ui; std::unique_ptr<Ui::SdbDock> ui;
QString path; QString path;
MainWindow *main;
void reload(QString path);
}; };
#endif // SDBDOCK_H #endif // SDBDOCK_H

View File

@ -9,7 +9,7 @@
SectionsDock::SectionsDock(MainWindow *main, QWidget *parent) : SectionsDock::SectionsDock(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::SectionsDock) ui(new Ui::SectionsDock)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -27,16 +27,6 @@ SectionsDock::SectionsDock(MainWindow *main, QWidget *parent) :
SectionsDock::~SectionsDock() {} SectionsDock::~SectionsDock() {}
void SectionsDock::setup()
{
sectionsWidget->setup();
}
void SectionsDock::refresh()
{
sectionsWidget->setup();
}
void SectionsDock::showSectionsContextMenu(const QPoint &pt) void SectionsDock::showSectionsContextMenu(const QPoint &pt)
{ {
// Set functions popup menu // Set functions popup menu

View File

@ -1,9 +1,10 @@
#ifndef SECTIONSDOCK_H #ifndef SECTIONSDOCK_H
#define SECTIONSDOCK_H #define SECTIONSDOCK_H
#include "DockWidget.h"
#include <memory> #include <memory>
#include <QDockWidget>
class MainWindow; class MainWindow;
class SectionsWidget; class SectionsWidget;
@ -12,7 +13,7 @@ namespace Ui
class SectionsDock; class SectionsDock;
} }
class SectionsDock : public DockWidget class SectionsDock : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -20,10 +21,6 @@ public:
explicit SectionsDock(MainWindow *main, QWidget *parent = 0); explicit SectionsDock(MainWindow *main, QWidget *parent = 0);
~SectionsDock(); ~SectionsDock();
void setup() override;
void refresh() override;
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;

View File

@ -17,9 +17,11 @@ SectionsWidget::SectionsWidget(MainWindow *main, QWidget *parent) :
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
//setStyleSheet("QSplitter::handle:horizontal { width: 3px; } QSplitter::handle:vertical { height: 3px; }"); //setStyleSheet("QSplitter::handle:horizontal { width: 3px; } QSplitter::handle:vertical { height: 3px; }");
setStyleSheet("QSplitter::handle { height: 2px; background-color: rgb(255, 255, 255); image: url(:/img/icons/tabs.svg); }"); setStyleSheet("QSplitter::handle { height: 2px; background-color: rgb(255, 255, 255); image: url(:/img/icons/tabs.svg); }");
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshSections()));
} }
void SectionsWidget::setup() void SectionsWidget::refreshSections()
{ {
tree->clear(); tree->clear();

View File

@ -23,7 +23,8 @@ class SectionsWidget : public QSplitter
public: public:
explicit SectionsWidget(MainWindow *main, QWidget *parent = 0); explicit SectionsWidget(MainWindow *main, QWidget *parent = 0);
void setup(); private slots:
void refreshSections();
private: private:
QAbstractItemView *pieChart; QAbstractItemView *pieChart;

View File

@ -108,5 +108,5 @@ void SideBar::on_respButton_toggled(bool checked)
void SideBar::on_refreshButton_clicked() void SideBar::on_refreshButton_clicked()
{ {
this->main->refreshVisibleDockWidgets(); this->main->refreshAll();
} }

View File

@ -17,8 +17,7 @@
SidebarWidget::SidebarWidget(QWidget *parent, Qt::WindowFlags flags) : SidebarWidget::SidebarWidget(QWidget *parent, Qt::WindowFlags flags) :
QDockWidget(parent, flags), QDockWidget(parent, flags),
ui(new Ui::SidebarWidget), ui(new Ui::SidebarWidget)
core(CutterCore::getInstance())
{ {
ui->setupUi(this); ui->setupUi(this);
this->xrefToTreeWidget_2 = ui->xrefToTreeWidget_2; this->xrefToTreeWidget_2 = ui->xrefToTreeWidget_2;
@ -27,12 +26,14 @@ SidebarWidget::SidebarWidget(QWidget *parent, Qt::WindowFlags flags) :
// Add margin to function name line edit // Add margin to function name line edit
ui->fcnNameEdit->setTextMargins(5, 0, 0, 0); ui->fcnNameEdit->setTextMargins(5, 0, 0, 0);
connect(core, SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
connect(core, SIGNAL(flagsChanged()), this, SLOT(refresh()));
connect(core, SIGNAL(commentsChanged()), this, SLOT(refresh()));
connect(core, SIGNAL(asmOptionsChanged()), this, SLOT(refresh()));
setScrollMode(); setScrollMode();
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refresh()));
connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refresh()));
connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(refresh()));
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refresh()));
} }
SidebarWidget::SidebarWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) SidebarWidget::SidebarWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags)
@ -54,7 +55,7 @@ void SidebarWidget::on_seekChanged(RVA addr)
void SidebarWidget::refresh(RVA addr) void SidebarWidget::refresh(RVA addr)
{ {
if(addr == RVA_INVALID) if(addr == RVA_INVALID)
addr = core->getOffset(); addr = Core()->getOffset();
get_refs_data(addr); get_refs_data(addr);
setFcnName(addr); setFcnName(addr);
@ -82,13 +83,13 @@ void SidebarWidget::on_offsetToolButton_clicked()
void SidebarWidget::on_xreFromTreeWidget_2_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/) void SidebarWidget::on_xreFromTreeWidget_2_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
{ {
XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>(); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
this->core->seek(xref.to); Core()->seek(xref.to);
} }
void SidebarWidget::on_xrefToTreeWidget_2_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/) void SidebarWidget::on_xrefToTreeWidget_2_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
{ {
XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>(); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
this->core->seek(xref.from); Core()->seek(xref.from);
} }
void SidebarWidget::on_xrefFromToolButton_2_clicked() void SidebarWidget::on_xrefFromToolButton_2_clicked()
@ -122,10 +123,10 @@ void SidebarWidget::on_xrefToToolButton_2_clicked()
void SidebarWidget::get_refs_data(RVA addr) void SidebarWidget::get_refs_data(RVA addr)
{ {
// refs = calls q hace esa funcion // refs = calls q hace esa funcion
QList<XrefDescription> refs = core->getXRefs(addr, false, false); QList<XrefDescription> refs = Core()->getXRefs(addr, false, false);
// xrefs = calls a esa funcion // xrefs = calls a esa funcion
QList<XrefDescription> xrefs = core->getXRefs(addr, true, false); QList<XrefDescription> xrefs = Core()->getXRefs(addr, true, false);
// Data for the disasm side graph // Data for the disasm side graph
QList<int> data; QList<int> data;
@ -135,10 +136,10 @@ void SidebarWidget::get_refs_data(RVA addr)
data << xrefs.size(); data << xrefs.size();
//qDebug() << "CC: " << this->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16)); //qDebug() << "CC: " << this->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16));
//data << this->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16)); //data << this->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16));
data << this->core->getCycloComplex(addr); data << Core()->getCycloComplex(addr);
//qDebug() << "BB: " << this->core->fcnBasicBlockCount(offset.toLong(&ok, 16)); //qDebug() << "BB: " << this->core->fcnBasicBlockCount(offset.toLong(&ok, 16));
data << this->core->fcnBasicBlockCount(addr); data << Core()->fcnBasicBlockCount(addr);
data << this->core->fcnEndBbs(addr); data << Core()->fcnEndBbs(addr);
//qDebug() << "MEOW: " + this->core->fcnEndBbs(offset); //qDebug() << "MEOW: " + this->core->fcnEndBbs(offset);
// Update disasm side bar // Update disasm side bar
@ -154,9 +155,9 @@ void SidebarWidget::fill_refs(QList<XrefDescription> refs, QList<XrefDescription
XrefDescription xref = refs[i]; XrefDescription xref = refs[i];
QTreeWidgetItem *tempItem = new QTreeWidgetItem(); QTreeWidgetItem *tempItem = new QTreeWidgetItem();
tempItem->setText(0, RAddressString(xref.to)); tempItem->setText(0, RAddressString(xref.to));
tempItem->setText(1, core->disassembleSingleInstruction(xref.from)); tempItem->setText(1, Core()->disassembleSingleInstruction(xref.from));
tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref)); tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref));
QString tooltip = this->core->cmd("pdi 10 @ " + QString::number(xref.to)).trimmed(); QString tooltip = Core()->cmd("pdi 10 @ " + QString::number(xref.to)).trimmed();
tempItem->setToolTip(0, tooltip); tempItem->setToolTip(0, tooltip);
tempItem->setToolTip(1, tooltip); tempItem->setToolTip(1, tooltip);
this->xreFromTreeWidget_2->insertTopLevelItem(0, tempItem); this->xreFromTreeWidget_2->insertTopLevelItem(0, tempItem);
@ -175,9 +176,9 @@ void SidebarWidget::fill_refs(QList<XrefDescription> refs, QList<XrefDescription
QTreeWidgetItem *tempItem = new QTreeWidgetItem(); QTreeWidgetItem *tempItem = new QTreeWidgetItem();
tempItem->setText(0, RAddressString(xref.from)); tempItem->setText(0, RAddressString(xref.from));
tempItem->setText(1, core->disassembleSingleInstruction(xref.from)); tempItem->setText(1, Core()->disassembleSingleInstruction(xref.from));
tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref)); tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref));
QString tooltip = this->core->cmd("pdi 10 @ " + QString::number(xref.from)).trimmed(); QString tooltip = Core()->cmd("pdi 10 @ " + QString::number(xref.from)).trimmed();
// TODO wtf is this? // TODO wtf is this?
//tempItem->setToolTip(0, this->core->cmd("pdi 10 @ " + tooltip).trimmed()); //tempItem->setToolTip(0, this->core->cmd("pdi 10 @ " + tooltip).trimmed());
@ -196,7 +197,7 @@ void SidebarWidget::fill_refs(QList<XrefDescription> refs, QList<XrefDescription
void SidebarWidget::fillOffsetInfo(QString off) void SidebarWidget::fillOffsetInfo(QString off)
{ {
ui->offsetTreeWidget->clear(); ui->offsetTreeWidget->clear();
QString raw = this->core->getOffsetInfo(off); QString raw = Core()->getOffsetInfo(off);
QList<QString> lines = raw.split("\n", QString::SkipEmptyParts); QList<QString> lines = raw.split("\n", QString::SkipEmptyParts);
foreach (QString line, lines) foreach (QString line, lines)
{ {
@ -215,7 +216,7 @@ void SidebarWidget::fillOffsetInfo(QString off)
} }
// Add opcode description // Add opcode description
QStringList description = this->core->cmd("?d. @ " + off).split(": "); QStringList description = Core()->cmd("?d. @ " + off).split(": ");
if (description.length() >= 2) if (description.length() >= 2)
{ {
ui->opcodeDescText->setPlainText("# " + description[0] + ":\n" + description[1]); ui->opcodeDescText->setPlainText("# " + description[0] + ":\n" + description[1]);
@ -227,15 +228,15 @@ void SidebarWidget::setFcnName(RVA addr)
RAnalFunction *fcn; RAnalFunction *fcn;
QString addr_string; QString addr_string;
fcn = this->core->functionAt(addr); fcn = Core()->functionAt(addr);
if (fcn) if (fcn)
{ {
QString segment = this->core->cmd("S. @ " + QString::number(addr)).split(" ").last(); QString segment = Core()->cmd("S. @ " + QString::number(addr)).split(" ").last();
addr_string = segment.trimmed() + ":" + fcn->name; addr_string = segment.trimmed() + ":" + fcn->name;
} }
else else
{ {
addr_string = core->cmdFunctionAt(addr); addr_string = Core()->cmdFunctionAt(addr);
} }
ui->fcnNameEdit->setText(addr_string); ui->fcnNameEdit->setText(addr_string);

View File

@ -38,7 +38,6 @@ public:
private: private:
std::unique_ptr<Ui::SidebarWidget> ui; std::unique_ptr<Ui::SidebarWidget> ui;
CutterCore *core;
void setFcnName(RVA addr); void setFcnName(RVA addr);
void get_refs_data(RVA addr); void get_refs_data(RVA addr);

View File

@ -8,29 +8,21 @@
StringsWidget::StringsWidget(MainWindow *main, QWidget *parent) : StringsWidget::StringsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::StringsWidget), ui(new Ui::StringsWidget),
main(main) main(main)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->stringsTreeWidget->hideColumn(0); ui->stringsTreeWidget->hideColumn(0);
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillTreeWidget()));
} }
StringsWidget::~StringsWidget() {} StringsWidget::~StringsWidget() {}
void StringsWidget::setup()
{
setScrollMode();
fillTreeWidget();
}
void StringsWidget::refresh()
{
setup();
}
void StringsWidget::on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void StringsWidget::on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {
Q_UNUSED(column); Q_UNUSED(column);

View File

@ -1,9 +1,10 @@
#ifndef STRINGSWIDGET_H #ifndef STRINGSWIDGET_H
#define STRINGSWIDGET_H #define STRINGSWIDGET_H
#include "DockWidget.h"
#include <memory> #include <memory>
#include <QDockWidget>
class MainWindow; class MainWindow;
class QTreeWidgetItem; class QTreeWidgetItem;
@ -12,7 +13,7 @@ namespace Ui
class StringsWidget; class StringsWidget;
} }
class StringsWidget : public DockWidget class StringsWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -20,20 +21,15 @@ public:
explicit StringsWidget(MainWindow *main, QWidget *parent = 0); explicit StringsWidget(MainWindow *main, QWidget *parent = 0);
~StringsWidget(); ~StringsWidget();
void setup() override;
void refresh() override;
void fillStrings();
private slots: private slots:
void on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column); void on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void fillTreeWidget();
private: private:
std::unique_ptr<Ui::StringsWidget> ui; std::unique_ptr<Ui::StringsWidget> ui;
MainWindow *main; MainWindow *main;
void fillTreeWidget();
void setScrollMode(); void setScrollMode();
}; };

View File

@ -8,27 +8,20 @@
SymbolsWidget::SymbolsWidget(QWidget *parent) : SymbolsWidget::SymbolsWidget(QWidget *parent) :
DockWidget(parent), QDockWidget(parent),
ui(new Ui::SymbolsWidget) ui(new Ui::SymbolsWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->symbolsTreeWidget->hideColumn(0); ui->symbolsTreeWidget->hideColumn(0);
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillSymbols()));
} }
SymbolsWidget::~SymbolsWidget() {} SymbolsWidget::~SymbolsWidget() {}
void SymbolsWidget::setup()
{
setScrollMode();
fillSymbols();
}
void SymbolsWidget::refresh()
{
setup();
}
void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {

View File

@ -1,9 +1,10 @@
#ifndef SYMBOLSWIDGET_H #ifndef SYMBOLSWIDGET_H
#define SYMBOLSWIDGET_H #define SYMBOLSWIDGET_H
#include "DockWidget.h"
#include <memory> #include <memory>
#include <QDockWidget>
class MainWindow; class MainWindow;
class QTreeWidgetItem; class QTreeWidgetItem;
@ -12,7 +13,7 @@ namespace Ui
class SymbolsWidget; class SymbolsWidget;
} }
class SymbolsWidget : public DockWidget class SymbolsWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -20,17 +21,14 @@ public:
explicit SymbolsWidget(QWidget *parent = 0); explicit SymbolsWidget(QWidget *parent = 0);
~SymbolsWidget(); ~SymbolsWidget();
void setup() override;
void refresh() override;
private slots: private slots:
void on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column); void on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void fillSymbols();
private: private:
std::unique_ptr<Ui::SymbolsWidget> ui; std::unique_ptr<Ui::SymbolsWidget> ui;
void fillSymbols();
void setScrollMode(); void setScrollMode();
}; };