mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 03:46:11 +00:00
Added ResourcesWidget (fix #259)
This commit is contained in:
parent
293078d358
commit
3712cf1529
@ -64,6 +64,7 @@
|
|||||||
#include "widgets/EntrypointWidget.h"
|
#include "widgets/EntrypointWidget.h"
|
||||||
#include "dialogs/SaveProjectDialog.h"
|
#include "dialogs/SaveProjectDialog.h"
|
||||||
#include "widgets/ClassesWidget.h"
|
#include "widgets/ClassesWidget.h"
|
||||||
|
#include "widgets/ResourcesWidget.h"
|
||||||
|
|
||||||
// graphics
|
// graphics
|
||||||
#include <QGraphicsEllipseItem>
|
#include <QGraphicsEllipseItem>
|
||||||
@ -87,29 +88,7 @@ static void registerCustomFonts()
|
|||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
core(CutterCore::getInstance()),
|
core(CutterCore::getInstance()),
|
||||||
notepadDock(nullptr),
|
ui(new Ui::MainWindow)
|
||||||
pseudocodeDock(nullptr),
|
|
||||||
asmDock(nullptr),
|
|
||||||
calcDock(nullptr),
|
|
||||||
omnibar(nullptr),
|
|
||||||
ui(new Ui::MainWindow),
|
|
||||||
highlighter(nullptr),
|
|
||||||
hex_highlighter(nullptr),
|
|
||||||
visualNavbar(nullptr),
|
|
||||||
entrypointDock(nullptr),
|
|
||||||
functionsDock(nullptr),
|
|
||||||
importsDock(nullptr),
|
|
||||||
exportsDock(nullptr),
|
|
||||||
symbolsDock(nullptr),
|
|
||||||
relocsDock(nullptr),
|
|
||||||
commentsDock(nullptr),
|
|
||||||
stringsDock(nullptr),
|
|
||||||
flagsDock(nullptr),
|
|
||||||
dashboardDock(nullptr),
|
|
||||||
gotoEntry(nullptr),
|
|
||||||
sdbDock(nullptr),
|
|
||||||
sectionsDock(nullptr),
|
|
||||||
consoleDock(nullptr)
|
|
||||||
{
|
{
|
||||||
panelLock = false;
|
panelLock = false;
|
||||||
tabsOnTop = false;
|
tabsOnTop = false;
|
||||||
@ -180,7 +159,7 @@ void MainWindow::initUI()
|
|||||||
/*
|
/*
|
||||||
* Dock Widgets
|
* Dock Widgets
|
||||||
*/
|
*/
|
||||||
dockWidgets.reserve(14);
|
dockWidgets.reserve(20);
|
||||||
|
|
||||||
#define ADD_DOCK(cls, dockMember, action) \
|
#define ADD_DOCK(cls, dockMember, action) \
|
||||||
{ \
|
{ \
|
||||||
@ -243,6 +222,7 @@ void MainWindow::initUI()
|
|||||||
ADD_DOCK(Dashboard, dashboardDock, ui->actionDashboard);
|
ADD_DOCK(Dashboard, dashboardDock, ui->actionDashboard);
|
||||||
ADD_DOCK(SdbDock, sdbDock, ui->actionSDBBrowser);
|
ADD_DOCK(SdbDock, sdbDock, ui->actionSDBBrowser);
|
||||||
ADD_DOCK(ClassesWidget, classesDock, ui->actionClasses);
|
ADD_DOCK(ClassesWidget, classesDock, ui->actionClasses);
|
||||||
|
ADD_DOCK(ResourcesWidget, resourcesDock, ui->actionResources);
|
||||||
|
|
||||||
#undef ADD_DOCK
|
#undef ADD_DOCK
|
||||||
|
|
||||||
@ -548,6 +528,7 @@ void MainWindow::restoreDocks()
|
|||||||
tabifyDockWidget(dashboardDock, symbolsDock);
|
tabifyDockWidget(dashboardDock, symbolsDock);
|
||||||
tabifyDockWidget(dashboardDock, notepadDock);
|
tabifyDockWidget(dashboardDock, notepadDock);
|
||||||
tabifyDockWidget(dashboardDock, classesDock);
|
tabifyDockWidget(dashboardDock, classesDock);
|
||||||
|
tabifyDockWidget(dashboardDock, resourcesDock);
|
||||||
|
|
||||||
updateDockActionsChecked();
|
updateDockActionsChecked();
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ class ConsoleWidget;
|
|||||||
class EntrypointWidget;
|
class EntrypointWidget;
|
||||||
class DisassemblerGraphView;
|
class DisassemblerGraphView;
|
||||||
class ClassesWidget;
|
class ClassesWidget;
|
||||||
|
class ResourcesWidget;
|
||||||
|
|
||||||
class QDockWidget;
|
class QDockWidget;
|
||||||
|
|
||||||
@ -146,19 +147,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CutterCore *core;
|
CutterCore *core;
|
||||||
Notepad *notepadDock;
|
|
||||||
DisassemblyWidget *disassemblyDock;
|
|
||||||
SidebarWidget *sidebarDock;
|
|
||||||
HexdumpWidget *hexdumpDock;
|
|
||||||
PseudocodeWidget *pseudocodeDock;
|
|
||||||
QDockWidget *graphDock;
|
|
||||||
DisassemblerGraphView *graphView;
|
|
||||||
QDockWidget *asmDock;
|
|
||||||
QDockWidget *calcDock;
|
|
||||||
Omnibar *omnibar;
|
|
||||||
//SideBar *sideBar;
|
|
||||||
Configuration *configuration;
|
|
||||||
|
|
||||||
bool panelLock;
|
bool panelLock;
|
||||||
bool tabsOnTop;
|
bool tabsOnTop;
|
||||||
ut64 hexdumpTopOffset;
|
ut64 hexdumpTopOffset;
|
||||||
@ -168,25 +156,36 @@ private:
|
|||||||
Highlighter *highlighter;
|
Highlighter *highlighter;
|
||||||
AsciiHighlighter *hex_highlighter;
|
AsciiHighlighter *hex_highlighter;
|
||||||
VisualNavbar *visualNavbar;
|
VisualNavbar *visualNavbar;
|
||||||
EntrypointWidget *entrypointDock;
|
Omnibar *omnibar;
|
||||||
FunctionsWidget *functionsDock;
|
Configuration *configuration;
|
||||||
ImportsWidget *importsDock;
|
|
||||||
ExportsWidget *exportsDock;
|
|
||||||
SymbolsWidget *symbolsDock;
|
|
||||||
RelocsWidget *relocsDock;
|
|
||||||
CommentsWidget *commentsDock;
|
|
||||||
StringsWidget *stringsDock;
|
|
||||||
FlagsWidget *flagsDock;
|
|
||||||
Dashboard *dashboardDock;
|
|
||||||
QLineEdit *gotoEntry;
|
|
||||||
SdbDock *sdbDock;
|
|
||||||
//QAction *sidebar_action;
|
|
||||||
SectionsDock *sectionsDock;
|
|
||||||
ConsoleWidget *consoleDock;
|
|
||||||
ClassesWidget *classesDock;
|
|
||||||
|
|
||||||
QList<QDockWidget *> dockWidgets;
|
QList<QDockWidget *> dockWidgets;
|
||||||
QMap<QAction *, QDockWidget *> dockWidgetActions;
|
QMap<QAction *, QDockWidget *> dockWidgetActions;
|
||||||
|
Notepad *notepadDock = nullptr;
|
||||||
|
DisassemblyWidget *disassemblyDock = nullptr;
|
||||||
|
SidebarWidget *sidebarDock = nullptr;
|
||||||
|
HexdumpWidget *hexdumpDock = nullptr;
|
||||||
|
PseudocodeWidget *pseudocodeDock = nullptr;
|
||||||
|
QDockWidget *graphDock = nullptr;
|
||||||
|
EntrypointWidget *entrypointDock = nullptr;
|
||||||
|
FunctionsWidget *functionsDock = nullptr;
|
||||||
|
ImportsWidget *importsDock = nullptr;
|
||||||
|
ExportsWidget *exportsDock = nullptr;
|
||||||
|
SymbolsWidget *symbolsDock = nullptr;
|
||||||
|
RelocsWidget *relocsDock = nullptr;
|
||||||
|
CommentsWidget *commentsDock = nullptr;
|
||||||
|
StringsWidget *stringsDock = nullptr;
|
||||||
|
FlagsWidget *flagsDock = nullptr;
|
||||||
|
Dashboard *dashboardDock = nullptr;
|
||||||
|
QLineEdit *gotoEntry = nullptr;
|
||||||
|
SdbDock *sdbDock = nullptr;
|
||||||
|
SectionsDock *sectionsDock = nullptr;
|
||||||
|
ConsoleWidget *consoleDock = nullptr;
|
||||||
|
ClassesWidget *classesDock = nullptr;
|
||||||
|
ResourcesWidget *resourcesDock = nullptr;
|
||||||
|
DisassemblerGraphView *graphView = nullptr;
|
||||||
|
QDockWidget *asmDock = nullptr;
|
||||||
|
QDockWidget *calcDock = nullptr;
|
||||||
|
|
||||||
void toggleDockWidget(QDockWidget *dock_widget, bool show);
|
void toggleDockWidget(QDockWidget *dock_widget, bool show);
|
||||||
|
|
||||||
|
@ -249,6 +249,7 @@ border-top: 0px;
|
|||||||
<addaction name="actionExports"/>
|
<addaction name="actionExports"/>
|
||||||
<addaction name="actionSymbols"/>
|
<addaction name="actionSymbols"/>
|
||||||
<addaction name="actionSDBBrowser"/>
|
<addaction name="actionSDBBrowser"/>
|
||||||
|
<addaction name="actionResources"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionRelocs"/>
|
<addaction name="actionRelocs"/>
|
||||||
<addaction name="actionStrings"/>
|
<addaction name="actionStrings"/>
|
||||||
@ -1041,6 +1042,14 @@ QToolButton:pressed {
|
|||||||
<string>Analyze</string>
|
<string>Analyze</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionResources">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Resources</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -1204,6 +1204,29 @@ QList<ClassDescription> CutterCore::getAllClasses()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<ResourcesDescription> CutterCore::getAllResources()
|
||||||
|
{
|
||||||
|
CORE_LOCK();
|
||||||
|
QList<ResourcesDescription> ret;
|
||||||
|
|
||||||
|
QJsonArray resourcesArray = cmdj("iRj").array();
|
||||||
|
for (QJsonValueRef value : resourcesArray)
|
||||||
|
{
|
||||||
|
QJsonObject resourceObject = value.toObject();
|
||||||
|
|
||||||
|
ResourcesDescription res;
|
||||||
|
res.name = resourceObject["name"].toString();
|
||||||
|
res.vaddr = resourceObject["vaddr"].toVariant().toULongLong();
|
||||||
|
res.index = resourceObject["index"].toVariant().toULongLong();
|
||||||
|
res.type = resourceObject["type"].toString();
|
||||||
|
res.size = resourceObject["size"].toVariant().toULongLong();
|
||||||
|
res.lang = resourceObject["lang"].toString();
|
||||||
|
|
||||||
|
ret << res;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QList<XrefDescription> CutterCore::getXRefs(RVA addr, bool to, bool whole_function, const QString &filterType)
|
QList<XrefDescription> CutterCore::getXRefs(RVA addr, bool to, bool whole_function, const QString &filterType)
|
||||||
{
|
{
|
||||||
QList<XrefDescription> ret = QList<XrefDescription>();
|
QList<XrefDescription> ret = QList<XrefDescription>();
|
||||||
|
12
src/cutter.h
12
src/cutter.h
@ -195,6 +195,16 @@ struct ClassDescription
|
|||||||
QList<ClassFieldDescription> fields;
|
QList<ClassFieldDescription> fields;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ResourcesDescription
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
RVA vaddr;
|
||||||
|
ut64 index;
|
||||||
|
QString type;
|
||||||
|
ut64 size;
|
||||||
|
QString lang;
|
||||||
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(FunctionDescription)
|
Q_DECLARE_METATYPE(FunctionDescription)
|
||||||
Q_DECLARE_METATYPE(ImportDescription)
|
Q_DECLARE_METATYPE(ImportDescription)
|
||||||
Q_DECLARE_METATYPE(ExportDescription)
|
Q_DECLARE_METATYPE(ExportDescription)
|
||||||
@ -210,6 +220,7 @@ Q_DECLARE_METATYPE(RBinPluginDescription)
|
|||||||
Q_DECLARE_METATYPE(ClassMethodDescription)
|
Q_DECLARE_METATYPE(ClassMethodDescription)
|
||||||
Q_DECLARE_METATYPE(ClassFieldDescription)
|
Q_DECLARE_METATYPE(ClassFieldDescription)
|
||||||
Q_DECLARE_METATYPE(ClassDescription)
|
Q_DECLARE_METATYPE(ClassDescription)
|
||||||
|
Q_DECLARE_METATYPE(ResourcesDescription)
|
||||||
Q_DECLARE_METATYPE(const ClassDescription *)
|
Q_DECLARE_METATYPE(const ClassDescription *)
|
||||||
Q_DECLARE_METATYPE(const ClassMethodDescription *)
|
Q_DECLARE_METATYPE(const ClassMethodDescription *)
|
||||||
Q_DECLARE_METATYPE(const ClassFieldDescription *)
|
Q_DECLARE_METATYPE(const ClassFieldDescription *)
|
||||||
@ -341,6 +352,7 @@ public:
|
|||||||
QList<SectionDescription> getAllSections();
|
QList<SectionDescription> getAllSections();
|
||||||
QList<EntrypointDescription> getAllEntrypoint();
|
QList<EntrypointDescription> getAllEntrypoint();
|
||||||
QList<ClassDescription> getAllClasses();
|
QList<ClassDescription> getAllClasses();
|
||||||
|
QList<ResourcesDescription> getAllResources();
|
||||||
|
|
||||||
QList<XrefDescription> getXRefs(RVA addr, bool to, bool whole_function, const QString &filterType = QString::null);
|
QList<XrefDescription> getXRefs(RVA addr, bool to, bool whole_function, const QString &filterType = QString::null);
|
||||||
|
|
||||||
|
@ -86,7 +86,8 @@ SOURCES += \
|
|||||||
dialogs/preferences/GeneralOptionsWidget.cpp \
|
dialogs/preferences/GeneralOptionsWidget.cpp \
|
||||||
dialogs/preferences/GraphOptionsWidget.cpp \
|
dialogs/preferences/GraphOptionsWidget.cpp \
|
||||||
widgets/QuickFilterView.cpp \
|
widgets/QuickFilterView.cpp \
|
||||||
widgets/ClassesWidget.cpp
|
widgets/ClassesWidget.cpp \
|
||||||
|
widgets/ResourcesWidget.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
cutter.h \
|
cutter.h \
|
||||||
@ -143,7 +144,8 @@ HEADERS += \
|
|||||||
dialogs/preferences/GeneralOptionsWidget.h \
|
dialogs/preferences/GeneralOptionsWidget.h \
|
||||||
dialogs/preferences/GraphOptionsWidget.h \
|
dialogs/preferences/GraphOptionsWidget.h \
|
||||||
widgets/QuickFilterView.h \
|
widgets/QuickFilterView.h \
|
||||||
widgets/ClassesWidget.h
|
widgets/ClassesWidget.h \
|
||||||
|
widgets/ResourcesWidget.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
dialogs/AboutDialog.ui \
|
dialogs/AboutDialog.ui \
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "ClassesWidget.h"
|
#include "ClassesWidget.h"
|
||||||
#include "ui_ClassesWidget.h"
|
#include "ui_ClassesWidget.h"
|
||||||
#include "MainWindow.h"
|
|
||||||
#include "utils/Helpers.h"
|
#include "utils/Helpers.h"
|
||||||
|
|
||||||
ClassesModel::ClassesModel(QList<ClassDescription> *classes, QObject *parent)
|
ClassesModel::ClassesModel(QList<ClassDescription> *classes, QObject *parent)
|
||||||
@ -243,16 +242,12 @@ bool ClassesSortFilterProxyModel::lessThan(const QModelIndex &left, const QModel
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
ClassesWidget::ClassesWidget(MainWindow *main, QWidget *parent) :
|
ClassesWidget::ClassesWidget(QWidget *parent) :
|
||||||
QDockWidget(parent),
|
QDockWidget(parent),
|
||||||
ui(new Ui::ClassesWidget),
|
ui(new Ui::ClassesWidget)
|
||||||
main(main)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// Radare core found in:
|
|
||||||
this->main = main;
|
|
||||||
|
|
||||||
model = new ClassesModel(&classes, this);
|
model = new ClassesModel(&classes, this);
|
||||||
proxy_model = new ClassesSortFilterProxyModel(model, this);
|
proxy_model = new ClassesSortFilterProxyModel(model, this);
|
||||||
ui->classesTreeView->setModel(proxy_model);
|
ui->classesTreeView->setModel(proxy_model);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef CLASSWSWIDGET_H
|
#ifndef CLASSESWIDGET_H
|
||||||
#define CLASSWSWIDGET_H
|
#define CLASSESWIDGET_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -9,16 +9,12 @@
|
|||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
|
|
||||||
class MainWindow;
|
|
||||||
class QTreeWidget;
|
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class ClassesWidget;
|
class ClassesWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class QTreeWidget;
|
||||||
class MainWindow;
|
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +48,7 @@ public:
|
|||||||
void endReload();
|
void endReload();
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ClassesModel::RowType);
|
Q_DECLARE_METATYPE(ClassesModel::RowType)
|
||||||
|
|
||||||
|
|
||||||
class ClassesSortFilterProxyModel : public QSortFilterProxyModel
|
class ClassesSortFilterProxyModel : public QSortFilterProxyModel
|
||||||
@ -74,7 +70,7 @@ class ClassesWidget : public QDockWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ClassesWidget(MainWindow *main, QWidget *parent = 0);
|
explicit ClassesWidget(QWidget *parent = nullptr);
|
||||||
~ClassesWidget();
|
~ClassesWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -84,7 +80,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::ClassesWidget> ui;
|
std::unique_ptr<Ui::ClassesWidget> ui;
|
||||||
MainWindow *main;
|
|
||||||
|
|
||||||
ClassesModel *model;
|
ClassesModel *model;
|
||||||
ClassesSortFilterProxyModel *proxy_model;
|
ClassesSortFilterProxyModel *proxy_model;
|
||||||
@ -92,4 +87,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // CLASSWSWIDGET_H
|
#endif // CLASSESWIDGET_H
|
||||||
|
114
src/widgets/ResourcesWidget.cpp
Normal file
114
src/widgets/ResourcesWidget.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
#include "ResourcesWidget.h"
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
ResourcesModel::ResourcesModel(QList<ResourcesDescription> *resources, QObject *parent)
|
||||||
|
: QAbstractListModel(parent),
|
||||||
|
resources(resources)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int ResourcesModel::rowCount(const QModelIndex &) const
|
||||||
|
{
|
||||||
|
return resources->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ResourcesModel::columnCount(const QModelIndex &) const
|
||||||
|
{
|
||||||
|
return Columns::COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ResourcesModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
const ResourcesDescription *res = &resources->at(index.row());
|
||||||
|
switch (role)
|
||||||
|
{
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
switch (index.column())
|
||||||
|
{
|
||||||
|
case NAME:
|
||||||
|
return res->name;
|
||||||
|
case VADDR:
|
||||||
|
return RAddressString(res->vaddr);
|
||||||
|
case INDEX:
|
||||||
|
return res->index;
|
||||||
|
case TYPE:
|
||||||
|
return res->type;
|
||||||
|
case SIZE:
|
||||||
|
return res->size;
|
||||||
|
case LANG:
|
||||||
|
return res->lang;
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ResourcesModel::headerData(int section, Qt::Orientation, int role) const
|
||||||
|
{
|
||||||
|
switch (role)
|
||||||
|
{
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
switch (section)
|
||||||
|
{
|
||||||
|
case NAME:
|
||||||
|
return tr("Name");
|
||||||
|
case VADDR:
|
||||||
|
return tr("Vaddr");
|
||||||
|
case INDEX:
|
||||||
|
return tr("Index");
|
||||||
|
case TYPE:
|
||||||
|
return tr("Type");
|
||||||
|
case SIZE:
|
||||||
|
return tr("Size");
|
||||||
|
case LANG:
|
||||||
|
return tr("Lang");
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourcesModel::beginReload()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourcesModel::endReload()
|
||||||
|
{
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourcesWidget::ResourcesWidget(QWidget *parent)
|
||||||
|
: QDockWidget(parent)
|
||||||
|
{
|
||||||
|
model = new ResourcesModel(&resources, this);
|
||||||
|
|
||||||
|
// Configure widget
|
||||||
|
this->setWindowTitle(tr("Resources"));
|
||||||
|
|
||||||
|
// Add resources tree view
|
||||||
|
view = new QTreeView(this);
|
||||||
|
view->setModel(model);
|
||||||
|
view->show();
|
||||||
|
this->setWidget(view);
|
||||||
|
|
||||||
|
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshResources()));
|
||||||
|
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(onDoubleClicked(const QModelIndex &)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourcesWidget::refreshResources()
|
||||||
|
{
|
||||||
|
model->beginReload();
|
||||||
|
resources = Core()->getAllResources();
|
||||||
|
model->endReload();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourcesWidget::onDoubleClicked(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
ResourcesDescription res = index.data().value<ResourcesDescription>();
|
||||||
|
CutterCore::getInstance()->seek(res.vaddr);
|
||||||
|
}
|
48
src/widgets/ResourcesWidget.h
Normal file
48
src/widgets/ResourcesWidget.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#ifndef RESOURCESWIDGET_H
|
||||||
|
#define RESOURCESWIDGET_H
|
||||||
|
|
||||||
|
#include "cutter.h"
|
||||||
|
|
||||||
|
#include <QDockWidget>
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
|
class ResourcesModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<ResourcesDescription> *resources;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Columns { INDEX = 0, NAME, VADDR, TYPE, SIZE, LANG, COUNT };
|
||||||
|
explicit ResourcesModel(QList<ResourcesDescription> *resources, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
|
||||||
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
|
void beginReload();
|
||||||
|
void endReload();
|
||||||
|
};
|
||||||
|
|
||||||
|
class ResourcesWidget : public QDockWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
ResourcesModel *model;
|
||||||
|
QTreeView *view;
|
||||||
|
QList<ResourcesDescription> resources;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ResourcesWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void refreshResources();
|
||||||
|
void onDoubleClicked(const QModelIndex &);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RESOURCESWIDGET_H
|
@ -79,10 +79,6 @@ void StringsModel::endReload()
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StringsSortFilterProxyModel::StringsSortFilterProxyModel(StringsModel *source_model, QObject *parent)
|
StringsSortFilterProxyModel::StringsSortFilterProxyModel(StringsModel *source_model, QObject *parent)
|
||||||
: QSortFilterProxyModel(parent)
|
: QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
|
@ -17,8 +17,6 @@ namespace Ui
|
|||||||
class StringsWidget;
|
class StringsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class StringsModel: public QAbstractListModel
|
class StringsModel: public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Loading…
Reference in New Issue
Block a user