Commit 46101b0b authored by Aurindam Jana's avatar Aurindam Jana Committed by hjk

Inspector: Update Editor on object selection

When an object is selected in the Inspector, the
Editor is updated to show the relevant code.

Task-number: QTCREATORBUG-8246

Change-Id: I4f7fbcccdeb22849682fa72c63e87a78f48d185b
Reviewed-by: default avatarhjk <qthjk@ovi.com>
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@digia.com>
parent 62b20005
......@@ -50,6 +50,8 @@ BaseTreeView::BaseTreeView(QWidget *parent)
connect(this, SIGNAL(activated(QModelIndex)),
SLOT(rowActivatedHelper(QModelIndex)));
connect(this, SIGNAL(clicked(QModelIndex)),
SLOT(rowClickedHelper(QModelIndex)));
connect(header(), SIGNAL(sectionClicked(int)),
SLOT(headerSectionClicked(int)));
......
......@@ -49,6 +49,7 @@ public:
void setModel(QAbstractItemModel *model);
virtual void rowActivated(const QModelIndex &) {}
virtual void rowClicked(const QModelIndex &) {}
void mousePressEvent(QMouseEvent *ev);
public slots:
......@@ -61,6 +62,7 @@ protected slots:
private slots:
void rowActivatedHelper(const QModelIndex &index) { rowActivated(index); }
void rowClickedHelper(const QModelIndex &index) { rowClicked(index); }
void headerSectionClicked(int logicalIndex);
private:
......
......@@ -1431,6 +1431,10 @@ void DebuggerEngine::updateWatchData(const WatchData &, const WatchUpdateFlags &
{
}
void DebuggerEngine::watchDataSelected(const QByteArray &iname)
{
}
void DebuggerEngine::watchPoint(const QPoint &)
{
}
......
......@@ -149,6 +149,8 @@ public:
virtual void updateWatchData(const Internal::WatchData &data,
const Internal::WatchUpdateFlags & flags = Internal::WatchUpdateFlags());
virtual void watchDataSelected(const QByteArray &iname);
virtual void startDebugger(DebuggerRunControl *runControl);
virtual void watchPoint(const QPoint &);
......
......@@ -35,6 +35,7 @@
#include "qmlengine.h"
#include "qtmessageloghandler.h"
#include "watchdata.h"
#include "watchhandler.h"
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
......@@ -135,6 +136,13 @@ void QmlCppEngine::updateWatchData(const WatchData &data,
d->m_activeEngine->updateWatchData(data, flags);
}
void QmlCppEngine::watchDataSelected(const QByteArray &iname)
{
const WatchData *wd = watchHandler()->findData(iname);
if (wd && wd->isInspect())
d->m_qmlEngine->watchDataSelected(iname);
}
void QmlCppEngine::watchPoint(const QPoint &point)
{
d->m_cppEngine->watchPoint(point);
......
......@@ -50,6 +50,7 @@ public:
TextEditor::ITextEditor * editor, const DebuggerToolTipContext &);
void updateWatchData(const WatchData &data,
const WatchUpdateFlags &flags);
void watchDataSelected(const QByteArray &iname);
void watchPoint(const QPoint &);
void fetchMemory(MemoryAgent *, QObject *, quint64 addr, quint64 length);
......
......@@ -1021,6 +1021,13 @@ void QmlEngine::updateWatchData(const WatchData &data,
watchHandler()->insertData(data);
}
void QmlEngine::watchDataSelected(const QByteArray &iname)
{
const WatchData *wd = watchHandler()->findData(iname);
if (wd && wd->isInspect())
m_inspectorAdapter.agent()->watchDataSelected(wd);
}
void QmlEngine::synchronizeWatchers()
{
QStringList watchedExpressions = watchHandler()->watchedExpressions();
......
......@@ -161,6 +161,7 @@ private:
bool supportsThreads() const { return false; }
void updateWatchData(const WatchData &data,
const WatchUpdateFlags &flags);
void watchDataSelected(const QByteArray &iname);
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
bool evaluateScriptExpression(const QString &expression);
......
......@@ -81,6 +81,8 @@ QmlInspectorAdapter::QmlInspectorAdapter(QmlAdapter *debugAdapter,
{
connect(m_agent, SIGNAL(objectFetched(QmlDebug::ObjectReference)),
SLOT(onObjectFetched(QmlDebug::ObjectReference)));
connect(m_agent, SIGNAL(jumpToObjectDefinition(QmlDebug::FileReference)),
SLOT(jumpToObjectDefinitionInEditor(QmlDebug::FileReference)));
QmlDebugConnection *connection = m_debugAdapter->connection();
DeclarativeEngineDebugClient *engineClient1
......@@ -467,7 +469,7 @@ void QmlInspectorAdapter::showConnectionStatusMessage(const QString &message)
m_engine->showMessage(_("QML Inspector: ") + message, LogStatus);
}
void QmlInspectorAdapter::gotoObjectReferenceDefinition(
void QmlInspectorAdapter::jumpToObjectDefinitionInEditor(
const FileReference &objSource)
{
if (m_cursorPositionChangedExternally) {
......@@ -502,7 +504,7 @@ void QmlInspectorAdapter::selectObject(const ObjectReference &obj,
QList<ObjectReference>() << obj);
if (target == EditorTarget)
gotoObjectReferenceDefinition(obj.source());
jumpToObjectDefinitionInEditor(obj.source());
if (!agent()->selectObjectInTree(obj.debugId()))
return;
......
......@@ -97,6 +97,7 @@ private slots:
void onReload();
void onReloaded();
void onDestroyedObject(int);
void jumpToObjectDefinitionInEditor(const QmlDebug::FileReference &objSource);
private:
void setActiveEngineClient(QmlDebug::BaseEngineDebugClient *client);
......@@ -104,8 +105,6 @@ private:
void initializePreviews();
void showConnectionStatusMessage(const QString &message);
void gotoObjectReferenceDefinition(const QmlDebug::FileReference &objSource);
enum SelectionTarget { NoTarget, ToolTarget, EditorTarget };
void selectObject(
const QmlDebug::ObjectReference &objectReference,
......
......@@ -121,6 +121,17 @@ void QmlInspectorAgent::updateWatchData(const WatchData &data)
}
}
void QmlInspectorAgent::watchDataSelected(const WatchData *data)
{
if (debug)
qDebug() << __FUNCTION__ << '(' << data->id << ')';
if (data->id) {
QTC_ASSERT(m_debugIdLocations.keys().contains(data->id), return);
emit jumpToObjectDefinition(m_debugIdLocations.value(data->id));
}
}
bool QmlInspectorAgent::selectObjectInTree(int debugId)
{
if (debug) {
......
......@@ -60,6 +60,7 @@ public:
void assignValue(const WatchData *data, const QString &expression, const QVariant &valueV);
void updateWatchData(const WatchData &data);
void watchDataSelected(const WatchData *data);
bool selectObjectInTree(int debugId);
quint32 setBindingForObject(int objectDebugId,
......@@ -101,6 +102,7 @@ signals:
void propertyChanged(int debugId, const QByteArray &propertyName,
const QVariant &propertyValue);
void automaticUpdateFailed();
void jumpToObjectDefinition(const QmlDebug::FileReference &objSource);
private slots:
void updateStatus();
......
......@@ -995,6 +995,11 @@ void WatchTreeView::setModel(QAbstractItemModel *model)
SLOT(handleItemIsExpanded(QModelIndex)));
}
void WatchTreeView::rowClicked(const QModelIndex &index)
{
currentEngine()->watchDataSelected(currentEngine()->watchHandler()->watchData(index)->iname);
}
void WatchTreeView::handleItemIsExpanded(const QModelIndex &idx)
{
bool on = idx.data(LocalsExpandedRole).toBool();
......
......@@ -51,6 +51,7 @@ public:
explicit WatchTreeView(Type type, QWidget *parent = 0);
Type type() const { return m_type; }
void setModel(QAbstractItemModel *model);
void rowClicked(const QModelIndex &index);
void reset();
public slots:
......
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