debugger: do not insert multiple "<Edit>" placeholders when creating new watch

items
This commit is contained in:
hjk
2010-07-22 15:34:35 +02:00
parent bdb2e751e0
commit d27ec169d0
4 changed files with 34 additions and 8 deletions

View File

@@ -599,11 +599,21 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
case EngineActionsEnabledRole:
return engine()->debuggerActionsEnabled();
case WatcherEditPlaceHolderRole:
return m_handler->watcherEditPlaceHolder();
}
const WatchItem *item = watchItem(idx);
const WatchItem &data = *item;
if (data.name == m_handler->watcherEditPlaceHolder()) {
if (idx.column() == 0 &&
(role == Qt::EditRole || role == Qt::DisplayRole))
return data.name;
return QVariant();
}
switch (role) {
case Qt::EditRole:
case Qt::DisplayRole: {
@@ -822,12 +832,21 @@ Qt::ItemFlags WatchModel::flags(const QModelIndex &idx) const
const WatchData &data = *watchItem(idx);
if (data.isWatcher() && idx.column() == 0)
return editable; // watcher names are editable
if (data.isWatcher() && idx.column() == 2)
return editable; // watcher types are
if (idx.column() == 1 && data.valueEditable)
return editable; // locals and watcher values are sometimes editable
if (idx.column() == 0)
return editable; // Watcher names are editable.
if (data.isWatcher()) {
if (data.name != m_handler->watcherEditPlaceHolder()) {
// FIXME: Forcing types is not implemented yet.
//if (idx.column() == 2)
// return editable; // Watcher types can be set by force.
if (idx.column() == 1 && data.valueEditable)
return editable; // Watcher values are sometimes editable.
}
} else {
if (idx.column() == 1 && data.valueEditable)
return editable; // Locals values are sometimes editable.
}
return notEditable;
}
@@ -1229,6 +1248,10 @@ QByteArray WatchHandler::watcherName(const QByteArray &exp)
void WatchHandler::watchExpression(const QString &exp)
{
// Do not insert multiple placeholders.
if (exp == watcherEditPlaceHolder() && m_watcherNames.contains(exp.toLatin1()))
return;
// FIXME: 'exp' can contain illegal characters
WatchData data;
data.exp = exp.toLatin1();