summaryrefslogtreecommitdiffstats
path: root/tools/qmldebugger
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-10-21 00:20:57 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-10-21 00:20:57 (GMT)
commit110c58a20f3158143d83ebea4f2ece4f7925f913 (patch)
tree1158730a379963ede7c8d9864dd05219803f00ab /tools/qmldebugger
parent85fe2b6ece1e590199bcf7960c1a40e816e81105 (diff)
downloadQt-110c58a20f3158143d83ebea4f2ece4f7925f913.zip
Qt-110c58a20f3158143d83ebea4f2ece4f7925f913.tar.gz
Qt-110c58a20f3158143d83ebea4f2ece4f7925f913.tar.bz2
Give more info about whether a value is null and its value type.
Diffstat (limited to 'tools/qmldebugger')
-rw-r--r--tools/qmldebugger/expressionquerywidget.cpp55
-rw-r--r--tools/qmldebugger/expressionquerywidget.h4
-rw-r--r--tools/qmldebugger/objectpropertiesview.cpp19
3 files changed, 58 insertions, 20 deletions
diff --git a/tools/qmldebugger/expressionquerywidget.cpp b/tools/qmldebugger/expressionquerywidget.cpp
index 90ab8ee..b29b465 100644
--- a/tools/qmldebugger/expressionquerywidget.cpp
+++ b/tools/qmldebugger/expressionquerywidget.cpp
@@ -16,7 +16,8 @@ ExpressionQueryWidget::ExpressionQueryWidget(QmlEngineDebug *client, QWidget *pa
m_query(0),
m_groupBox(0),
m_textEdit(new QTextEdit),
- m_lineEdit(0)
+ m_lineEdit(0),
+ m_button(0)
{
m_prompt = QLatin1String(">> ");
@@ -31,16 +32,19 @@ ExpressionQueryWidget::ExpressionQueryWidget(QmlEngineDebug *client, QWidget *pa
if (m_style == Compact) {
QHBoxLayout *hbox = new QHBoxLayout;
- QPushButton *button = new QPushButton(tr("Execute"));
- connect(button, SIGNAL(clicked()), SLOT(executeExpression()));
+ m_button = new QPushButton(tr("Execute"));
+ m_button->setEnabled(false);
+ connect(m_button, SIGNAL(clicked()), SLOT(executeExpression()));
m_lineEdit = new QLineEdit;
connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(executeExpression()));
+ connect(m_lineEdit, SIGNAL(textChanged(QString)), SLOT(lineEditTextChanged(QString)));
hbox->addWidget(new QLabel(tr("Expression:")));
hbox->addWidget(m_lineEdit);
- hbox->addWidget(button);
+ hbox->addWidget(m_button);
vbox->addLayout(hbox);
m_textEdit->setReadOnly(true);
+ m_lineEdit->installEventFilter(this);
} else {
m_textEdit->installEventFilter(this);
}
@@ -55,7 +59,7 @@ void ExpressionQueryWidget::updateTitle()
+ m_currObject.className() + QLatin1String(": ")
+ (m_currObject.name().isEmpty() ? QLatin1String("<unnamed>") : m_currObject.name())
+ QLatin1String(">");
- m_groupBox->setTitle(tr("Expression queries (current context: %1)"
+ m_groupBox->setTitle(tr("Expression queries (using context for %1)"
, "Selected object").arg(desc));
}
}
@@ -101,18 +105,20 @@ void ExpressionQueryWidget::executeExpression()
{
if (m_style == Compact)
m_expr = m_lineEdit->text().trimmed();
+ else
+ m_expr = m_expr.trimmed();
- if (!m_expr.trimmed().isEmpty() && m_currObject.debugId() != -1) {
- checkCurrentContext();
+ if (!m_expr.isEmpty() && m_currObject.debugId() != -1) {
if (m_query)
delete m_query;
- m_query = m_client->queryExpressionResult(m_currObject.debugId(), m_expr.trimmed(), this);
+ m_query = m_client->queryExpressionResult(m_currObject.debugId(), m_expr, this);
if (!m_query->isWaiting())
showResult();
else
QObject::connect(m_query, SIGNAL(stateChanged(State)),
this, SLOT(showResult()));
+ m_lastExpr = m_expr;
if (m_lineEdit)
m_lineEdit->clear();
}
@@ -122,9 +128,11 @@ void ExpressionQueryWidget::showResult()
{
if (m_query) {
m_textEdit->moveCursor(QTextCursor::End);
- QString result = m_query->result().toString();
- if (result.isEmpty())
+ QString result;
+ if (m_query->result().isNull())
result = QLatin1String("<no value>");
+ else
+ result = m_query->result().toString();
if (m_style == Compact) {
m_textEdit->setTextColor(Qt::black);
@@ -140,6 +148,12 @@ void ExpressionQueryWidget::showResult()
}
}
+void ExpressionQueryWidget::lineEditTextChanged(const QString &s)
+{
+ if (m_button)
+ m_button->setEnabled(!s.isEmpty());
+}
+
bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event)
{
if (obj == m_textEdit) {
@@ -176,6 +190,27 @@ bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event)
default:
break;
}
+ } else if (obj == m_lineEdit) {
+ switch (event->type()) {
+ case QEvent::KeyPress:
+ {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ int key = keyEvent->key();
+ if (key == Qt::Key_Up && m_lineEdit->text() != m_lastExpr) {
+ m_expr = m_lineEdit->text();
+ if (!m_lastExpr.isEmpty())
+ m_lineEdit->setText(m_lastExpr);
+ } else if (key == Qt::Key_Down) {
+ m_lineEdit->setText(m_expr);
+ }
+ break;
+ }
+ case QEvent::FocusIn:
+ checkCurrentContext();
+ break;
+ default:
+ break;
+ }
}
return QWidget::eventFilter(obj, event);
}
diff --git a/tools/qmldebugger/expressionquerywidget.h b/tools/qmldebugger/expressionquerywidget.h
index 3ea95ac..8db8f9f 100644
--- a/tools/qmldebugger/expressionquerywidget.h
+++ b/tools/qmldebugger/expressionquerywidget.h
@@ -10,6 +10,7 @@ QT_BEGIN_NAMESPACE
class QGroupBox;
class QTextEdit;
class QLineEdit;
+class QPushButton;
class ExpressionQueryWidget : public QWidget
{
@@ -31,6 +32,7 @@ public slots:
private slots:
void executeExpression();
void showResult();
+ void lineEditTextChanged(const QString &s);
private:
void appendPrompt();
@@ -45,8 +47,10 @@ private:
QGroupBox *m_groupBox;
QTextEdit *m_textEdit;
QLineEdit *m_lineEdit;
+ QPushButton *m_button;
QString m_prompt;
QString m_expr;
+ QString m_lastExpr;
QmlDebugObjectReference m_currObject;
QmlDebugObjectReference m_objectAtLastFocus;
diff --git a/tools/qmldebugger/objectpropertiesview.cpp b/tools/qmldebugger/objectpropertiesview.cpp
index 4a2f97d..61afe3f 100644
--- a/tools/qmldebugger/objectpropertiesview.cpp
+++ b/tools/qmldebugger/objectpropertiesview.cpp
@@ -22,12 +22,12 @@ public:
};
PropertiesViewItem::PropertiesViewItem(QTreeWidget *widget)
-: QTreeWidgetItem(widget)
+ : QTreeWidgetItem(widget)
{
}
PropertiesViewItem::PropertiesViewItem(QTreeWidgetItem *parent)
-: QTreeWidgetItem(parent)
+ : QTreeWidgetItem(parent)
{
}
@@ -108,8 +108,10 @@ void ObjectPropertiesView::setObject(const QmlDebugObjectReference &object)
item->setText(0, p.name());
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
- if (!p.hasNotifySignal())
+ if (!p.hasNotifySignal()) {
item->setForeground(0, Qt::gray);
+ item->setForeground(1, Qt::gray);
+ }
if (!p.binding().isEmpty()) {
PropertiesViewItem *binding = new PropertiesViewItem(item);
@@ -161,14 +163,11 @@ void ObjectPropertiesView::valueChanged(const QByteArray &name, const QVariant &
PropertiesViewItem *item = static_cast<PropertiesViewItem *>(m_tree->topLevelItem(i));
if (item->property.name() == name) {
if (value.isNull()) {
- item->setText(1, QLatin1String("null"));
- item->setForeground(1, Qt::gray);
+ item->setText(1, QLatin1String("<null>")
+ + QLatin1String(" : ")
+ + item->property.valueTypeName());
} else {
- QString s = value.toString();
- if (s.isEmpty())
- s = QString::fromUtf8(value.typeName());
- item->setText(1, s);
- item->setForeground(1, QBrush());
+ item->setText(1, value.toString());
}
}
}