Commit d27ec169 authored by hjk's avatar hjk
Browse files

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

items
parent bdb2e751
......@@ -214,6 +214,7 @@ enum ModelRoles
LocalsPointerValueRole, // Pointer value (address) as quint64
LocalsIsWatchpointAtAddressRole,
LocalsIsWatchpointAtPointerValueRole,
WatcherEditPlaceHolderRole,
RequestWatchPointRole,
RequestToggleWatchRole,
RequestToolTipByExpressionRole,
......
......@@ -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();
......
......@@ -201,7 +201,7 @@ private:
QHash<QString, QStringList> m_reportedTypeFormats;
// Items expanded in the Locals & Watchers view.
QSet<QByteArray> m_expandedINames;
QSet<QByteArray> m_expandedINames;
WatchModel *m_return;
WatchModel *m_locals;
......
......@@ -206,7 +206,9 @@ void WatchWindow::mouseDoubleClickEvent(QMouseEvent *ev)
{
const QModelIndex idx = indexAt(ev->pos());
if (!idx.isValid()) {
setModelData(RequestWatchExpressionRole, QString("<Edit>"));
// The "<Edit>" string.
QVariant placeHolder = model()->data(idx, WatcherEditPlaceHolderRole);
setModelData(RequestWatchExpressionRole, placeHolder);
return;
}
QTreeView::mouseDoubleClickEvent(ev);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment