diff --git a/NEWS.md b/NEWS.md index 9c7b676f..4fc61614 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,7 @@ Red Panda C++ Version 0.13.2 - enhancement: modify values in the memory view while debugging - enhancement: auto update watch, local and memory view after expression evaluated - enhancement: auto update watch, local and memory view after memory modified + - enhancement: modify values in the watch view by double click diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 2237fe33..89ba4085 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -42,6 +42,8 @@ Debugger::Debugger(QObject *parent) : QObject(parent) mMemoryModel = new MemoryModel(8,this); connect(mMemoryModel,&MemoryModel::setMemoryData, this, &Debugger::setMemoryData); + connect(mWatchModel, &WatchModel::setWatchVarValue, + this, &Debugger::setWatchVarValue); mExecuting = false; mReader = nullptr; mTarget = nullptr; @@ -590,6 +592,12 @@ void Debugger::setMemoryData(qulonglong address, unsigned char data) refreshAll(); } +void Debugger::setWatchVarValue(const QString &name, const QString &value) +{ + sendCommand("-var-assign",QString("%1 %2").arg(name,value)); + refreshAll(); +} + void Debugger::updateMemory(const QStringList &value) { mMemoryModel->updateMemory(value); @@ -2138,6 +2146,35 @@ QModelIndex WatchModel::index(WatchVar* pVar) const { } } +bool WatchModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!index.isValid()) { + return false; + } + if (index.column()==2 && role == Qt::EditRole) { + WatchVar* item = static_cast(index.internalPointer()); + emit setWatchVarValue(item->name,value.toString()); + } + return false; + +} + +Qt::ItemFlags WatchModel::flags(const QModelIndex &index) const +{ + Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; + if (!index.isValid()) { + return Qt::ItemIsEnabled; + } + if (index.column() == 2) { + WatchVar* item = static_cast(index.internalPointer()); + qDebug()<name<numChild<type<hasMore<<(item->numChild==0 && !item->hasMore && !item->type.isEmpty()); + if (item->numChild==0 && !item->type.isEmpty()) + flags |= Qt::ItemIsEditable; + qDebug()< mWatchVars; QHash mVarIndex; int mUpdateCount; + + // QAbstractItemModel interface +public: + bool setData(const QModelIndex &index, const QVariant &value, int role) override; + Qt::ItemFlags flags(const QModelIndex &index) const override; }; struct MemoryLine { @@ -313,6 +320,7 @@ private: private slots: void syncFinishedParsing(); void setMemoryData(qulonglong address, unsigned char data); + void setWatchVarValue(const QString& name, const QString& value); void updateMemory(const QStringList& value); void updateEval(const QString& value); void updateDisassembly(const QString& file, const QString& func,const QStringList& value); diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index d343b303..0cc17bcf 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -85,7 +85,7 @@ QTabWidget::West - 0 + 1 true @@ -165,7 +165,7 @@ - QAbstractItemView::NoEditTriggers + QAbstractItemView::DoubleClicked Qt::ElideNone