debugger: disable some watch related actions when appropriate

This commit is contained in:
hjk
2010-07-14 14:52:14 +02:00
parent 9a1d97707a
commit bc325eb9ab

View File

@@ -283,7 +283,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
const bool actionsEnabled = modelData(EngineActionsEnabledRole).toBool(); const bool actionsEnabled = modelData(EngineActionsEnabledRole).toBool();
const unsigned engineCapabilities = modelData(EngineCapabilitiesRole).toUInt(); const unsigned engineCapabilities = modelData(EngineCapabilitiesRole).toUInt();
const bool canHandleWatches = actionsEnabled && (engineCapabilities & AddWatcherCapability); const bool canHandleWatches =
actionsEnabled && (engineCapabilities & AddWatcherCapability);
QMenu menu; QMenu menu;
QAction *actInsertNewWatchItem = menu.addAction(tr("Insert New Watch Item")); QAction *actInsertNewWatchItem = menu.addAction(tr("Insert New Watch Item"));
@@ -335,12 +336,15 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
actSetWatchPointAtVariableAddress->setEnabled(false); actSetWatchPointAtVariableAddress->setEnabled(false);
} }
QAction *actWatchExpression = QString actionName = exp.isEmpty() ? tr("Watch Expression")
new QAction(tr("Watch Expression \"%1\"").arg(exp), &menu); : tr("Watch Expression \"%1\"").arg(exp);
actWatchExpression->setEnabled(canHandleWatches); QAction *actWatchExpression = new QAction(actionName, &menu);
actWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty());
QAction *actRemoveWatchExpression = actionName = exp.isEmpty() ? tr("Remove Watch Expression")
new QAction(tr("Remove Watch Expression \"%1\"").arg(exp), &menu); : tr("Remove Watch Expression \"%1\"").arg(exp);
QAction *actRemoveWatchExpression = new QAction(actionName, &menu);
actRemoveWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty());
if (m_type == LocalsType) if (m_type == LocalsType)
menu.addAction(actWatchExpression); menu.addAction(actWatchExpression);