Commit 5dd26166 authored by hjk's avatar hjk

Debugger: Remove direct entering new watchers in the treeview

Instead pop up the "Add new expression dialog". Same amount of activity
needed, but more uniform in UI and code and hopefully less confusion
about the now-gone <Edit> marker.

Change-Id: I228801dc51f6d09ea9991b98399dc9ef04aa96c8
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 170389cf
......@@ -1502,20 +1502,15 @@ class DumperBase:
self.put('iname="%s",' % iname)
self.put('name="%s",' % exp)
self.put('wname="%s",' % escapedExp)
if len(exp) == 0: # The <Edit> case
self.putValue(" ")
self.putNoType()
try:
value = self.parseAndEvaluate(exp)
self.putItem(value)
except RuntimeError:
self.currentType.value = " "
self.currentValue.value = "<no such value>"
self.currentChildNumChild = -1
self.currentNumChild = 0
self.putNumChild(0)
else:
try:
value = self.parseAndEvaluate(exp)
self.putItem(value)
except RuntimeError:
self.currentType.value = " "
self.currentValue.value = "<no such value>"
self.currentChildNumChild = -1
self.currentNumChild = 0
self.putNumChild(0)
# Some "Enums"
......
......@@ -684,8 +684,6 @@ static QString quoteUnprintable(const QString &str)
static QString translate(const QString &str)
{
if (str.startsWith(QLatin1Char('<'))) {
if (str == QLatin1String("<Edit>"))
return WatchHandler::tr("<Edit>");
if (str == QLatin1String("<empty>"))
return WatchHandler::tr("<empty>");
if (str == QLatin1String("<uninitialized>"))
......@@ -1063,9 +1061,7 @@ static QString expression(const WatchItem *item)
QString WatchModel::displayName(const WatchItem *item) const
{
QString result;
if (item->parent == m_watchRoot && item->name.isEmpty())
result = tr("<Edit>");
else if (item->parent == m_returnRoot)
if (item->parent == m_returnRoot)
result = tr("returned value");
else if (item->name == QLatin1String("*"))
result = QLatin1Char('*') + item->parent->name;
......
......@@ -554,8 +554,7 @@ void WatchTreeView::mouseDoubleClickEvent(QMouseEvent *ev)
{
const QModelIndex idx = indexAt(ev->pos());
if (!idx.isValid()) {
// The "<Edit>" case.
watchExpression(QString());
inputNewExpression();
return;
}
BaseTreeView::mouseDoubleClickEvent(ev);
......@@ -921,12 +920,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
if (!act) {
;
} else if (act == &actInsertNewWatchItem) {
bool ok;
QString newExp = QInputDialog::getText(this, tr("Enter Expression for Evaluator"),
tr("Expression:"), QLineEdit::Normal,
QString(), &ok);
if (ok && !newExp.isEmpty())
watchExpression(newExp);
inputNewExpression();
} else if (act == &actOpenMemoryEditAtObjectAddress) {
addVariableMemoryView(currentEngine(), false, mi0, false, ev->globalPos(), this);
} else if (act == &actOpenMemoryEditAtPointerAddress) {
......@@ -1090,5 +1084,15 @@ void WatchTreeView::setModelData
model()->setData(index, value, role);
}
void WatchTreeView::inputNewExpression()
{
bool ok;
QString exp = QInputDialog::getText(this, tr("Enter Expression for Evaluator"),
tr("Expression:"), QLineEdit::Normal,
QString(), &ok);
if (ok && !exp.isEmpty())
watchExpression(exp, exp);
}
} // namespace Internal
} // namespace Debugger
......@@ -89,6 +89,7 @@ private:
bool event(QEvent *ev);
void currentChanged(const QModelIndex &current, const QModelIndex &previous);
void inputNewExpression();
void editItem(const QModelIndex &idx);
void resetHelper(const QModelIndex &idx);
......
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