aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/debugger/watchwindow.cpp
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-07-07 15:08:21 +0200
committerhjk <hjk121@nokiamail.com>2014-07-08 13:50:52 +0200
commit5fa89bcd547a3bc9710596d258dbf199320da06b (patch)
tree81b3ed247b747adbed8825619f8c1f242a5903a6 /src/plugins/debugger/watchwindow.cpp
parent0bab6e37b41985b649383323189c50fd862be7db (diff)
Debugger: Use a history completer for watched expressions
Some of them can be laborous to retype, so keep some history. Change-Id: Ibc12077f77fc5acc901c95001fb95bfb89763758 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/plugins/debugger/watchwindow.cpp')
-rw-r--r--src/plugins/debugger/watchwindow.cpp82
1 files changed, 76 insertions, 6 deletions
diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp
index b519c25322..7775c6e84d 100644
--- a/src/plugins/debugger/watchwindow.cpp
+++ b/src/plugins/debugger/watchwindow.cpp
@@ -60,6 +60,13 @@
#include <QScrollBar>
#include <QTimer>
+// For InputDialog, move to Utils?
+#include <coreplugin/helpmanager.h>
+#include <QLabel>
+#include <QVBoxLayout>
+#include <QButtonGroup>
+#include <QDialogButtonBox>
+
//#define USE_WATCH_MODEL_TEST 1
#if USE_WATCH_MODEL_TEST
@@ -1084,14 +1091,77 @@ void WatchTreeView::setModelData
model()->setData(index, value, role);
}
+
+// FIXME: Move to Utils?
+class InputDialog : public QDialog
+{
+public:
+ InputDialog()
+ {
+ m_label = new QLabel(this);
+ m_hint = new QLabel(this);
+ m_lineEdit = new Utils::FancyLineEdit(this);
+ m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel,
+ Qt::Horizontal, this);
+
+ auto layout = new QVBoxLayout(this);
+ layout->addWidget(m_label, Qt::AlignLeft);
+ layout->addWidget(m_hint, Qt::AlignLeft);
+ layout->addWidget(m_lineEdit);
+ layout->addSpacing(10);
+ layout->addWidget(m_buttons);
+ setLayout(layout);
+
+ connect(m_buttons, SIGNAL(accepted()), m_lineEdit, SLOT(onEditingFinished()));
+ connect(m_buttons, SIGNAL(accepted()), SLOT(accept()));
+ connect(m_buttons, SIGNAL(rejected()), SLOT(reject()));
+ connect(m_hint, SIGNAL(linkActivated(QString)),
+ Core::HelpManager::instance(), SLOT(handleHelpRequest(QString)));
+ }
+
+ void setLabelText(const QString &text)
+ {
+ m_label->setText(text);
+ }
+
+ void setHintText(const QString &text)
+ {
+ m_hint->setText(QString::fromLatin1("<html>%1</html>").arg(text));
+ }
+
+ void setHistoryCompleter(const QString &key)
+ {
+ m_lineEdit->setHistoryCompleter(key);
+ m_lineEdit->setText(QString()); // Undo "convenient" population with history item.
+ }
+
+ QString text() const
+ {
+ return m_lineEdit->text();
+ }
+
+public:
+ QLabel *m_label;
+ QLabel *m_hint;
+ Utils::FancyLineEdit *m_lineEdit;
+ QDialogButtonBox *m_buttons;
+};
+
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);
+ InputDialog dlg;
+ dlg.setWindowTitle(tr("New Evaluated Expression"));
+ dlg.setLabelText(tr("Enter an expression to evaluate."));
+ dlg.setHintText(tr("Note: Evaluators will be re-evaluated after each step. "
+ "For details check the <a href=\""
+ "qthelp://org.qt-project.qtcreator/doc/creator-debug-mode.html#locals-and-expressions"
+ "\">documentation</a>."));
+ dlg.setHistoryCompleter(QLatin1String("WatchItems"));
+ if (dlg.exec() == QDialog::Accepted) {
+ QString exp = dlg.text();
+ if (!exp.isEmpty())
+ watchExpression(exp, exp);
+ }
}
} // namespace Internal