From 5dd261662ba0aa39b497ba941f283664173c2526 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 7 Jul 2014 10:33:38 +0200 Subject: [PATCH] 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 marker. Change-Id: I228801dc51f6d09ea9991b98399dc9ef04aa96c8 Reviewed-by: Christian Stenger --- share/qtcreator/debugger/dumper.py | 21 ++++++++------------- src/plugins/debugger/watchhandler.cpp | 6 +----- src/plugins/debugger/watchwindow.cpp | 20 ++++++++++++-------- src/plugins/debugger/watchwindow.h | 1 + 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index 19120442263..c610acb3713 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -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 case - self.putValue(" ") - self.putNoType() + try: + value = self.parseAndEvaluate(exp) + self.putItem(value) + except RuntimeError: + self.currentType.value = " " + self.currentValue.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 = "" - self.currentChildNumChild = -1 - self.currentNumChild = 0 - self.putNumChild(0) # Some "Enums" diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 6c8717ca8de..8c45d960f26 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -684,8 +684,6 @@ static QString quoteUnprintable(const QString &str) static QString translate(const QString &str) { if (str.startsWith(QLatin1Char('<'))) { - if (str == QLatin1String("")) - return WatchHandler::tr(""); if (str == QLatin1String("")) return WatchHandler::tr(""); if (str == QLatin1String("")) @@ -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(""); - 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; diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index d89513b5288..b519c253223 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -554,8 +554,7 @@ void WatchTreeView::mouseDoubleClickEvent(QMouseEvent *ev) { const QModelIndex idx = indexAt(ev->pos()); if (!idx.isValid()) { - // The "" 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 diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index 2e322dcb090..caeb68bef45 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -89,6 +89,7 @@ private: bool event(QEvent *ev); void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); + void inputNewExpression(); void editItem(const QModelIndex &idx); void resetHelper(const QModelIndex &idx);