GUI work.
This commit is contained in:
39
src/ui/CommandQueueView.cpp
Normal file
39
src/ui/CommandQueueView.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "CommandQueueView.h"
|
||||
|
||||
#include "project.h"
|
||||
|
||||
#include "ui_CommandQueueView.h"
|
||||
|
||||
CommandQueueView::CommandQueueView(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::CommandQueueView)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(Project::get(),SIGNAL(commandListChanged()),SLOT(onCommandListChanged()));
|
||||
}
|
||||
|
||||
CommandQueueView::~CommandQueueView()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CommandQueueView::changeEvent(QEvent *e)
|
||||
{
|
||||
QDockWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CommandQueueView::onCommandListChanged() {
|
||||
Project &project(*Project::get());
|
||||
ui->lstQueuedCommands->clear();
|
||||
const CommandStream& cs(project.m_project_command_stream);
|
||||
for(const Command * cmd : cs.m_commands) {
|
||||
ui->lstQueuedCommands->addItem(cmd->name());
|
||||
}
|
||||
}
|
||||
28
src/ui/CommandQueueView.h
Normal file
28
src/ui/CommandQueueView.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef COMMANDQUEUEVIEW_H
|
||||
#define COMMANDQUEUEVIEW_H
|
||||
|
||||
#include <QtWidgets/QDockWidget>
|
||||
|
||||
namespace Ui {
|
||||
class CommandQueueView;
|
||||
}
|
||||
|
||||
class CommandQueueView : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CommandQueueView(QWidget *parent = 0);
|
||||
~CommandQueueView();
|
||||
|
||||
public slots:
|
||||
void onCommandListChanged();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
Ui::CommandQueueView *ui;
|
||||
};
|
||||
|
||||
#endif // COMMANDQUEUEVIEW_H
|
||||
33
src/ui/CommandQueueView.ui
Normal file
33
src/ui/CommandQueueView.ui
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CommandQueueView</class>
|
||||
<widget class="QDockWidget" name="CommandQueueView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>222</width>
|
||||
<height>446</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Doc&kWidget</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="lstQueuedCommands"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Step</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
115
src/ui/DccMainWindow.cpp
Normal file
115
src/ui/DccMainWindow.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
#include "DccMainWindow.h"
|
||||
#include "ui_DccMainWindow.h"
|
||||
//#include "ui_exe2c_gui.h"
|
||||
//#include "exe2c_interface.h"
|
||||
//#include "exe2c.h"
|
||||
#include "FunctionViewWidget.h"
|
||||
#include "FunctionListDockWidget.h"
|
||||
#include "CommandQueueView.h"
|
||||
#include "dcc_interface.h"
|
||||
#include "project.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QLabel>
|
||||
#include <QFileDialog>
|
||||
IDcc* g_EXE2C = NULL;
|
||||
extern bool exe2c_Init();
|
||||
|
||||
DccMainWindow::DccMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::DccMainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->statusbar->addPermanentWidget(new QLabel("Test"));
|
||||
|
||||
g_EXE2C = IDcc::get();
|
||||
g_EXE2C->BaseInit();
|
||||
g_EXE2C->Init(this);
|
||||
|
||||
m_last_display = g_EXE2C->GetFirstFuncHandle();
|
||||
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()));
|
||||
this->addDockWidget(Qt::RightDockWidgetArea,m_functionlist_widget);
|
||||
this->addDockWidget(Qt::LeftDockWidgetArea,m_command_queue);
|
||||
m_asm_view = new FunctionViewWidget(this);
|
||||
m_asm_view->setWindowTitle(tr("Assembly listing"));
|
||||
ui->mdiArea->addSubWindow(m_asm_view);
|
||||
//m_internal_view = new FunctionViewWidget;
|
||||
//m_internal_view->setWindowTitle(QApplication::tr("Internal listing"));
|
||||
//ui->mdiArea->addSubWindow(m_internal_view);
|
||||
m_c_view = new FunctionViewWidget;
|
||||
m_c_view->setWindowTitle(tr("Decompiled"));
|
||||
ui->mdiArea->addSubWindow(m_c_view);
|
||||
}
|
||||
|
||||
DccMainWindow::~DccMainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DccMainWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
QMainWindow::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void DccMainWindow::onOptim()
|
||||
{
|
||||
Project::get()->processCommands();
|
||||
g_EXE2C->analysis_Once();
|
||||
emit functionListChanged();
|
||||
if(m_last_display==g_EXE2C->GetCurFuncHandle())
|
||||
{
|
||||
displayCurrentFunction();
|
||||
}
|
||||
}
|
||||
void DccMainWindow::onOptim10()
|
||||
{
|
||||
for(int i=0; i<10; i++)
|
||||
g_EXE2C->analysis_Once();
|
||||
emit functionListChanged();
|
||||
if(m_last_display==g_EXE2C->GetCurFuncHandle())
|
||||
{
|
||||
displayCurrentFunction();
|
||||
}
|
||||
}
|
||||
void DccMainWindow::onOpenFile_Action()
|
||||
{
|
||||
QFileDialog dlg;
|
||||
QString name=dlg.getOpenFileName(0,
|
||||
tr("Select DOS executable"),
|
||||
".",
|
||||
tr("Executable files (*.exe *.EXE *.com *.COM)"));
|
||||
if(!g_EXE2C->load(name)) {
|
||||
QMessageBox::critical(this,tr("Error"),QString(tr("Cannot open file %1")).arg(name));
|
||||
}
|
||||
//bool m_bSucc = m_xTextBuffer.LoadFromFile(lpszPathName);
|
||||
emit functionListChanged();
|
||||
}
|
||||
|
||||
void DccMainWindow::displayCurrentFunction()
|
||||
{
|
||||
if(m_last_display!=g_EXE2C->GetCurFuncHandle())
|
||||
m_last_display=g_EXE2C->GetCurFuncHandle();
|
||||
g_EXE2C->prtout_asm(m_asm_view);
|
||||
//g_EXE2C->prtout_itn(m_internal_view);
|
||||
g_EXE2C->prtout_cpp(m_c_view);
|
||||
}
|
||||
void DccMainWindow::prt_log(const char *v)
|
||||
{
|
||||
qDebug()<<v;
|
||||
}
|
||||
|
||||
void DccMainWindow::on_actionExit_triggered()
|
||||
{
|
||||
qApp->exit(0);
|
||||
}
|
||||
49
src/ui/DccMainWindow.h
Normal file
49
src/ui/DccMainWindow.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef EXE2C_MAINWINDOW_H
|
||||
#define EXE2C_MAINWINDOW_H
|
||||
|
||||
#include "Procedure.h"
|
||||
#include "DccFrontend.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QAbstractTableModel>
|
||||
#include <QVariant>
|
||||
#include <vector>
|
||||
|
||||
class FunctionViewWidget;
|
||||
class FunctionListDockWidget;
|
||||
class CommandQueueView;
|
||||
|
||||
namespace Ui {
|
||||
class DccMainWindow;
|
||||
}
|
||||
|
||||
class DccMainWindow : public QMainWindow/*,public I_E2COUT*/ {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DccMainWindow(QWidget *parent = 0);
|
||||
~DccMainWindow();
|
||||
void prt_log(const char * str);
|
||||
public slots:
|
||||
void onOptim();
|
||||
void onOptim10();
|
||||
void onOpenFile_Action();
|
||||
void displayCurrentFunction();
|
||||
signals:
|
||||
void functionListChanged();
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
private slots:
|
||||
void on_actionExit_triggered();
|
||||
|
||||
private:
|
||||
|
||||
FunctionViewWidget *m_asm_view;
|
||||
// FunctionViewWidget *m_internal_view;
|
||||
FunctionViewWidget *m_c_view;
|
||||
CommandQueueView *m_command_queue;
|
||||
FunctionListDockWidget *m_functionlist_widget;
|
||||
Ui::DccMainWindow *ui;
|
||||
ilFunction m_last_display;
|
||||
};
|
||||
|
||||
#endif // EXE2C_MAINWINDOW_H
|
||||
372
src/ui/DccMainWindow.ui
Normal file
372
src/ui/DccMainWindow.ui
Normal file
@@ -0,0 +1,372 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DccMainWindow</class>
|
||||
<widget class="QMainWindow" name="DccMainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QMdiArea" name="mdiArea"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_as"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuUndo">
|
||||
<property name="title">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<addaction name="actionUndo"/>
|
||||
<addaction name="actionRedo"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCut"/>
|
||||
<addaction name="actionCopy"/>
|
||||
<addaction name="actionPaste"/>
|
||||
<addaction name="actionDelete"/>
|
||||
<addaction name="actionSelect_All"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFind"/>
|
||||
<addaction name="actionFind_next"/>
|
||||
<addaction name="actionFind_Previous"/>
|
||||
<addaction name="actionReplace"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRead_Only"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuView">
|
||||
<property name="title">
|
||||
<string>View</string>
|
||||
</property>
|
||||
<addaction name="actionToolbar"/>
|
||||
<addaction name="actionStatus_Bar"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuWindow">
|
||||
<property name="title">
|
||||
<string>Window</string>
|
||||
</property>
|
||||
<addaction name="actionMdiCascadeWindows"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuUndo"/>
|
||||
<addaction name="menuView"/>
|
||||
<addaction name="menuWindow"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionOptim"/>
|
||||
<addaction name="actionOptim10"/>
|
||||
</widget>
|
||||
<action name="actionNew">
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_as">
|
||||
<property name="text">
|
||||
<string>Save as</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUndo">
|
||||
<property name="text">
|
||||
<string>Undo</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRedo">
|
||||
<property name="text">
|
||||
<string>Redo</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCut">
|
||||
<property name="text">
|
||||
<string>Cut</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopy">
|
||||
<property name="text">
|
||||
<string>Copy</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPaste">
|
||||
<property name="text">
|
||||
<string>Paste</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDelete">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSelect_All">
|
||||
<property name="text">
|
||||
<string>Select All</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFind">
|
||||
<property name="text">
|
||||
<string>Find</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFind_next">
|
||||
<property name="text">
|
||||
<string>Find Next</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFind_Previous">
|
||||
<property name="text">
|
||||
<string>Find Previous</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReplace">
|
||||
<property name="text">
|
||||
<string>Replace</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRead_Only">
|
||||
<property name="text">
|
||||
<string>Read Only</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOptim">
|
||||
<property name="text">
|
||||
<string>Optim</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Optimization step</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionToolbar">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Toolbar</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Toggle toolbar visibility</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+T</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStatus_Bar">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Status Bar</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Toggle status bar visibility</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMdiCascadeWindows">
|
||||
<property name="text">
|
||||
<string>Cascade windows</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Will re-arrange the mdi children windows</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMdiTileWindows">
|
||||
<property name="text">
|
||||
<string>Tile windows</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOptim10">
|
||||
<property name="text">
|
||||
<string>Optim10</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>actionStatus_Bar</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>statusbar</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>588</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionToolbar</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>toolBar</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>37</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionMdiCascadeWindows</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>mdiArea</receiver>
|
||||
<slot>cascadeSubWindows()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>347</x>
|
||||
<y>314</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionMdiTileWindows</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>mdiArea</receiver>
|
||||
<slot>tileSubWindows()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>347</x>
|
||||
<y>314</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionOptim</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>DccMainWindow</receiver>
|
||||
<slot>onOptim()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>299</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionNew</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>DccMainWindow</receiver>
|
||||
<slot>onOpenFile_Action()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>299</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionOptim10</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>DccMainWindow</receiver>
|
||||
<slot>onOptim10()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>299</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>onOptim()</slot>
|
||||
<slot>onOpenFile_Action()</slot>
|
||||
<slot>displayCurrentFunction(QModelIndex)</slot>
|
||||
<slot>functionSelected(QModelIndex)</slot>
|
||||
<slot>onOptim10()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
102
src/ui/FunctionListDockWidget.cpp
Normal file
102
src/ui/FunctionListDockWidget.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
#include "FunctionListDockWidget.h"
|
||||
#include "ui_FunctionListDockWidget.h"
|
||||
#include "dcc.h"
|
||||
#include "dcc_interface.h"
|
||||
#include "Procedure.h"
|
||||
|
||||
#include <QtCore>
|
||||
//#include "exe2c.h"
|
||||
extern IDcc *g_EXE2C;
|
||||
FunctionListDockWidget::FunctionListDockWidget(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::FunctionListDockWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_func_list_view->setModel(&m_list_model);
|
||||
}
|
||||
|
||||
FunctionListDockWidget::~FunctionListDockWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
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());
|
||||
}
|
||||
// signalled by m_func_list_view accepted signal
|
||||
void FunctionListDockWidget::displayRequest(const QModelIndex &)
|
||||
{
|
||||
// argument ignored since functionSelected must've been called before us
|
||||
emit displayRequested();
|
||||
}
|
||||
void FunctionListModel::updateFunctionList()
|
||||
{
|
||||
rebuildFunctionList();
|
||||
}
|
||||
void FunctionListModel::rebuildFunctionList()
|
||||
{
|
||||
ilFunction iter = g_EXE2C->GetFirstFuncHandle();
|
||||
clear();
|
||||
beginInsertRows(QModelIndex(),0,g_EXE2C->getFuncCount());
|
||||
|
||||
while (g_EXE2C->isValidFuncHandle(iter))
|
||||
{
|
||||
const Function &info(*iter);
|
||||
//g_EXE2C->GetFuncInfo(iter, &info);
|
||||
iter = g_EXE2C->GetNextFuncHandle(iter);
|
||||
|
||||
if (info.name.isEmpty())
|
||||
continue;
|
||||
// fixme
|
||||
add_function(info.name,info.nStep,info.procEntry,info.procEntry+10,info.cbParam);
|
||||
}
|
||||
endInsertRows();
|
||||
}
|
||||
QVariant FunctionListModel::data(const QModelIndex &idx,int role) const
|
||||
{
|
||||
int row=idx.row();
|
||||
int column=idx.column();
|
||||
const function_info &inf=m_list[row];
|
||||
if(Qt::DisplayRole==role)
|
||||
{
|
||||
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);
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
QVariant FunctionListModel::headerData(int section, Qt::Orientation orientation,int role) const
|
||||
{
|
||||
if(Qt::DisplayRole==role && orientation==Qt::Horizontal)
|
||||
{
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
72
src/ui/FunctionListDockWidget.h
Normal file
72
src/ui/FunctionListDockWidget.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef FUNCTIONLISTDOCKWIDGET_H
|
||||
#define FUNCTIONLISTDOCKWIDGET_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QDockWidget>
|
||||
//#include "exe2c.h"
|
||||
|
||||
class FunctionListModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
struct function_info
|
||||
{
|
||||
QString m_name;
|
||||
int m_decoding_step;
|
||||
int m_start_off, m_end_off, m_stack_purge;
|
||||
};
|
||||
std::vector<function_info> m_list;
|
||||
public:
|
||||
int rowCount(const QModelIndex &/*idx*/) const {return m_list.size();}
|
||||
int columnCount(const QModelIndex &/*idx*/) const {return 3;}
|
||||
QVariant data(const QModelIndex &,int role) const;
|
||||
void clear()
|
||||
{
|
||||
beginResetModel();
|
||||
m_list.clear();
|
||||
endResetModel();
|
||||
}
|
||||
QVariant headerData(int section, Qt::Orientation orientation,int role) const;
|
||||
public slots:
|
||||
void updateFunctionList();
|
||||
|
||||
protected:
|
||||
void add_function(const QString &name,int step,int start_off,int end_off,int stack_purge)
|
||||
{
|
||||
|
||||
function_info info;
|
||||
info.m_name=name;
|
||||
info.m_decoding_step=step;
|
||||
info.m_start_off=start_off;
|
||||
info.m_end_off=end_off;
|
||||
info.m_stack_purge=stack_purge;
|
||||
m_list.push_back(info);
|
||||
}
|
||||
void rebuildFunctionList();
|
||||
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class FunctionListDockWidget;
|
||||
}
|
||||
|
||||
class FunctionListDockWidget : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FunctionListDockWidget(QWidget *parent = 0);
|
||||
~FunctionListDockWidget();
|
||||
FunctionListModel *model() {return &m_list_model;}
|
||||
public slots:
|
||||
void displayRequest(const QModelIndex &idx);
|
||||
void functionSelected(const QModelIndex &idx);
|
||||
|
||||
signals:
|
||||
void displayRequested();
|
||||
private:
|
||||
Ui::FunctionListDockWidget *ui;
|
||||
FunctionListModel m_list_model;
|
||||
};
|
||||
|
||||
#endif // FUNCTIONLISTDOCKWIDGET_H
|
||||
74
src/ui/FunctionListDockWidget.ui
Normal file
74
src/ui/FunctionListDockWidget.ui
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FunctionListDockWidget</class>
|
||||
<widget class="QDockWidget" name="FunctionListDockWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>DockWidget</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="m_func_list_view">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>m_func_list_view</sender>
|
||||
<signal>activated(QModelIndex)</signal>
|
||||
<receiver>FunctionListDockWidget</receiver>
|
||||
<slot>displayRequest(QModelIndex)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>199</x>
|
||||
<y>161</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>199</x>
|
||||
<y>149</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_func_list_view</sender>
|
||||
<signal>clicked(QModelIndex)</signal>
|
||||
<receiver>FunctionListDockWidget</receiver>
|
||||
<slot>functionSelected(QModelIndex)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>199</x>
|
||||
<y>161</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>199</x>
|
||||
<y>149</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<signal>displayRequested()</signal>
|
||||
<slot>displayRequest(QModelIndex)</slot>
|
||||
<slot>functionSelected(QModelIndex)</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
81
src/ui/FunctionViewWidget.cpp
Normal file
81
src/ui/FunctionViewWidget.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
#include <QDebug>
|
||||
#include <QtCore>
|
||||
#include "FunctionViewWidget.h"
|
||||
#include "ui_FunctionViewWidget.h"
|
||||
#include "RenderTags.h"
|
||||
//#include "XMLTYPE.h"
|
||||
FunctionViewWidget::FunctionViewWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FunctionViewWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
//ui->label->setTextFormat(Qt::RichText);
|
||||
}
|
||||
|
||||
FunctionViewWidget::~FunctionViewWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FunctionViewWidget::prtt(const char *s)
|
||||
{
|
||||
collected_text+=s;
|
||||
//collected_text+="<br>";
|
||||
}
|
||||
void FunctionViewWidget::prtt(const std::string &s)
|
||||
{
|
||||
collected_text+=s.c_str();
|
||||
//collected_text+="<br>";
|
||||
}
|
||||
void FunctionViewWidget::TAGbegin(TAG_TYPE tag_type, void *p)
|
||||
{
|
||||
QColor col= RenderTag_2_Color(tag_type);
|
||||
switch(tag_type)
|
||||
{
|
||||
case XT_Function:
|
||||
collected_text+="<body style='color: #FFFFFF; background-color: #000000'>";
|
||||
break;
|
||||
case XT_FuncName:
|
||||
case XT_Symbol:
|
||||
case XT_Keyword:
|
||||
case XT_DataType:
|
||||
case XT_Number:
|
||||
case XT_AsmOffset:
|
||||
case XT_AsmLabel:
|
||||
collected_text+="<font color='"+col.name()+"'>";
|
||||
break;
|
||||
default:
|
||||
qDebug()<<"Tag type:"<<tag_type;
|
||||
}
|
||||
}
|
||||
void FunctionViewWidget::TAGend(TAG_TYPE tag_type)
|
||||
{
|
||||
switch(tag_type)
|
||||
{
|
||||
case XT_Function:
|
||||
{
|
||||
collected_text+="</body>";
|
||||
// TODO: What about attributes with spaces?
|
||||
collected_text.replace(" ", " ");
|
||||
QFile res("result.html");
|
||||
res.open(QFile::WriteOnly);
|
||||
res.write(collected_text.toUtf8());
|
||||
res.close();
|
||||
collected_text.replace(QChar('\n'),"<br>");
|
||||
ui->textEdit->setHtml(collected_text);
|
||||
collected_text.clear();
|
||||
break;
|
||||
}
|
||||
case XT_FuncName:
|
||||
case XT_Symbol:
|
||||
case XT_Keyword:
|
||||
case XT_DataType:
|
||||
case XT_Number:
|
||||
case XT_AsmOffset:
|
||||
case XT_AsmLabel:
|
||||
collected_text+="</font>";
|
||||
break;
|
||||
default:
|
||||
qDebug()<<"Tag end:"<<tag_type;
|
||||
}
|
||||
}
|
||||
27
src/ui/FunctionViewWidget.h
Normal file
27
src/ui/FunctionViewWidget.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef FUNCTIONVIEWWIDGET_H
|
||||
#define FUNCTIONVIEWWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "StructuredTextTarget.h"
|
||||
#include "RenderTags.h"
|
||||
//#include "XmlPrt.h"
|
||||
namespace Ui {
|
||||
class FunctionViewWidget;
|
||||
}
|
||||
class FunctionViewWidget : public QWidget,public IStructuredTextTarget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FunctionViewWidget(QWidget *parent = 0);
|
||||
~FunctionViewWidget();
|
||||
void prtt(const char * s);
|
||||
void prtt(const std::string &s);
|
||||
void TAGbegin(enum TAG_TYPE tag_type, void * p);
|
||||
void TAGend(enum TAG_TYPE tag_type);
|
||||
private:
|
||||
Ui::FunctionViewWidget *ui;
|
||||
QString collected_text;
|
||||
};
|
||||
|
||||
#endif // FUNCTIONVIEWWIDGET_H
|
||||
28
src/ui/FunctionViewWidget.ui
Normal file
28
src/ui/FunctionViewWidget.ui
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FunctionViewWidget</class>
|
||||
<widget class="QWidget" name="FunctionViewWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
23
src/ui/RenderTags.cpp
Normal file
23
src/ui/RenderTags.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "RenderTags.h"
|
||||
|
||||
QColor RenderTag_2_Color(TAG_TYPE tag_type)
|
||||
{
|
||||
switch (tag_type)
|
||||
{
|
||||
case XT_invalid : return QColor(255,255,255);
|
||||
case XT_blank : return QColor(255,255,255);
|
||||
case XT_Symbol : return QColor(57,109,165);
|
||||
case XT_Function : return QColor(255,255,255);
|
||||
case XT_Keyword : return QColor(255,255,0);
|
||||
case XT_Class : return QColor(255,255,0);
|
||||
case XT_K1 : return QColor(163,70,255);
|
||||
case XT_Comment : return QColor(0,245,255);
|
||||
case XT_DataType : return QColor(100,222,192);
|
||||
case XT_Number : return QColor(0,255,0);
|
||||
case XT_AsmStack : return QColor(0,70,255);
|
||||
case XT_AsmOffset: return QColor(70,180,70);
|
||||
case XT_AsmLabel : return QColor(255,180,70);
|
||||
case XT_FuncName : return QColor(255,0,255);
|
||||
}
|
||||
return QColor(255,255,255);
|
||||
}
|
||||
28
src/ui/RenderTags.h
Normal file
28
src/ui/RenderTags.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <qcolor.h>
|
||||
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_DataType, //
|
||||
XT_Number, //
|
||||
XT_AsmStack, //stack values
|
||||
XT_AsmOffset, //seg:offset
|
||||
XT_AsmLabel, //label name
|
||||
XT_FuncName,
|
||||
};
|
||||
struct tColorPair
|
||||
{
|
||||
QColor color1;
|
||||
QColor color2;
|
||||
};
|
||||
extern tColorPair tbl_color[];
|
||||
|
||||
QColor RenderTag_2_Color(TAG_TYPE tag_type);
|
||||
Reference in New Issue
Block a user