forked from qt-creator/qt-creator
QmlJSInspector: Enable/Disable based on engine state
Change-Id: I078d12fb16fe61908e5b90ebf819c9fd9e8faae0 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -130,6 +130,7 @@ QmlCppEngine::~QmlCppEngine()
|
||||
bool QmlCppEngine::setToolTipExpression(const QPoint & mousePos,
|
||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &ctx)
|
||||
{
|
||||
//FIXIT:: This is broken!!
|
||||
return d->m_activeEngine->setToolTipExpression(mousePos, editor, ctx);
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ namespace Internal {
|
||||
class QtMessageLogItem;
|
||||
class QmlEnginePrivate;
|
||||
|
||||
class QmlEngine : public DebuggerEngine
|
||||
class DEBUGGER_EXPORT QmlEngine : public DebuggerEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -45,10 +45,9 @@
|
||||
#include <qmljs/parser/qmljsast_p.h>
|
||||
#include <qmljseditor/qmljseditorconstants.h>
|
||||
#include <qmljseditor/qmljseditor.h>
|
||||
#include <debugger/debuggerconstants.h>
|
||||
#include <debugger/debuggermainwindow.h>
|
||||
#include <debugger/debuggerplugin.h>
|
||||
#include <debugger/debuggerengine.h>
|
||||
#include <debugger/qml/qmlengine.h>
|
||||
#include <debugger/debuggerstartparameters.h>
|
||||
#include <debugger/qml/qmladapter.h>
|
||||
|
||||
@@ -137,7 +136,6 @@ InspectorUi::InspectorUi(QObject *parent)
|
||||
, m_propertyInspector(0)
|
||||
, m_settings(new InspectorSettings(this))
|
||||
, m_clientProxy(0)
|
||||
, m_qmlEngine(0)
|
||||
, m_debugQuery(0)
|
||||
, m_selectionCallbackExpected(false)
|
||||
, m_cursorPositionChangedExternally(false)
|
||||
@@ -169,23 +167,31 @@ void InspectorUi::restoreSettings()
|
||||
m_settings->restoreSettings(Core::ICore::settings());
|
||||
}
|
||||
|
||||
void InspectorUi::setDebuggerEngine(QObject *qmlEngine)
|
||||
void InspectorUi::setDebuggerEngine(QObject *engine)
|
||||
{
|
||||
if (m_qmlEngine && !qmlEngine) {
|
||||
disconnect(m_qmlEngine, SIGNAL(tooltipRequested(QPoint,TextEditor::ITextEditor*,int)),
|
||||
Debugger::Internal::QmlEngine *qmlEngine =
|
||||
qobject_cast<Debugger::Internal::QmlEngine *>(engine);
|
||||
QTC_ASSERT(qmlEngine, return);
|
||||
Debugger::DebuggerEngine *masterEngine = qmlEngine;
|
||||
if (qmlEngine->isSlaveEngine())
|
||||
masterEngine = qmlEngine->masterEngine();
|
||||
|
||||
connect(qmlEngine, SIGNAL(tooltipRequested(QPoint,TextEditor::ITextEditor*,int)),
|
||||
this, SLOT(showDebuggerTooltip(QPoint,TextEditor::ITextEditor*,int)));
|
||||
connect(masterEngine, SIGNAL(stateChanged(Debugger::DebuggerState)),
|
||||
this, SLOT(onEngineStateChanged(Debugger::DebuggerState)));
|
||||
}
|
||||
|
||||
m_qmlEngine = qmlEngine;
|
||||
if (m_qmlEngine) {
|
||||
connect(m_qmlEngine, SIGNAL(tooltipRequested(QPoint,TextEditor::ITextEditor*,int)),
|
||||
this, SLOT(showDebuggerTooltip(QPoint,TextEditor::ITextEditor*,int)));
|
||||
}
|
||||
}
|
||||
|
||||
QObject *InspectorUi::debuggerEngine() const
|
||||
void InspectorUi::onEngineStateChanged(Debugger::DebuggerState state)
|
||||
{
|
||||
return m_qmlEngine;
|
||||
bool enable = state == Debugger::InferiorRunOk;
|
||||
if (enable)
|
||||
m_toolBar->enable();
|
||||
else
|
||||
m_toolBar->disable();
|
||||
m_crumblePath->setEnabled(enable);
|
||||
m_propertyInspector->setContentsValid(enable);
|
||||
m_propertyInspector->reset();
|
||||
}
|
||||
|
||||
void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor,
|
||||
@@ -342,7 +348,6 @@ void InspectorUi::disconnected()
|
||||
disconnectSignals();
|
||||
disable();
|
||||
|
||||
m_qmlEngine = 0;
|
||||
resetViews();
|
||||
|
||||
applyChangesToQmlInspectorHelper(false);
|
||||
@@ -355,7 +360,6 @@ void InspectorUi::disconnected()
|
||||
m_clientProxy = 0;
|
||||
m_propertyInspector->clear();
|
||||
m_pendingPreviewDocumentNames.clear();
|
||||
setDebuggerEngine(0);
|
||||
}
|
||||
|
||||
void InspectorUi::onRootContext(const QVariant &value)
|
||||
@@ -399,6 +403,8 @@ void InspectorUi::updateEngineList()
|
||||
|
||||
void InspectorUi::changeSelectedItems(const QList<QmlDebugObjectReference> &objects)
|
||||
{
|
||||
if (!m_propertyInspector->contentsValid())
|
||||
return;
|
||||
if (m_selectionCallbackExpected) {
|
||||
m_selectionCallbackExpected = false;
|
||||
return;
|
||||
|
@@ -41,6 +41,8 @@
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||
|
||||
#include <debugger/debuggerconstants.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QObject>
|
||||
|
||||
@@ -100,7 +102,6 @@ public:
|
||||
void connected(ClientProxy *clientProxy);
|
||||
void disconnected();
|
||||
void setDebuggerEngine(QObject *qmlEngine);
|
||||
QObject *debuggerEngine() const;
|
||||
|
||||
signals:
|
||||
void statusMessage(const QString &text);
|
||||
@@ -133,6 +134,7 @@ private slots:
|
||||
|
||||
void updatePendingPreviewDocuments(QmlJS::Document::Ptr doc);
|
||||
void showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
|
||||
void onEngineStateChanged(Debugger::DebuggerState state);
|
||||
|
||||
private:
|
||||
void showRoot();
|
||||
@@ -161,7 +163,6 @@ private:
|
||||
|
||||
InspectorSettings *m_settings;
|
||||
ClientProxy *m_clientProxy;
|
||||
QObject *m_qmlEngine;
|
||||
quint32 m_debugQuery;
|
||||
quint32 m_showObjectQueryId;
|
||||
QList<quint32> m_updateObjectQueryIds;
|
||||
|
@@ -255,6 +255,30 @@ inline QString cleanPropertyValue(QString propertyValue)
|
||||
return propertyValue;
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// QmlJSPropertyInspectorModel
|
||||
// *************************************************************************
|
||||
QmlJSPropertyInspectorModel::QmlJSPropertyInspectorModel()
|
||||
: QStandardItemModel()
|
||||
, m_contentsValid(false)
|
||||
{
|
||||
}
|
||||
|
||||
Qt::ItemFlags QmlJSPropertyInspectorModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
return m_contentsValid ? QStandardItemModel::flags(index) : Qt::ItemFlags();
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspectorModel::setContentsValid(bool contentsValid)
|
||||
{
|
||||
m_contentsValid = contentsValid;
|
||||
}
|
||||
|
||||
bool QmlJSPropertyInspectorModel::contentsValid() const
|
||||
{
|
||||
return m_contentsValid;
|
||||
}
|
||||
|
||||
QmlJSPropertyInspector::QmlJSPropertyInspector(QWidget *parent)
|
||||
: QTreeView(parent)
|
||||
{
|
||||
@@ -285,6 +309,16 @@ void QmlJSPropertyInspector::clear()
|
||||
m_currentObjects.clear();
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::setContentsValid(bool contentsValid)
|
||||
{
|
||||
m_model.setContentsValid(contentsValid);
|
||||
}
|
||||
|
||||
bool QmlJSPropertyInspector::contentsValid() const
|
||||
{
|
||||
return m_model.contentsValid();
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::setCurrentObjects(const QList<QmlDebugObjectReference> &objectList)
|
||||
{
|
||||
if (objectList.isEmpty())
|
||||
|
@@ -92,6 +92,21 @@ private:
|
||||
QmlEditorWidgets::CustomColorDialog *m_mainFrame;
|
||||
};
|
||||
|
||||
class QmlJSPropertyInspectorModel : public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QmlJSPropertyInspectorModel();
|
||||
void setContentsValid(bool contentsValid);
|
||||
bool contentsValid() const;
|
||||
|
||||
protected:
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
private:
|
||||
bool m_contentsValid;
|
||||
};
|
||||
|
||||
class QmlJSPropertyInspector : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -107,6 +122,8 @@ public:
|
||||
|
||||
explicit QmlJSPropertyInspector(QWidget *parent = 0);
|
||||
void clear();
|
||||
void setContentsValid(bool contentsValid);
|
||||
bool contentsValid() const;
|
||||
|
||||
signals:
|
||||
void changePropertyValue(int debugId, QString propertyName, QString valueExpression);
|
||||
@@ -135,7 +152,7 @@ private:
|
||||
|
||||
void contextMenuEvent(QContextMenuEvent *ev);
|
||||
|
||||
QStandardItemModel m_model;
|
||||
QmlJSPropertyInspectorModel m_model;
|
||||
QList<int> m_currentObjects;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user