WIP: More GUI work, use shared_ptr to store Function references.
This commit is contained in:
@@ -26,13 +26,15 @@ DccMainWindow::DccMainWindow(QWidget *parent) :
|
||||
g_EXE2C->BaseInit();
|
||||
g_EXE2C->Init(this);
|
||||
|
||||
m_last_display = g_EXE2C->GetFirstFuncHandle();
|
||||
m_last_display = nullptr;
|
||||
m_command_queue = new CommandQueueView(this);
|
||||
m_functionlist_widget = new FunctionListDockWidget(this);
|
||||
m_functionlist_widget->setWindowTitle(QApplication::tr("Function list"));
|
||||
connect(m_functionlist_widget,SIGNAL(displayRequested()), SLOT(displayCurrentFunction()));
|
||||
// we are beeing signalled when display is requested
|
||||
connect(this,SIGNAL(functionListChanged()), m_functionlist_widget->model(),SLOT(updateFunctionList()));
|
||||
connect(Project::get(),SIGNAL(newFunctionCreated(PtrFunction)),SLOT(onNewFunction(PtrFunction)));
|
||||
|
||||
this->addDockWidget(Qt::RightDockWidgetArea,m_functionlist_widget);
|
||||
this->addDockWidget(Qt::LeftDockWidgetArea,m_command_queue);
|
||||
m_asm_view = new FunctionViewWidget(this);
|
||||
@@ -62,6 +64,9 @@ void DccMainWindow::changeEvent(QEvent *e)
|
||||
break;
|
||||
}
|
||||
}
|
||||
void DccMainWindow::onNewFunction(PtrFunction f) {
|
||||
emit functionListChanged();
|
||||
}
|
||||
void DccMainWindow::onOptim()
|
||||
{
|
||||
Project::get()->processCommands();
|
||||
|
||||
@@ -34,7 +34,7 @@ protected:
|
||||
void changeEvent(QEvent *e);
|
||||
private slots:
|
||||
void on_actionExit_triggered();
|
||||
|
||||
void onNewFunction(PtrFunction f);
|
||||
private:
|
||||
|
||||
FunctionViewWidget *m_asm_view;
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
CommandQueueView *m_command_queue;
|
||||
FunctionListDockWidget *m_functionlist_widget;
|
||||
Ui::DccMainWindow *ui;
|
||||
ilFunction m_last_display;
|
||||
PtrFunction m_last_display;
|
||||
};
|
||||
|
||||
#endif // EXE2C_MAINWINDOW_H
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "FunctionListDockWidget.h"
|
||||
#include "ui_FunctionListDockWidget.h"
|
||||
|
||||
#include "dcc.h"
|
||||
#include "dcc_interface.h"
|
||||
#include "Procedure.h"
|
||||
#include "project.h"
|
||||
|
||||
#include <QtCore>
|
||||
//#include "exe2c.h"
|
||||
@@ -21,9 +23,10 @@ FunctionListDockWidget::~FunctionListDockWidget()
|
||||
}
|
||||
void FunctionListDockWidget::functionSelected(const QModelIndex &idx)
|
||||
{
|
||||
QVariant v=m_list_model.data(idx,Qt::DisplayRole);
|
||||
qDebug()<<"neb changed function to "<<v;
|
||||
g_EXE2C->SetCurFunc_by_Name(v.toString().toStdString().c_str());
|
||||
|
||||
QVariant v=m_list_model.data(m_list_model.index(idx.row(),0),Qt::DisplayRole);
|
||||
qDebug()<<"changed function to "<<v;
|
||||
g_EXE2C->SetCurFunc_by_Name(v.toString());
|
||||
}
|
||||
// signalled by m_func_list_view accepted signal
|
||||
void FunctionListDockWidget::displayRequest(const QModelIndex &)
|
||||
@@ -37,20 +40,17 @@ void FunctionListModel::updateFunctionList()
|
||||
}
|
||||
void FunctionListModel::rebuildFunctionList()
|
||||
{
|
||||
ilFunction iter = g_EXE2C->GetFirstFuncHandle();
|
||||
Project &project(*Project::get());
|
||||
const lFunction &funcs(project.functions());
|
||||
clear();
|
||||
beginInsertRows(QModelIndex(),0,g_EXE2C->getFuncCount());
|
||||
|
||||
while (g_EXE2C->isValidFuncHandle(iter))
|
||||
beginInsertRows(QModelIndex(),0,funcs.size());
|
||||
for(const PtrFunction &info : funcs)
|
||||
{
|
||||
const Function &info(*iter);
|
||||
//g_EXE2C->GetFuncInfo(iter, &info);
|
||||
iter = g_EXE2C->GetNextFuncHandle(iter);
|
||||
|
||||
if (info.name.isEmpty())
|
||||
if (info->name.isEmpty())
|
||||
continue;
|
||||
// fixme
|
||||
add_function(info.name,info.nStep,info.procEntry,info.procEntry+10,info.cbParam);
|
||||
add_function(info->name,info->nStep,info->procEntry,info->procEntry+10,info->cbParam);
|
||||
}
|
||||
endInsertRows();
|
||||
}
|
||||
@@ -63,19 +63,29 @@ QVariant FunctionListModel::data(const QModelIndex &idx,int role) const
|
||||
{
|
||||
switch(column)
|
||||
{
|
||||
case 0: // name
|
||||
{
|
||||
return QVariant(inf.m_name);
|
||||
}
|
||||
case 1: // step
|
||||
return QVariant(inf.m_decoding_step);
|
||||
case 2: // start offset
|
||||
{
|
||||
QString in_base_16=QString("%1").arg(inf.m_start_off,0,16);
|
||||
return QVariant(in_base_16);
|
||||
}
|
||||
case 0: // name
|
||||
{
|
||||
return QVariant(inf.m_name);
|
||||
}
|
||||
case 1: { // step
|
||||
switch(inf.m_decoding_step) {
|
||||
case eNotDecoded:
|
||||
return "Undecoded";
|
||||
case eDisassemblyInProgress:
|
||||
return "Disassembly in progress";
|
||||
case eDissassembled:
|
||||
return "Disassembled";
|
||||
default:
|
||||
return QVariant();
|
||||
return "UNKNOWN STATE";
|
||||
}
|
||||
}
|
||||
case 2: // start offset
|
||||
{
|
||||
QString in_base_16=QString("%1").arg(inf.m_start_off,0,16);
|
||||
return QVariant(in_base_16);
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -87,14 +97,14 @@ QVariant FunctionListModel::headerData(int section, Qt::Orientation orientation,
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case 0: // name
|
||||
return QObject::tr("Function name");
|
||||
case 1: // step
|
||||
return QObject::tr("Decoding step");
|
||||
case 2: // start offset
|
||||
return QObject::tr("Start offset");
|
||||
default:
|
||||
return QVariant();
|
||||
case 0: // name
|
||||
return QObject::tr("Function name");
|
||||
case 1: // step
|
||||
return QObject::tr("Decoding step");
|
||||
case 2: // start offset
|
||||
return QObject::tr("Start offset");
|
||||
default:
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QAbstractTableModel>
|
||||
#include <QDockWidget>
|
||||
//#include "exe2c.h"
|
||||
|
||||
enum DecompilationStep : uint32_t;
|
||||
class FunctionListModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -12,7 +12,7 @@ class FunctionListModel : public QAbstractTableModel
|
||||
struct function_info
|
||||
{
|
||||
QString m_name;
|
||||
int m_decoding_step;
|
||||
DecompilationStep m_decoding_step;
|
||||
int m_start_off, m_end_off, m_stack_purge;
|
||||
};
|
||||
std::vector<function_info> m_list;
|
||||
@@ -31,7 +31,7 @@ public slots:
|
||||
void updateFunctionList();
|
||||
|
||||
protected:
|
||||
void add_function(const QString &name,int step,int start_off,int end_off,int stack_purge)
|
||||
void add_function(const QString &name,DecompilationStep step,int start_off,int end_off,int stack_purge)
|
||||
{
|
||||
|
||||
function_info info;
|
||||
|
||||
@@ -22,9 +22,9 @@ void FunctionViewWidget::prtt(const char *s)
|
||||
collected_text+=s;
|
||||
//collected_text+="<br>";
|
||||
}
|
||||
void FunctionViewWidget::prtt(const std::string &s)
|
||||
void FunctionViewWidget::prtt(const QString &s)
|
||||
{
|
||||
collected_text+=s.c_str();
|
||||
collected_text+=s;
|
||||
//collected_text+="<br>";
|
||||
}
|
||||
void FunctionViewWidget::TAGbegin(TAG_TYPE tag_type, void *p)
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
explicit FunctionViewWidget(QWidget *parent = 0);
|
||||
~FunctionViewWidget();
|
||||
void prtt(const char * s);
|
||||
void prtt(const std::string &s);
|
||||
void prtt(const QString &s);
|
||||
void TAGbegin(enum TAG_TYPE tag_type, void * p);
|
||||
void TAGend(enum TAG_TYPE tag_type);
|
||||
private:
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <qcolor.h>
|
||||
#include <QtGui/QColor>
|
||||
enum TAG_TYPE
|
||||
{
|
||||
XT_invalid = 0,
|
||||
XT_blank,
|
||||
XT_Symbol,
|
||||
XT_Function,
|
||||
XT_Keyword, //Keywords, such as struct, union, for, while
|
||||
XT_Class, //For comound types (struct/class/union)
|
||||
XT_K1, //Braces {} []
|
||||
XT_Comment, //Comments
|
||||
XT_Keyword, //Keywords, such as struct, union, for, while
|
||||
XT_Class, //For comound types (struct/class/union)
|
||||
XT_K1, //Braces {} []
|
||||
XT_Comment, //Comments
|
||||
XT_DataType, //
|
||||
XT_Number, //
|
||||
XT_Number, //
|
||||
XT_AsmStack, //stack values
|
||||
XT_AsmOffset, //seg:offset
|
||||
XT_AsmOffset, //seg:offset
|
||||
XT_AsmLabel, //label name
|
||||
XT_FuncName,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,28 @@
|
||||
#pragma once
|
||||
class IStructuredTextTarget {
|
||||
#include "src/ui/RenderTags.h"
|
||||
|
||||
class IStructuredTextTarget {
|
||||
public:
|
||||
virtual void TAGbegin(TAG_TYPE t,void *data)=0;
|
||||
virtual void TAGend(TAG_TYPE t)=0;
|
||||
virtual void prtt(const QString &v)=0;
|
||||
|
||||
virtual void addEOL() // some targets might want to disable newlines
|
||||
{
|
||||
prtt("\n");
|
||||
}
|
||||
void addSpace(int n=1) {
|
||||
while(n--)
|
||||
prtt(" ");
|
||||
}
|
||||
void addTaggedString(TAG_TYPE t, QString v) {
|
||||
this->TAGbegin(t,nullptr);
|
||||
this->prtt(v);
|
||||
this->TAGend(t);
|
||||
}
|
||||
void addTaggedString(TAG_TYPE t, QString str, void *value) {
|
||||
this->TAGbegin(t,value);
|
||||
this->prtt(str);
|
||||
this->TAGend(t);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user