forked from qt-creator/qt-creator
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 <christian.stenger@theqtcompany.com> Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -857,8 +857,25 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role
|
|||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
switch (idx.column()) {
|
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;
|
break;
|
||||||
|
}
|
||||||
case 1: // Change value
|
case 1: // Change value
|
||||||
engine()->assignValueInDebugger(&data, item->expression(), value);
|
engine()->assignValueInDebugger(&data, item->expression(), value);
|
||||||
break;
|
break;
|
||||||
|
@@ -116,27 +116,6 @@ public:
|
|||||||
return lineEdit;
|
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,
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &) const
|
const QModelIndex &) const
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user