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()));
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 &)));
}
@ -343,7 +343,7 @@ void MainWindow::finalizeOpen()
// FIXME: initialization order frakup. the next line is needed so that the
// comments widget displays the function names.
core->cmd("fs sections");
updateFrames();
refreshAll();
if (core->getNotes().isEmpty())
{
@ -480,61 +480,10 @@ void MainWindow::def_theme()
// TODO: emit a signal for theme
}
/*
* Refresh widget functions
*/
void MainWindow::refreshFunctions()
void MainWindow::refreshAll()
{
functionsDock->refresh();
}
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();
Core()->triggerRefreshAll();
}
void MainWindow::on_actionLock_triggered()
@ -683,7 +632,7 @@ void MainWindow::on_actionAbout_triggered()
void MainWindow::on_actionRefresh_Panels_triggered()
{
this->updateFrames();
this->refreshAll();
}
void MainWindow::toggleDockWidget(QDockWidget *dock_widget)
@ -953,33 +902,9 @@ void MainWindow::on_actionQuit_triggered()
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()
{
refreshVisibleDockWidgets();
refreshAll();
}
void MainWindow::on_actionAsmOptions_triggered()

View File

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

View File

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

View File

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

View File

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

View File

@ -39,6 +39,8 @@ GraphicsBar::GraphicsBar(MainWindow *main, QWidget *parent) :
*/
addWidget(this->codeGraphic);
//addWidget(addsCombo);
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillData()));
}
void GraphicsBar::paintEvent(QPaintEvent *event)
@ -51,7 +53,6 @@ void GraphicsBar::paintEvent(QPaintEvent *event)
void GraphicsBar::fillData()
{
// Prepare the graph scene
int w = this->codeGraphic->width();
int h = this->codeGraphic->height();
@ -66,65 +67,57 @@ void GraphicsBar::fillData()
this->codeGraphic->setToolTip("gap");
// Parse JSON data
QString jsonData = CutterCore::getInstance()->cmd("p-j");
QJsonDocument doc = QJsonDocument::fromJson(jsonData.toUtf8());
QJsonDocument doc = Core()->cmdj("p-j");
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
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)
QMap<QString, QVariant> map = i.toMap();
if (map.empty())
{
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;
int counter = 0;
for (auto i : mainMap["blocks"].toList())
else
{
QMap<QString, QVariant> map = i.toMap();
if (map.empty())
// Fill type of color
//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
// 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);
rect->setBrush(QBrush(QColor(190, 190, 190)));
}
else
{
// Fill type of color
//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);
rect->setBrush(QBrush(QColor(69, 104, 229)));
}
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:
void paintEvent(QPaintEvent *event);
private slots:
void fillData();
private:

View File

@ -8,7 +8,7 @@
#include "utils/Helpers.h"
CommentsWidget::CommentsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent),
QDockWidget(parent),
ui(new Ui::CommentsWidget),
main(main)
{
@ -26,7 +26,8 @@ CommentsWidget::CommentsWidget(MainWindow *main, QWidget *parent) :
connect(this, SIGNAL(customContextMenuRequested(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
ui->frame->hide();
@ -34,16 +35,6 @@ CommentsWidget::CommentsWidget(MainWindow *main, QWidget *parent) :
CommentsWidget::~CommentsWidget() {}
void CommentsWidget::setup()
{
refreshTree();
}
void CommentsWidget::refresh()
{
refreshTree();
}
void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
Q_UNUSED(column);

View File

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

View File

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

View File

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

View File

@ -74,6 +74,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
});
//Connect to bridge
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshView()));
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSeekChanged(RVA)));
connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshView()));
//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);
}
});
connect(Core(), &CutterCore::refreshAll, this, [this]() {
refreshDisasm(Core()->getOffset());
});
}
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) :
DockWidget(parent),
QDockWidget(parent),
ui(new Ui::EntrypointWidget),
main(main)
{
@ -24,22 +24,14 @@ EntrypointWidget::EntrypointWidget(MainWindow *main, QWidget *parent) :
//ui->importsTreeWidget->setItemDelegate(delegate);
ui->entrypointTreeWidget->hideColumn(0);
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(fillEntrypoint()));
}
EntrypointWidget::~EntrypointWidget() {}
void EntrypointWidget::setup()
{
setScrollMode();
fillEntrypoint();
}
void EntrypointWidget::refresh()
{
setup();
}
void EntrypointWidget::fillEntrypoint()
{
ui->entrypointTreeWidget->clear();

View File

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

View File

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

View File

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

View File

@ -125,7 +125,7 @@ bool FlagsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIn
FlagsWidget::FlagsWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent),
QDockWidget(parent),
ui(new Ui::FlagsWidget),
main(main)
{
@ -137,23 +137,14 @@ FlagsWidget::FlagsWidget(MainWindow *main, QWidget *parent) :
ui->flagsTreeView->setModel(flags_proxy_model);
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() {}
void FlagsWidget::setup()
{
setScrollMode();
refreshFlagspaces();
}
void FlagsWidget::refresh()
{
refreshFlagspaces();
}
void FlagsWidget::on_flagsTreeView_doubleClicked(const QModelIndex &index)
{
FlagDescription flag = index.data(FlagsModel::FlagDescriptionRole).value<FlagDescription>();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,21 +7,25 @@
#include <QTreeWidget>
SdbDock::SdbDock(MainWindow *main, QWidget *parent) :
DockWidget(parent),
SdbDock::SdbDock(QWidget *parent) :
QDockWidget(parent),
ui(new Ui::SdbDock)
{
ui->setupUi(this);
// Radare core found in:
this->main = main;
this->path = "";
reload("");
path = "";
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);
this->path = path;
/* insert root sdb keyvalue pairs */
ui->treeWidget->clear();
@ -95,18 +99,6 @@ void SdbDock::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
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()
{
if (ui->lockButton->isChecked())

View File

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

View File

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

View File

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

View File

@ -17,9 +17,11 @@ SectionsWidget::SectionsWidget(MainWindow *main, QWidget *parent) :
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
//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); }");
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshSections()));
}
void SectionsWidget::setup()
void SectionsWidget::refreshSections()
{
tree->clear();

View File

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

View File

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

View File

@ -17,8 +17,7 @@
SidebarWidget::SidebarWidget(QWidget *parent, Qt::WindowFlags flags) :
QDockWidget(parent, flags),
ui(new Ui::SidebarWidget),
core(CutterCore::getInstance())
ui(new Ui::SidebarWidget)
{
ui->setupUi(this);
this->xrefToTreeWidget_2 = ui->xrefToTreeWidget_2;
@ -27,12 +26,14 @@ SidebarWidget::SidebarWidget(QWidget *parent, Qt::WindowFlags flags) :
// Add margin to function name line edit
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();
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)
@ -54,7 +55,7 @@ void SidebarWidget::on_seekChanged(RVA addr)
void SidebarWidget::refresh(RVA addr)
{
if(addr == RVA_INVALID)
addr = core->getOffset();
addr = Core()->getOffset();
get_refs_data(addr);
setFcnName(addr);
@ -82,13 +83,13 @@ void SidebarWidget::on_offsetToolButton_clicked()
void SidebarWidget::on_xreFromTreeWidget_2_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
{
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*/)
{
XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
this->core->seek(xref.from);
Core()->seek(xref.from);
}
void SidebarWidget::on_xrefFromToolButton_2_clicked()
@ -122,10 +123,10 @@ void SidebarWidget::on_xrefToToolButton_2_clicked()
void SidebarWidget::get_refs_data(RVA addr)
{
// 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
QList<XrefDescription> xrefs = core->getXRefs(addr, true, false);
QList<XrefDescription> xrefs = Core()->getXRefs(addr, true, false);
// Data for the disasm side graph
QList<int> data;
@ -135,10 +136,10 @@ void SidebarWidget::get_refs_data(RVA addr)
data << xrefs.size();
//qDebug() << "CC: " << 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));
data << this->core->fcnBasicBlockCount(addr);
data << this->core->fcnEndBbs(addr);
data << Core()->fcnBasicBlockCount(addr);
data << Core()->fcnEndBbs(addr);
//qDebug() << "MEOW: " + this->core->fcnEndBbs(offset);
// Update disasm side bar
@ -154,9 +155,9 @@ void SidebarWidget::fill_refs(QList<XrefDescription> refs, QList<XrefDescription
XrefDescription xref = refs[i];
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
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));
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(1, tooltip);
this->xreFromTreeWidget_2->insertTopLevelItem(0, tempItem);
@ -175,9 +176,9 @@ void SidebarWidget::fill_refs(QList<XrefDescription> refs, QList<XrefDescription
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
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));
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?
//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)
{
ui->offsetTreeWidget->clear();
QString raw = this->core->getOffsetInfo(off);
QString raw = Core()->getOffsetInfo(off);
QList<QString> lines = raw.split("\n", QString::SkipEmptyParts);
foreach (QString line, lines)
{
@ -215,7 +216,7 @@ void SidebarWidget::fillOffsetInfo(QString off)
}
// Add opcode description
QStringList description = this->core->cmd("?d. @ " + off).split(": ");
QStringList description = Core()->cmd("?d. @ " + off).split(": ");
if (description.length() >= 2)
{
ui->opcodeDescText->setPlainText("# " + description[0] + ":\n" + description[1]);
@ -227,15 +228,15 @@ void SidebarWidget::setFcnName(RVA addr)
RAnalFunction *fcn;
QString addr_string;
fcn = this->core->functionAt(addr);
fcn = Core()->functionAt(addr);
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;
}
else
{
addr_string = core->cmdFunctionAt(addr);
addr_string = Core()->cmdFunctionAt(addr);
}
ui->fcnNameEdit->setText(addr_string);

View File

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

View File

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

View File

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

View File

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

View File

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