From ab7421e2fb01e4ea6409fc67067b2b843fd624df Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sun, 21 Sep 2003 17:49:35 +0000 Subject: [PATCH] Added value editing also to the watches window. --- kdbg/dbgmainwnd.cpp | 28 +++++++++++++++++++++++++--- kdbg/debugger.cpp | 26 ++++++++++---------------- kdbg/debugger.h | 5 +---- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index 7b1853d..cfe0f68 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -27,6 +27,7 @@ #include "memwindow.h" #include "ttywnd.h" #include "procattach.h" +#include "dbgdriver.h" #include "mydebug.h" @@ -744,10 +745,31 @@ void DebuggerMainWnd::slotLocalsToWatch() */ void DebuggerMainWnd::slotEditValue() { - int idx = m_localVariables->currentItem(); - if (idx >= 0 && m_debugger != 0 && m_debugger->canSingleStep()) { + // does one of the value trees have the focus + QWidget* f = kapp->focusWidget(); + ExprWnd* wnd; + if (f == m_localVariables) { + wnd = m_localVariables; + } else if (f == m_watches->watchVariables()) { + wnd = m_watches->watchVariables(); + } else { + return; + } + + if (m_localVariables->isEditing() || + m_watches->watchVariables()->isEditing()) + { + return; /* don't edit twice */ + } + + int idx = wnd->currentItem(); + if (idx >= 0 && m_debugger != 0 && m_debugger->canSingleStep()) + { TRACE("edit value"); - m_debugger->editLocalValue(idx); + // determine the text to edit + VarTree* expr = static_cast(wnd->itemAt(idx)); + QString text = m_debugger->driver()->editableValue(expr); + wnd->editValue(idx, text); } } diff --git a/kdbg/debugger.cpp b/kdbg/debugger.cpp index 5d3e9f1..cf95c96 100644 --- a/kdbg/debugger.cpp +++ b/kdbg/debugger.cpp @@ -55,7 +55,9 @@ KDebugger::KDebugger(QWidget* parent, connect(&m_watchVariables, SIGNAL(expanding(KTreeViewItem*,bool&)), SLOT(slotWatchExpanding(KTreeViewItem*,bool&))); connect(&m_localVariables, SIGNAL(editValueCommitted(int, const QString&)), - SLOT(slotLocalsValueEdited(int, const QString&))); + SLOT(slotValueEdited(int, const QString&))); + connect(&m_watchVariables, SIGNAL(editValueCommitted(int, const QString&)), + SLOT(slotValueEdited(int, const QString&))); connect(&m_btWindow, SIGNAL(highlighted(int)), SLOT(gotoFrame(int))); @@ -2230,30 +2232,22 @@ void KDebugger::handleSetPC(const char* /*output*/) gotoFrame(0); } -void KDebugger::editLocalValue(int row) -{ - if (m_localVariables.isEditing()) /* don't edit twice */ - return; - - // determine the text to edit - VarTree* expr = static_cast(m_localVariables.itemAt(row)); - QString text = m_d->editableValue(expr); - m_localVariables.editValue(row, text); -} - -void KDebugger::slotLocalsValueEdited(int row, const QString& text) +void KDebugger::slotValueEdited(int row, const QString& text) { if (text.simplifyWhiteSpace().isEmpty()) return; /* no text entered: ignore request */ - TRACE(QString().sprintf("Changing value at row %d to ", row) + text); + ASSERT(sender()->inherits("ExprWnd")); + ExprWnd* wnd = const_cast(static_cast(sender())); + TRACE(QString().sprintf("Changing %s at row %d to ", + wnd->name(), row) + text); // determine the lvalue to edit - VarTree* expr = static_cast(m_localVariables.itemAt(row)); + VarTree* expr = static_cast(wnd->itemAt(row)); QString lvalue = expr->computeExpr(); CmdQueueItem* cmd = m_d->executeCmd(DCsetvariable, lvalue, text); cmd->m_expr = expr; - cmd->m_exprWnd = &m_localVariables; + cmd->m_exprWnd = wnd; } void KDebugger::handleSetVariable(CmdQueueItem* cmd, const char* output) diff --git a/kdbg/debugger.h b/kdbg/debugger.h index 81e8cbd..7263578 100644 --- a/kdbg/debugger.h +++ b/kdbg/debugger.h @@ -308,9 +308,6 @@ public: /** Returns the pid that the debugger is currently attached to. */ const QString& attachedPid() const { return m_attachedPid; } - /** Edit a value */ - void editLocalValue(int row); - /** * The memory at that the expression evaluates to is watched. Can be * empty. Triggers a redisplay even if the expression did not change. @@ -420,7 +417,7 @@ protected slots: void slotDeleteWatch(); void slotValuePopup(const QString&); void slotDisassemble(const QString&, int); - void slotLocalsValueEdited(int, const QString&); + void slotValueEdited(int, const QString&); public slots: void setThread(int); void shutdown(); -- 2.11.4.GIT