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: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-07-07 10:33:38 +02:00
parent 170389cf40
commit 5dd261662b
4 changed files with 22 additions and 26 deletions

View File

@@ -1502,20 +1502,15 @@ class DumperBase:
self.put('iname="%s",' % iname) self.put('iname="%s",' % iname)
self.put('name="%s",' % exp) self.put('name="%s",' % exp)
self.put('wname="%s",' % escapedExp) self.put('wname="%s",' % escapedExp)
if len(exp) == 0: # The <Edit> case try:
self.putValue(" ") value = self.parseAndEvaluate(exp)
self.putNoType() self.putItem(value)
except RuntimeError:
self.currentType.value = " "
self.currentValue.value = "<no such value>"
self.currentChildNumChild = -1
self.currentNumChild = 0
self.putNumChild(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" # Some "Enums"

View File

@@ -684,8 +684,6 @@ static QString quoteUnprintable(const QString &str)
static QString translate(const QString &str) static QString translate(const QString &str)
{ {
if (str.startsWith(QLatin1Char('<'))) { if (str.startsWith(QLatin1Char('<'))) {
if (str == QLatin1String("<Edit>"))
return WatchHandler::tr("<Edit>");
if (str == QLatin1String("<empty>")) if (str == QLatin1String("<empty>"))
return WatchHandler::tr("<empty>"); return WatchHandler::tr("<empty>");
if (str == QLatin1String("<uninitialized>")) if (str == QLatin1String("<uninitialized>"))
@@ -1063,9 +1061,7 @@ static QString expression(const WatchItem *item)
QString WatchModel::displayName(const WatchItem *item) const QString WatchModel::displayName(const WatchItem *item) const
{ {
QString result; QString result;
if (item->parent == m_watchRoot && item->name.isEmpty()) if (item->parent == m_returnRoot)
result = tr("<Edit>");
else if (item->parent == m_returnRoot)
result = tr("returned value"); result = tr("returned value");
else if (item->name == QLatin1String("*")) else if (item->name == QLatin1String("*"))
result = QLatin1Char('*') + item->parent->name; result = QLatin1Char('*') + item->parent->name;

View File

@@ -554,8 +554,7 @@ void WatchTreeView::mouseDoubleClickEvent(QMouseEvent *ev)
{ {
const QModelIndex idx = indexAt(ev->pos()); const QModelIndex idx = indexAt(ev->pos());
if (!idx.isValid()) { if (!idx.isValid()) {
// The "<Edit>" case. inputNewExpression();
watchExpression(QString());
return; return;
} }
BaseTreeView::mouseDoubleClickEvent(ev); BaseTreeView::mouseDoubleClickEvent(ev);
@@ -921,12 +920,7 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
if (!act) { if (!act) {
; ;
} else if (act == &actInsertNewWatchItem) { } else if (act == &actInsertNewWatchItem) {
bool ok; inputNewExpression();
QString newExp = QInputDialog::getText(this, tr("Enter Expression for Evaluator"),
tr("Expression:"), QLineEdit::Normal,
QString(), &ok);
if (ok && !newExp.isEmpty())
watchExpression(newExp);
} else if (act == &actOpenMemoryEditAtObjectAddress) { } else if (act == &actOpenMemoryEditAtObjectAddress) {
addVariableMemoryView(currentEngine(), false, mi0, false, ev->globalPos(), this); addVariableMemoryView(currentEngine(), false, mi0, false, ev->globalPos(), this);
} else if (act == &actOpenMemoryEditAtPointerAddress) { } else if (act == &actOpenMemoryEditAtPointerAddress) {
@@ -1090,5 +1084,15 @@ void WatchTreeView::setModelData
model()->setData(index, value, role); 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 Internal
} // namespace Debugger } // namespace Debugger

View File

@@ -89,6 +89,7 @@ private:
bool event(QEvent *ev); bool event(QEvent *ev);
void currentChanged(const QModelIndex &current, const QModelIndex &previous); void currentChanged(const QModelIndex &current, const QModelIndex &previous);
void inputNewExpression();
void editItem(const QModelIndex &idx); void editItem(const QModelIndex &idx);
void resetHelper(const QModelIndex &idx); void resetHelper(const QModelIndex &idx);