From 45e7ccc0fa0663fd3df7b3efce456549db0f20ea Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Thu, 19 Mar 2009 15:33:11 +0100
Subject: [PATCH] debugger: make assignment of simple types work again

---
 src/plugins/debugger/debuggermanager.cpp | 5 ++++-
 src/plugins/debugger/watchhandler.cpp    | 6 +++---
 src/plugins/debugger/watchhandler.h      | 2 +-
 src/plugins/debugger/watchwindow.cpp     | 9 ++++++---
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp
index 35c78d94b6c..2c16981558d 100644
--- a/src/plugins/debugger/debuggermanager.cpp
+++ b/src/plugins/debugger/debuggermanager.cpp
@@ -966,7 +966,10 @@ void DebuggerManager::exitDebugger()
 void DebuggerManager::assignValueInDebugger()
 {
     if (QAction *action = qobject_cast<QAction *>(sender())) {
-        qDebug() << "HANDLING " << action->data().toString();
+        QString str = action->data().toString();
+        int i = str.indexOf('=');
+        if (i != -1)
+            assignValueInDebugger(str.left(i), str.mid(i + 1));
     }
 }
 void DebuggerManager::assignValueInDebugger(const QString &expr, const QString &value)
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index f0d5a33a1fa..355417d81ed 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -440,9 +440,6 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
     const WatchData &data = m_displaySet.at(node);
 
     switch (role) {
-        case Qt::EditRole:
-            return data.exp;
-
         case Qt::DisplayRole: {
             switch (idx.column()) {
                 case 0: return data.name;
@@ -496,6 +493,9 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
             break;
         }
 
+        case ExpressionRole:
+            return data.exp;
+
         case INameRole:
             return data.iname;
 
diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h
index aed6b37566d..4cac4a87f99 100644
--- a/src/plugins/debugger/watchhandler.h
+++ b/src/plugins/debugger/watchhandler.h
@@ -132,7 +132,7 @@ public:
     bool changed;
 };
 
-enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole };
+enum { INameRole = Qt::UserRole, ExpressionRole, VisualRole, ExpandedRole };
 
 
 class WatchHandler : public QAbstractItemModel
diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp
index f93a7fe7ec8..70f32cd48cb 100644
--- a/src/plugins/debugger/watchwindow.cpp
+++ b/src/plugins/debugger/watchwindow.cpp
@@ -54,7 +54,7 @@ using namespace Debugger::Internal;
 //
 /////////////////////////////////////////////////////////////////////
 
-enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole };
+enum { INameRole = Qt::UserRole, ExpressionRole, VisualRole, ExpandedRole };
 
 class WatchDelegate : public QItemDelegate
 {
@@ -71,7 +71,10 @@ public:
     {
         QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor);
         QTC_ASSERT(lineEdit, return);
-        lineEdit->setText(index.model()->data(index, Qt::EditRole).toString());
+        if (index.column() == 1) 
+            lineEdit->setText(index.model()->data(index, Qt::DisplayRole).toString());
+        else
+            lineEdit->setText(index.model()->data(index, ExpressionRole).toString());
     }
 
     void setModelData(QWidget *editor, QAbstractItemModel *,
@@ -80,7 +83,7 @@ public:
         QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
         QTC_ASSERT(lineEdit, return);
         QString value = lineEdit->text();
-        QString exp = index.model()->data(index, Qt::EditRole).toString();
+        QString exp = index.model()->data(index, ExpressionRole).toString();
         if (index.column() == 1) {
             // the value column
             theDebuggerSetting(AssignValue)->trigger(exp + '=' + value);
-- 
GitLab