summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2012-01-16 12:38:33 +0100
committerAurindam Jana <aurindam.jana@nokia.com>2012-01-18 14:57:41 +0100
commit70bcccd646d2aeac3aabf9bc6c81ed42c563aeb2 (patch)
treec8a95c7269bb84843bbb69315713efb770ad5f6a /src
parent8e7a11392cd3c52a6d7038d16b949bf0927b9285 (diff)
downloadqt-creator-70bcccd646d2aeac3aabf9bc6c81ed42c563aeb2.tar.gz
ScriptConsole: Show current context
Show the current context in the script console. The expression in the script console is evaluated within this context. Change-Id: Ieb4cfc3e0892b150301f4ad79220cd878dee3ce3 Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/debugger/qml/qmljsscriptconsole.cpp17
-rw-r--r--src/plugins/debugger/stackhandler.cpp11
-rw-r--r--src/plugins/debugger/stackhandler.h1
3 files changed, 19 insertions, 10 deletions
diff --git a/src/plugins/debugger/qml/qmljsscriptconsole.cpp b/src/plugins/debugger/qml/qmljsscriptconsole.cpp
index 21fb2281ae..5098dcd8ec 100644
--- a/src/plugins/debugger/qml/qmljsscriptconsole.cpp
+++ b/src/plugins/debugger/qml/qmljsscriptconsole.cpp
@@ -49,6 +49,8 @@
#include <qmljsdebugclient/qdebugmessageclient.h>
#include <debugger/qml/qmlcppengine.h>
#include <debugger/qml/qmlengine.h>
+#include <debugger/stackhandler.h>
+#include <debugger/stackframe.h>
#include <QtGui/QMenu>
#include <QtGui/QTextBlock>
@@ -289,17 +291,19 @@ void QmlJSScriptConsole::setInferiorStopped(bool inferiorStopped)
onSelectionChanged();
}
-void QmlJSScriptConsole::setEngine(QmlEngine *engine)
+void QmlJSScriptConsole::setEngine(QmlEngine *eng)
{
if (d->adapter) {
+ disconnect(engine()->stackHandler(), SIGNAL(currentIndexChanged()), this, SLOT(onSelectionChanged()));
disconnect(d->adapter, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
disconnect(d->adapter->messageClient(), SIGNAL(message(QtMsgType,QString)),
this, SLOT(insertDebugOutput(QtMsgType,QString)));
d->adapter = 0;
}
- if (engine) {
- d->adapter = engine->adapter();
+ if (eng) {
+ d->adapter = eng->adapter();
+ connect(eng->stackHandler(), SIGNAL(currentIndexChanged()), this, SLOT(onSelectionChanged()));
connect(d->adapter, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(d->adapter->messageClient(), SIGNAL(message(QtMsgType,QString)),
this, SLOT(insertDebugOutput(QtMsgType,QString)));
@@ -308,7 +312,7 @@ void QmlJSScriptConsole::setEngine(QmlEngine *engine)
clear();
}
-DebuggerEngine * QmlJSScriptConsole::engine()
+DebuggerEngine *QmlJSScriptConsole::engine()
{
if (d->adapter) {
return d->adapter->debuggerEngine();
@@ -372,10 +376,11 @@ void QmlJSScriptConsole::onStateChanged(QmlJsDebugClient::QDeclarativeDebugQuery
void QmlJSScriptConsole::onSelectionChanged()
{
if (d->adapter) {
- QString status;
+ QString status(tr("Context: "));
if (!d->inferiorStopped) {
- status.append(tr("Current Selected Object: "));
status.append(d->adapter->currentSelectedDisplayName());
+ } else {
+ status.append(engine()->stackHandler()->currentFrame().function);
}
emit updateStatusMessage(status, 0);
}
diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp
index 37eb25d16a..d88acc41c1 100644
--- a/src/plugins/debugger/stackhandler.cpp
+++ b/src/plugins/debugger/stackhandler.cpp
@@ -62,7 +62,7 @@ StackHandler::StackHandler()
{
m_resetLocationScheduled = false;
m_contentsValid = false;
- m_currentIndex = 0;
+ m_currentIndex = -1;
m_canExpand = false;
connect(debuggerCore()->action(OperateByInstruction), SIGNAL(triggered()),
this, SLOT(resetModel()));
@@ -160,6 +160,8 @@ Qt::ItemFlags StackHandler::flags(const QModelIndex &index) const
StackFrame StackHandler::currentFrame() const
{
+ if (m_currentIndex == -1)
+ return StackFrame();
QTC_ASSERT(m_currentIndex >= 0, return StackFrame());
QTC_ASSERT(m_currentIndex < m_stackFrames.size(), return StackFrame());
return m_stackFrames.at(m_currentIndex);
@@ -167,7 +169,7 @@ StackFrame StackHandler::currentFrame() const
void StackHandler::setCurrentIndex(int level)
{
- if (level == m_currentIndex)
+ if (level == -1 || level == m_currentIndex)
return;
// Emit changed for previous frame
@@ -175,6 +177,7 @@ void StackHandler::setCurrentIndex(int level)
emit dataChanged(i, i);
m_currentIndex = level;
+ emit currentIndexChanged();
// Emit changed for new frame
i = index(m_currentIndex, 0);
@@ -184,7 +187,7 @@ void StackHandler::setCurrentIndex(int level)
void StackHandler::removeAll()
{
m_stackFrames.clear();
- m_currentIndex = 0;
+ setCurrentIndex(-1);
reset();
}
@@ -195,7 +198,7 @@ void StackHandler::setFrames(const StackFrames &frames, bool canExpand)
m_canExpand = canExpand;
m_stackFrames = frames;
if (m_currentIndex >= m_stackFrames.size())
- m_currentIndex = m_stackFrames.size() - 1;
+ setCurrentIndex(m_stackFrames.size() - 1);
reset();
emit stackChanged();
}
diff --git a/src/plugins/debugger/stackhandler.h b/src/plugins/debugger/stackhandler.h
index 2a29c523d3..afbe1410df 100644
--- a/src/plugins/debugger/stackhandler.h
+++ b/src/plugins/debugger/stackhandler.h
@@ -87,6 +87,7 @@ public:
signals:
void stackChanged();
+ void currentIndexChanged();
private:
// QAbstractTableModel