From df00a7af64d142b2ac64316816d02c33b7e7a981 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 6 Mar 2015 11:32:39 +0100 Subject: [PATCH] Debugger: Move watcher modification from delegate to model We don't need the remove/re-insert cycle in the new model, so the expression modification can be done directly. Change-Id: If9626f48fcfbcf75e61d332afb59b986da6c2dbc Reviewed-by: Christian Stenger Reviewed-by: hjk --- src/plugins/debugger/watchhandler.cpp | 19 ++++++++++++++++++- src/plugins/debugger/watchwindow.cpp | 21 --------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index b9f8ebb2891..7ef0e3890e0 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -857,8 +857,25 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role switch (role) { case Qt::EditRole: switch (idx.column()) { - case 0: // Watch expression: See delegate. + case 0: { + QByteArray exp = value.toByteArray(); + if (!exp.isEmpty()) { + theWatcherNames.remove(item->d.exp); + item->d.exp = exp; + item->d.name = QString::fromLatin1(exp); + theWatcherNames[exp] = m_handler->m_watcherCounter++; + m_handler->saveWatchers(); + if (engine()->state() == DebuggerNotReady) { + item->d.setAllUnneeded(); + item->d.setValue(QString(QLatin1Char(' '))); + item->d.setHasChildren(false); + } else { + engine()->updateWatchData(item->d); + } + } + m_handler->updateWatchersWindow(); break; + } case 1: // Change value engine()->assignValueInDebugger(&data, item->expression(), value); break; diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 33cc5be3aff..4c359802695 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -116,27 +116,6 @@ public: return lineEdit; } - void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const - { - // Standard handling for anything but the watcher name column (change - // expression), which removes/recreates a row, which cannot be done - // in model->setData(). - if (index.column() != 0) { - QItemDelegate::setModelData(editor, model, index); - return; - } - const QMetaProperty userProperty = editor->metaObject()->userProperty(); - QTC_ASSERT(userProperty.isValid(), return); - const QString value = editor->property(userProperty.name()).toString(); - const QString exp = index.data(LocalsExpressionRole).toString(); - if (exp == value) - return; - WatchHandler *handler = currentEngine()->watchHandler(); - handler->removeData(index.data(LocalsINameRole).toByteArray()); - handler->watchExpression(value); - } - void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const {