forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -49,6 +49,8 @@
|
|||||||
#include <qmljsdebugclient/qdebugmessageclient.h>
|
#include <qmljsdebugclient/qdebugmessageclient.h>
|
||||||
#include <debugger/qml/qmlcppengine.h>
|
#include <debugger/qml/qmlcppengine.h>
|
||||||
#include <debugger/qml/qmlengine.h>
|
#include <debugger/qml/qmlengine.h>
|
||||||
|
#include <debugger/stackhandler.h>
|
||||||
|
#include <debugger/stackframe.h>
|
||||||
|
|
||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
#include <QtGui/QTextBlock>
|
#include <QtGui/QTextBlock>
|
||||||
@@ -289,17 +291,19 @@ void QmlJSScriptConsole::setInferiorStopped(bool inferiorStopped)
|
|||||||
onSelectionChanged();
|
onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSScriptConsole::setEngine(QmlEngine *engine)
|
void QmlJSScriptConsole::setEngine(QmlEngine *eng)
|
||||||
{
|
{
|
||||||
if (d->adapter) {
|
if (d->adapter) {
|
||||||
|
disconnect(engine()->stackHandler(), SIGNAL(currentIndexChanged()), this, SLOT(onSelectionChanged()));
|
||||||
disconnect(d->adapter, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
|
disconnect(d->adapter, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
|
||||||
disconnect(d->adapter->messageClient(), SIGNAL(message(QtMsgType,QString)),
|
disconnect(d->adapter->messageClient(), SIGNAL(message(QtMsgType,QString)),
|
||||||
this, SLOT(insertDebugOutput(QtMsgType,QString)));
|
this, SLOT(insertDebugOutput(QtMsgType,QString)));
|
||||||
d->adapter = 0;
|
d->adapter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (engine) {
|
if (eng) {
|
||||||
d->adapter = engine->adapter();
|
d->adapter = eng->adapter();
|
||||||
|
connect(eng->stackHandler(), SIGNAL(currentIndexChanged()), this, SLOT(onSelectionChanged()));
|
||||||
connect(d->adapter, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
|
connect(d->adapter, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
|
||||||
connect(d->adapter->messageClient(), SIGNAL(message(QtMsgType,QString)),
|
connect(d->adapter->messageClient(), SIGNAL(message(QtMsgType,QString)),
|
||||||
this, SLOT(insertDebugOutput(QtMsgType,QString)));
|
this, SLOT(insertDebugOutput(QtMsgType,QString)));
|
||||||
@@ -372,10 +376,11 @@ void QmlJSScriptConsole::onStateChanged(QmlJsDebugClient::QDeclarativeDebugQuery
|
|||||||
void QmlJSScriptConsole::onSelectionChanged()
|
void QmlJSScriptConsole::onSelectionChanged()
|
||||||
{
|
{
|
||||||
if (d->adapter) {
|
if (d->adapter) {
|
||||||
QString status;
|
QString status(tr("Context: "));
|
||||||
if (!d->inferiorStopped) {
|
if (!d->inferiorStopped) {
|
||||||
status.append(tr("Current Selected Object: "));
|
|
||||||
status.append(d->adapter->currentSelectedDisplayName());
|
status.append(d->adapter->currentSelectedDisplayName());
|
||||||
|
} else {
|
||||||
|
status.append(engine()->stackHandler()->currentFrame().function);
|
||||||
}
|
}
|
||||||
emit updateStatusMessage(status, 0);
|
emit updateStatusMessage(status, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ StackHandler::StackHandler()
|
|||||||
{
|
{
|
||||||
m_resetLocationScheduled = false;
|
m_resetLocationScheduled = false;
|
||||||
m_contentsValid = false;
|
m_contentsValid = false;
|
||||||
m_currentIndex = 0;
|
m_currentIndex = -1;
|
||||||
m_canExpand = false;
|
m_canExpand = false;
|
||||||
connect(debuggerCore()->action(OperateByInstruction), SIGNAL(triggered()),
|
connect(debuggerCore()->action(OperateByInstruction), SIGNAL(triggered()),
|
||||||
this, SLOT(resetModel()));
|
this, SLOT(resetModel()));
|
||||||
@@ -160,6 +160,8 @@ Qt::ItemFlags StackHandler::flags(const QModelIndex &index) const
|
|||||||
|
|
||||||
StackFrame StackHandler::currentFrame() const
|
StackFrame StackHandler::currentFrame() const
|
||||||
{
|
{
|
||||||
|
if (m_currentIndex == -1)
|
||||||
|
return StackFrame();
|
||||||
QTC_ASSERT(m_currentIndex >= 0, return StackFrame());
|
QTC_ASSERT(m_currentIndex >= 0, return StackFrame());
|
||||||
QTC_ASSERT(m_currentIndex < m_stackFrames.size(), return StackFrame());
|
QTC_ASSERT(m_currentIndex < m_stackFrames.size(), return StackFrame());
|
||||||
return m_stackFrames.at(m_currentIndex);
|
return m_stackFrames.at(m_currentIndex);
|
||||||
@@ -167,7 +169,7 @@ StackFrame StackHandler::currentFrame() const
|
|||||||
|
|
||||||
void StackHandler::setCurrentIndex(int level)
|
void StackHandler::setCurrentIndex(int level)
|
||||||
{
|
{
|
||||||
if (level == m_currentIndex)
|
if (level == -1 || level == m_currentIndex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Emit changed for previous frame
|
// Emit changed for previous frame
|
||||||
@@ -175,6 +177,7 @@ void StackHandler::setCurrentIndex(int level)
|
|||||||
emit dataChanged(i, i);
|
emit dataChanged(i, i);
|
||||||
|
|
||||||
m_currentIndex = level;
|
m_currentIndex = level;
|
||||||
|
emit currentIndexChanged();
|
||||||
|
|
||||||
// Emit changed for new frame
|
// Emit changed for new frame
|
||||||
i = index(m_currentIndex, 0);
|
i = index(m_currentIndex, 0);
|
||||||
@@ -184,7 +187,7 @@ void StackHandler::setCurrentIndex(int level)
|
|||||||
void StackHandler::removeAll()
|
void StackHandler::removeAll()
|
||||||
{
|
{
|
||||||
m_stackFrames.clear();
|
m_stackFrames.clear();
|
||||||
m_currentIndex = 0;
|
setCurrentIndex(-1);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +198,7 @@ void StackHandler::setFrames(const StackFrames &frames, bool canExpand)
|
|||||||
m_canExpand = canExpand;
|
m_canExpand = canExpand;
|
||||||
m_stackFrames = frames;
|
m_stackFrames = frames;
|
||||||
if (m_currentIndex >= m_stackFrames.size())
|
if (m_currentIndex >= m_stackFrames.size())
|
||||||
m_currentIndex = m_stackFrames.size() - 1;
|
setCurrentIndex(m_stackFrames.size() - 1);
|
||||||
reset();
|
reset();
|
||||||
emit stackChanged();
|
emit stackChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stackChanged();
|
void stackChanged();
|
||||||
|
void currentIndexChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// QAbstractTableModel
|
// QAbstractTableModel
|
||||||
|
|||||||
Reference in New Issue
Block a user