Commit 70bcccd6 authored by Aurindam Jana's avatar Aurindam Jana
Browse files

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: default avatarhjk <qthjk@ovi.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 8e7a1139
......@@ -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);
}
......
......@@ -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();
}
......
......@@ -87,6 +87,7 @@ public:
signals:
void stackChanged();
void currentIndexChanged();
private:
// QAbstractTableModel
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment