From a350650c593c6ee4c4dcb7835a95580885f4c13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E8=B6=8A?= Date: Thu, 18 May 2023 23:13:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E5=8D=95=E6=AD=A5?= =?UTF-8?q?=E4=B8=8E=E6=96=AD=E7=82=B9=E6=97=B6=E5=86=85=E5=AD=98=E5=92=8C?= =?UTF-8?q?=E5=AF=84=E5=AD=98=E5=99=A8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/Main.qml | 30 +++++++++++++++++++++++++++++- middle/memorytablemodel.cpp | 26 ++++++++++++++------------ middle/memorytablemodel.h | 2 ++ middle/registertablemodel.cpp | 2 +- middle/registertablemodel.h | 5 ++++- 5 files changed, 50 insertions(+), 15 deletions(-) diff --git a/front/Main.qml b/front/Main.qml index d61bc65..233f8cf 100644 --- a/front/Main.qml +++ b/front/Main.qml @@ -203,7 +203,7 @@ Window { columnWidthProvider: function (column) { switch (column) { case 0: - return dp(200); + return dp(250); case 1: case 2: case 3: @@ -717,6 +717,8 @@ Window { return; } codeTableModel.executeToNextBreakpoint(); + registerTableModel.initTable(); + memoryTableModel.initTable(); } Connections { target: codeTableModel @@ -727,6 +729,18 @@ Window { message.show(err, "red", 5000); } } + Connections { + target: registerTableModel + function onFail(err) { + message.show(err, "red", 5000); + } + } + Connections { + target: memoryTableModel + function onFail(err) { + message.show(err, "red", 5000); + } + } } MenuItem { text: qsTr("单步") @@ -736,6 +750,8 @@ Window { return; } codeTableModel.executeOneStep(); + registerTableModel.initTable(); + memoryTableModel.initTable(); } Connections { target: codeTableModel @@ -746,6 +762,18 @@ Window { message.show(err, "red", 5000); } } + Connections { + target: registerTableModel + function onFail(err) { + message.show(err, "red", 5000); + } + } + Connections { + target: memoryTableModel + function onFail(err) { + message.show(err, "red", 5000); + } + } } } Menu { diff --git a/middle/memorytablemodel.cpp b/middle/memorytablemodel.cpp index 56ebf74..0466c3c 100644 --- a/middle/memorytablemodel.cpp +++ b/middle/memorytablemodel.cpp @@ -9,19 +9,21 @@ void MemoryTableModel::initTable() { try { table.clear(); table.append({"地址", "值(+0)", "值(+4)", "值(+8)", "值(+c)", "值(+10)", "值(+14)", "值(+18)", "值(+1c)"}); - // for (int i = 0x10010000; i <= 0x100101e0; i += 0x20) { - // QVector row; - // row.append(QString::fromStdString("0x" + to_string(i))); - // for (int j = 0; j < 8; j++) { - // bitset<32> value = sys.AccessMemory(bitset<32>(i + j * 4)); - // stringstream ss; - // ss << hex << value.to_ulong(); - // row.append(QString::fromStdString("0x" + ss.str())); - // } - // table.append(row); - // } + for (int i = 0x10010000; i <= 0x100101e0; i += 0x20) { + QVector row; + stringstream ss; + ss << hex << i; + row.append(QString::fromStdString("0x" + ss.str())); + for (int j = 0; j < 8; j++) { + bitset<32> value = sys.ReadMemory(bitset<32>(i + j * 4)); + stringstream ss; + ss << hex << value.to_ulong(); + row.append(QString::fromStdString("0x" + ss.str())); + } + table.append(row); + } } catch (exception &e) { - cerr << e.what() << endl; + emit fail(QString{e.what()}); } endResetModel(); } \ No newline at end of file diff --git a/middle/memorytablemodel.h b/middle/memorytablemodel.h index 7fff11e..435dc46 100644 --- a/middle/memorytablemodel.h +++ b/middle/memorytablemodel.h @@ -41,6 +41,8 @@ class MemoryTableModel : public QAbstractTableModel { private: QVector> table; + signals: + void fail(QString); }; #endif // MEMORYTABLEMODEL_H diff --git a/middle/registertablemodel.cpp b/middle/registertablemodel.cpp index 5aaa460..7eb595b 100644 --- a/middle/registertablemodel.cpp +++ b/middle/registertablemodel.cpp @@ -17,7 +17,7 @@ void RegisterTableModel::initTable() { QString::fromStdString("0x" + ss.str())}); } } catch (exception &e) { - cerr << e.what() << endl; + emit fail(QString{e.what()}); } endResetModel(); } diff --git a/middle/registertablemodel.h b/middle/registertablemodel.h index 641ca37..2b67b36 100644 --- a/middle/registertablemodel.h +++ b/middle/registertablemodel.h @@ -35,10 +35,13 @@ class RegisterTableModel : public QAbstractTableModel { return roles; } - void initTable(); + Q_INVOKABLE void initTable(); private: QVector> table; + + signals: + void fail(QString); }; #endif // REGISTERTABLEMODEL_H