forked from qt-creator/qt-creator
QmlJSInspector: Fix line length
Change-Id: I483a970551e1747d037c9e0e4ec9332fe68cb49c Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -118,7 +118,8 @@ void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
|
||||
{
|
||||
QString serviceName;
|
||||
float version = 0;
|
||||
if (QDeclarativeDebugClient *client = qobject_cast<QDeclarativeDebugClient*>(sender())) {
|
||||
if (QDeclarativeDebugClient *client
|
||||
= qobject_cast<QDeclarativeDebugClient*>(sender())) {
|
||||
serviceName = client->name();
|
||||
version = client->serviceVersion();
|
||||
}
|
||||
@@ -134,7 +135,8 @@ QDeclarativeDebugClient *ClientProxy::qmlDebugger() const
|
||||
return m_engineClient;
|
||||
}
|
||||
|
||||
void ClientProxy::engineClientStatusChanged(QDeclarativeDebugClient::Status status)
|
||||
void ClientProxy::engineClientStatusChanged(
|
||||
QDeclarativeDebugClient::Status status)
|
||||
{
|
||||
if (status == QDeclarativeDebugClient::Enabled) {
|
||||
m_engineClient = qobject_cast<QmlEngineDebugClient *>(sender());
|
||||
@@ -167,8 +169,8 @@ void ClientProxy::onCurrentObjectsChanged(const QList<int> &debugIds,
|
||||
if (ref.debugId() != -1 && !ref.needsMoreData()) {
|
||||
selectedItems << ref;
|
||||
} else if (requestIfNeeded) {
|
||||
m_fetchCurrentObjectsQueryIds << fetchContextObject(
|
||||
QmlDebugObjectReference(debugId));
|
||||
m_fetchCurrentObjectsQueryIds
|
||||
<< fetchContextObject(QmlDebugObjectReference(debugId));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -176,10 +178,12 @@ void ClientProxy::onCurrentObjectsChanged(const QList<int> &debugIds,
|
||||
emit selectedItemsChanged(selectedItems);
|
||||
}
|
||||
|
||||
void ClientProxy::onCurrentObjectsFetched(quint32 queryId, const QVariant &result)
|
||||
void ClientProxy::onCurrentObjectsFetched(quint32 queryId,
|
||||
const QVariant &result)
|
||||
{
|
||||
m_fetchCurrentObjectsQueryIds.removeOne(queryId);
|
||||
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
||||
QmlDebugObjectReference obj
|
||||
= qvariant_cast<QmlDebugObjectReference>(result);
|
||||
m_fetchCurrentObjects.push_front(obj);
|
||||
|
||||
if (!getObjectHierarchy(obj))
|
||||
@@ -200,8 +204,8 @@ bool ClientProxy::getObjectHierarchy(const QmlDebugObjectReference &obj)
|
||||
|
||||
//for other objects
|
||||
if (parent.debugId() == -1 || parent.needsMoreData()) {
|
||||
m_fetchCurrentObjectsQueryIds << fetchContextObject(
|
||||
QmlDebugObjectReference(obj.parentId()));
|
||||
m_fetchCurrentObjectsQueryIds
|
||||
<< fetchContextObject(QmlDebugObjectReference(obj.parentId()));
|
||||
} else {
|
||||
return getObjectHierarchy(parent);
|
||||
}
|
||||
@@ -230,7 +234,8 @@ void ClientProxy::setSelectedItemsByObjectId(
|
||||
}
|
||||
}
|
||||
|
||||
void ClientProxy::addObjectToTree(const QmlDebugObjectReference &obj, bool notify)
|
||||
void ClientProxy::addObjectToTree(const QmlDebugObjectReference &obj,
|
||||
bool notify)
|
||||
{
|
||||
int count = m_rootObjects.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
@@ -245,7 +250,7 @@ void ClientProxy::addObjectToTree(const QmlDebugObjectReference &obj, bool notif
|
||||
|
||||
QmlDebugObjectReference ClientProxy::objectReferenceForId(int debugId) const
|
||||
{
|
||||
foreach (const QmlDebugObjectReference& it, m_rootObjects) {
|
||||
foreach (const QmlDebugObjectReference &it, m_rootObjects) {
|
||||
QmlDebugObjectReference result = objectReferenceForId(debugId, it);
|
||||
if (result.debugId() == debugId)
|
||||
return result;
|
||||
@@ -274,8 +279,9 @@ QmlJSInspector::Internal::ClientProxy::rootObjectReference() const
|
||||
}
|
||||
|
||||
QmlDebugObjectReference
|
||||
ClientProxy::objectReferenceForId(int debugId,
|
||||
const QmlDebugObjectReference &objectRef) const
|
||||
ClientProxy::objectReferenceForId(
|
||||
int debugId,
|
||||
const QmlDebugObjectReference &objectRef) const
|
||||
{
|
||||
if (objectRef.debugId() == debugId)
|
||||
return objectRef;
|
||||
@@ -307,7 +313,8 @@ QmlDebugObjectReference ClientProxy::objectReferenceForLocation(
|
||||
{
|
||||
const QList<QmlDebugObjectReference> refs = objectReferences();
|
||||
foreach (const QmlDebugObjectReference &ref, refs) {
|
||||
if (ref.source().lineNumber() == line && ref.source().columnNumber() == column)
|
||||
if (ref.source().lineNumber() == line
|
||||
&& ref.source().columnNumber() == column)
|
||||
return ref;
|
||||
}
|
||||
|
||||
@@ -389,7 +396,7 @@ quint32 ClientProxy::setMethodBodyForObject(int objectDebugId,
|
||||
}
|
||||
|
||||
quint32 ClientProxy::resetBindingForObject(int objectDebugId,
|
||||
const QString& propertyName)
|
||||
const QString &propertyName)
|
||||
{
|
||||
if (objectDebugId == -1)
|
||||
return false;
|
||||
@@ -424,7 +431,8 @@ quint32 ClientProxy::queryExpressionResult(int objectDebugId,
|
||||
|
||||
log(LogSend, QString("EVAL_EXPRESSION %1 %2").arg(
|
||||
QString::number(objectDebugId), expr));
|
||||
quint32 queryId = m_engineClient->queryExpressionResult(objectDebugId, expr);
|
||||
quint32 queryId
|
||||
= m_engineClient->queryExpressionResult(objectDebugId, expr);
|
||||
|
||||
if (m_adapter)
|
||||
m_adapter.data()->disableJsDebugging(block);
|
||||
@@ -510,7 +518,8 @@ void ClientProxy::queryEngineContext(int id)
|
||||
|
||||
log(LogSend, QString("LIST_OBJECTS %1").arg(QString::number(id)));
|
||||
|
||||
m_contextQueryId = m_engineClient->queryRootContexts(QmlDebugEngineReference(id));
|
||||
m_contextQueryId
|
||||
= m_engineClient->queryRootContexts(QmlDebugEngineReference(id));
|
||||
}
|
||||
|
||||
void ClientProxy::contextChanged(const QVariant &value)
|
||||
@@ -522,7 +531,7 @@ void ClientProxy::contextChanged(const QVariant &value)
|
||||
}
|
||||
}
|
||||
|
||||
quint32 ClientProxy::fetchContextObject(const QmlDebugObjectReference& obj)
|
||||
quint32 ClientProxy::fetchContextObject(const QmlDebugObjectReference &obj)
|
||||
{
|
||||
if (!isConnected())
|
||||
return 0;
|
||||
@@ -532,7 +541,7 @@ quint32 ClientProxy::fetchContextObject(const QmlDebugObjectReference& obj)
|
||||
}
|
||||
|
||||
void ClientProxy::fetchRootObjects(
|
||||
const QmlDebugContextReference& context, bool clear)
|
||||
const QmlDebugContextReference &context, bool clear)
|
||||
{
|
||||
if (!isConnected())
|
||||
return;
|
||||
@@ -555,25 +564,28 @@ void ClientProxy::fetchRootObjects(
|
||||
if (queryId)
|
||||
m_objectTreeQueryIds << queryId;
|
||||
}
|
||||
foreach (const QmlDebugContextReference& child, context.contexts()) {
|
||||
foreach (const QmlDebugContextReference &child, context.contexts()) {
|
||||
fetchRootObjects(child, false);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientProxy::insertObjectInTreeIfNeeded(const QmlDebugObjectReference &object)
|
||||
void ClientProxy::insertObjectInTreeIfNeeded(
|
||||
const QmlDebugObjectReference &object)
|
||||
{
|
||||
if (!m_rootObjects.contains(object))
|
||||
return;
|
||||
int count = m_rootObjects.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (m_rootObjects[i].parentId() < 0 && m_rootObjects[i].insertObjectInTree(object)) {
|
||||
if (m_rootObjects[i].parentId() < 0
|
||||
&& m_rootObjects[i].insertObjectInTree(object)) {
|
||||
m_rootObjects.removeOne(object);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClientProxy::onResult(quint32 queryId, const QVariant &value, const QByteArray &type)
|
||||
void ClientProxy::onResult(quint32 queryId, const QVariant &value,
|
||||
const QByteArray &type)
|
||||
{
|
||||
if (type == "FETCH_OBJECT_R") {
|
||||
log(LogReceive, QString("FETCH_OBJECT_R %1").arg(
|
||||
@@ -596,7 +608,8 @@ void ClientProxy::onResult(quint32 queryId, const QVariant &value, const QByteAr
|
||||
|
||||
void ClientProxy::objectTreeFetched(quint32 queryId, const QVariant &result)
|
||||
{
|
||||
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
||||
QmlDebugObjectReference obj
|
||||
= qvariant_cast<QmlDebugObjectReference>(result);
|
||||
m_rootObjects.append(obj);
|
||||
|
||||
m_objectTreeQueryIds.removeOne(queryId);
|
||||
@@ -610,14 +623,15 @@ void ClientProxy::objectTreeFetched(quint32 queryId, const QVariant &result)
|
||||
|
||||
if (isConnected()) {
|
||||
if (!m_inspectorClient->currentObjects().isEmpty())
|
||||
onCurrentObjectsChanged(m_inspectorClient->currentObjects(), false);
|
||||
onCurrentObjectsChanged(m_inspectorClient->currentObjects(),
|
||||
false);
|
||||
|
||||
m_inspectorClient->setObjectIdList(m_rootObjects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClientProxy::buildDebugIdHashRecursive(const QmlDebugObjectReference& ref)
|
||||
void ClientProxy::buildDebugIdHashRecursive(const QmlDebugObjectReference &ref)
|
||||
{
|
||||
QUrl fileUrl = ref.source().url();
|
||||
int lineNum = ref.source().lineNumber();
|
||||
@@ -633,7 +647,8 @@ void ClientProxy::buildDebugIdHashRecursive(const QmlDebugObjectReference& ref)
|
||||
lineNum += rx.cap(3).toInt() - 1;
|
||||
}
|
||||
|
||||
const QString filePath = InspectorUi::instance()->findFileInProject(fileUrl);
|
||||
const QString filePath
|
||||
= InspectorUi::instance()->findFileInProject(fileUrl);
|
||||
|
||||
// append the debug ids in the hash
|
||||
m_debugIdHash[qMakePair<QString, int>(filePath, rev)][qMakePair<int, int>(
|
||||
|
||||
@@ -45,7 +45,8 @@ class QmlAdapter;
|
||||
namespace QmlJSInspector {
|
||||
|
||||
//map <filename, editorRevision> -> <lineNumber, columnNumber> -> debugIds
|
||||
typedef QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > > DebugIdHash;
|
||||
typedef
|
||||
QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > > DebugIdHash;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@@ -67,8 +68,10 @@ public:
|
||||
QString source,
|
||||
int line);
|
||||
|
||||
quint32 setMethodBodyForObject(int objectDebugId, const QString &methodName, const QString &methodBody);
|
||||
quint32 resetBindingForObject(int objectDebugId, const QString &propertyName);
|
||||
quint32 setMethodBodyForObject(int objectDebugId, const QString &methodName,
|
||||
const QString &methodBody);
|
||||
quint32 resetBindingForObject(int objectDebugId,
|
||||
const QString &propertyName);
|
||||
quint32 queryExpressionResult(int objectDebugId, const QString &expr);
|
||||
void clearComponentCache();
|
||||
|
||||
@@ -81,14 +84,16 @@ public:
|
||||
QList<QmlDebugObjectReference> objectReferences() const;
|
||||
QmlDebugObjectReference objectReferenceForId(int debugId) const;
|
||||
QmlDebugObjectReference objectReferenceForId(const QString &objectId) const;
|
||||
QmlDebugObjectReference objectReferenceForLocation(int line, int column) const;
|
||||
QmlDebugObjectReference objectReferenceForLocation(int line,
|
||||
int column) const;
|
||||
QList<QmlDebugObjectReference> rootObjectReference() const;
|
||||
DebugIdHash debugIdHash() const { return m_debugIdHash; }
|
||||
|
||||
bool isConnected() const;
|
||||
|
||||
void setSelectedItemsByDebugId(const QList<int> &debugIds);
|
||||
void setSelectedItemsByObjectId(const QList<QmlDebugObjectReference> &objectRefs);
|
||||
void setSelectedItemsByObjectId(
|
||||
const QList<QmlDebugObjectReference> &objectRefs);
|
||||
|
||||
QList<QmlDebugEngineReference> engines() const;
|
||||
|
||||
@@ -108,7 +113,8 @@ signals:
|
||||
void aboutToReloadEngines();
|
||||
void enginesChanged();
|
||||
|
||||
void selectedItemsChanged(const QList<QmlDebugObjectReference> &selectedItems);
|
||||
void selectedItemsChanged(
|
||||
const QList<QmlDebugObjectReference> &selectedItems);
|
||||
|
||||
void connected();
|
||||
void disconnected();
|
||||
@@ -121,7 +127,8 @@ signals:
|
||||
void designModeBehaviorChanged(bool inDesignMode);
|
||||
void showAppOnTopChanged(bool showAppOnTop);
|
||||
void serverReloaded();
|
||||
void propertyChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
||||
void propertyChanged(int debugId, const QByteArray &propertyName,
|
||||
const QVariant &propertyValue);
|
||||
|
||||
void result(quint32 queryId, const QVariant &result);
|
||||
void rootContext(const QVariant &context);
|
||||
@@ -139,7 +146,8 @@ public slots:
|
||||
void changeToSelectMarqueeTool();
|
||||
void showAppOnTop(bool showOnTop);
|
||||
void createQmlObject(const QString &qmlText, int parentDebugId,
|
||||
const QStringList &imports, const QString &filename = QString(), int order = 0);
|
||||
const QStringList &imports,
|
||||
const QString &filename = QString(), int order = 0);
|
||||
void destroyQmlObject(int debugId);
|
||||
void reparentQmlObject(int debugId, int newParent);
|
||||
|
||||
@@ -148,10 +156,13 @@ private slots:
|
||||
void clientStatusChanged(QDeclarativeDebugClient::Status status);
|
||||
void engineClientStatusChanged(QDeclarativeDebugClient::Status status);
|
||||
|
||||
void onCurrentObjectsChanged(const QList<int> &debugIds, bool requestIfNeeded = true);
|
||||
void onCurrentObjectsChanged(const QList<int> &debugIds,
|
||||
bool requestIfNeeded = true);
|
||||
void newObjects();
|
||||
void objectWatchTriggered(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
||||
void onResult(quint32 queryId, const QVariant &value, const QByteArray &type);
|
||||
void objectWatchTriggered(int debugId, const QByteArray &propertyName,
|
||||
const QVariant &propertyValue);
|
||||
void onResult(quint32 queryId, const QVariant &value,
|
||||
const QByteArray &type);
|
||||
void onCurrentObjectsFetched(quint32 queryId, const QVariant &result);
|
||||
|
||||
private:
|
||||
@@ -162,8 +173,11 @@ private:
|
||||
void reloadEngines();
|
||||
bool getObjectHierarchy(const QmlDebugObjectReference &obj);
|
||||
|
||||
QList<QmlDebugObjectReference> objectReferences(const QmlDebugObjectReference &objectRef) const;
|
||||
QmlDebugObjectReference objectReferenceForId(int debugId, const QmlDebugObjectReference &ref) const;
|
||||
QList<QmlDebugObjectReference> objectReferences(
|
||||
const QmlDebugObjectReference &objectRef) const;
|
||||
QmlDebugObjectReference objectReferenceForId(
|
||||
int debugId,
|
||||
const QmlDebugObjectReference &ref) const;
|
||||
|
||||
enum LogDirection {
|
||||
LogSend,
|
||||
|
||||
@@ -44,7 +44,8 @@ ContextCrumblePath::ContextCrumblePath(QWidget *parent)
|
||||
updateContextPath(QStringList(), QList<int>());
|
||||
}
|
||||
|
||||
void ContextCrumblePath::updateContextPath(const QStringList &path, const QList<int> &debugIds)
|
||||
void ContextCrumblePath::updateContextPath(const QStringList &path,
|
||||
const QList<int> &debugIds)
|
||||
{
|
||||
Q_ASSERT(path.count() == debugIds.count());
|
||||
|
||||
@@ -59,7 +60,8 @@ void ContextCrumblePath::updateContextPath(const QStringList &path, const QList<
|
||||
}
|
||||
}
|
||||
|
||||
void ContextCrumblePath::addChildren(const QStringList &childrenNames, const QList<int> &childrenDebugIds)
|
||||
void ContextCrumblePath::addChildren(const QStringList &childrenNames,
|
||||
const QList<int> &childrenDebugIds)
|
||||
{
|
||||
Q_ASSERT(childrenNames.count() == childrenDebugIds.count());
|
||||
for (int i = 0; i < childrenNames.count(); i++)
|
||||
|
||||
@@ -50,7 +50,8 @@ public:
|
||||
|
||||
public slots:
|
||||
void updateContextPath(const QStringList &path, const QList<int> &debugIds);
|
||||
void addChildren(const QStringList &childrenNames, const QList<int> &childrenDebugIds);
|
||||
void addChildren(const QStringList &childrenNames,
|
||||
const QList<int> &childrenDebugIds);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
|
||||
@@ -124,7 +124,9 @@ InspectorUi *InspectorUi::m_instance = 0;
|
||||
|
||||
QmlJS::ModelManagerInterface *modelManager()
|
||||
{
|
||||
return ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>();
|
||||
ExtensionSystem::PluginManager *pm
|
||||
= ExtensionSystem::PluginManager::instance();
|
||||
return pm->getObject<QmlJS::ModelManagerInterface>();
|
||||
}
|
||||
|
||||
InspectorUi::InspectorUi(QObject *parent)
|
||||
@@ -175,8 +177,10 @@ void InspectorUi::setDebuggerEngine(QObject *engine)
|
||||
if (qmlEngine->isSlaveEngine())
|
||||
masterEngine = qmlEngine->masterEngine();
|
||||
|
||||
connect(qmlEngine, SIGNAL(tooltipRequested(QPoint,TextEditor::ITextEditor*,int)),
|
||||
this, SLOT(showDebuggerTooltip(QPoint,TextEditor::ITextEditor*,int)));
|
||||
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)));
|
||||
}
|
||||
@@ -202,20 +206,25 @@ QmlJSTools::SemanticInfo getSemanticInfo(QPlainTextEdit *qmlJSTextEdit)
|
||||
QTC_ASSERT(QLatin1String(qmlJSTextEdit->metaObject()->className())
|
||||
== QLatin1String("QmlJSEditor::QmlJSTextEditorWidget"),
|
||||
return info);
|
||||
QTC_ASSERT(qmlJSTextEdit->metaObject()->indexOfProperty("semanticInfo") != -1, return info);
|
||||
QTC_ASSERT(qmlJSTextEdit->metaObject()->indexOfProperty("semanticInfo")
|
||||
!= -1, return info);
|
||||
|
||||
info = qmlJSTextEdit->property("semanticInfo").value<QmlJSTools::SemanticInfo>();
|
||||
info = qmlJSTextEdit->property("semanticInfo")
|
||||
.value<QmlJSTools::SemanticInfo>();
|
||||
return info;
|
||||
}
|
||||
|
||||
void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor,
|
||||
void InspectorUi::showDebuggerTooltip(const QPoint &mousePos,
|
||||
TextEditor::ITextEditor *editor,
|
||||
int cursorPos)
|
||||
{
|
||||
Q_UNUSED(mousePos);
|
||||
if (m_clientProxy && editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||
if (m_clientProxy && editor->id()
|
||||
== QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||
TextEditor::BaseTextEditor *baseTextEditor =
|
||||
static_cast<TextEditor::BaseTextEditor*>(editor);
|
||||
QPlainTextEdit *editWidget = qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
|
||||
QPlainTextEdit *editWidget
|
||||
= qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
|
||||
|
||||
QmlJSTools::SemanticInfo semanticInfo = getSemanticInfo(editWidget);
|
||||
|
||||
@@ -235,7 +244,8 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE
|
||||
QmlDebugObjectReference ref;
|
||||
if (QmlJS::AST::Node *node
|
||||
= semanticInfo.declaringMemberNoProperties(cursorPos)) {
|
||||
if (QmlJS::AST::UiObjectMember *objMember = node->uiObjectMemberCast()) {
|
||||
if (QmlJS::AST::UiObjectMember *objMember
|
||||
= node->uiObjectMemberCast()) {
|
||||
ref = m_clientProxy->objectReferenceForLocation(
|
||||
objMember->firstSourceLocation().startLine,
|
||||
objMember->firstSourceLocation().startColumn);
|
||||
@@ -248,33 +258,41 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE
|
||||
if (wordAtCursor == QString("id")) {
|
||||
query = QString("\"id:") + ref.idString() + doubleQuote;
|
||||
} else {
|
||||
if ((qmlNode->kind == QmlJS::AST::Node::Kind_IdentifierExpression) ||
|
||||
(qmlNode->kind == QmlJS::AST::Node::Kind_FieldMemberExpression)) {
|
||||
tc.setPosition(qmlNode->expressionCast()->firstSourceLocation().begin());
|
||||
tc.setPosition(qmlNode->expressionCast()->lastSourceLocation().end(),
|
||||
using namespace QmlJS::AST;
|
||||
if ((qmlNode->kind == Node::Kind_IdentifierExpression) ||
|
||||
(qmlNode->kind == Node::Kind_FieldMemberExpression)) {
|
||||
ExpressionNode *expressionNode = qmlNode->expressionCast();
|
||||
tc.setPosition(expressionNode->firstSourceLocation().begin());
|
||||
tc.setPosition(expressionNode->lastSourceLocation().end(),
|
||||
QTextCursor::KeepAnchor);
|
||||
QString refToLook = tc.selectedText();
|
||||
if ((qmlNode->kind == QmlJS::AST::Node::Kind_IdentifierExpression) &&
|
||||
(m_clientProxy->objectReferenceForId(refToLook).debugId() == -1)) {
|
||||
query = doubleQuote + QString("local: ") + refToLook + doubleQuote;
|
||||
foreach (const QmlDebugPropertyReference &property, ref.properties()) {
|
||||
if ((qmlNode->kind == ::Node::Kind_IdentifierExpression) &&
|
||||
(m_clientProxy->objectReferenceForId(refToLook).debugId()
|
||||
== -1)) {
|
||||
query = doubleQuote + QString("local: ") + refToLook
|
||||
+ doubleQuote;
|
||||
foreach (const QmlDebugPropertyReference &property,
|
||||
ref.properties()) {
|
||||
if (property.name() == wordAtCursor
|
||||
&& !property.valueTypeName().isEmpty()) {
|
||||
query = doubleQuote + property.name() + QLatin1Char(':')
|
||||
+ doubleQuote + QLatin1Char('+') + property.name();
|
||||
query = doubleQuote + property.name()
|
||||
+ QLatin1Char(':') + doubleQuote
|
||||
+ QLatin1Char('+') + property.name();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
query = doubleQuote + refToLook + QLatin1Char(':') + doubleQuote
|
||||
+ QLatin1Char('+') + refToLook;
|
||||
query = doubleQuote + refToLook + QLatin1Char(':')
|
||||
+ doubleQuote + QLatin1Char('+') + refToLook;
|
||||
} else {
|
||||
// show properties
|
||||
foreach (const QmlDebugPropertyReference &property, ref.properties()) {
|
||||
if (property.name() == wordAtCursor && !property.valueTypeName().isEmpty()) {
|
||||
if (property.name() == wordAtCursor
|
||||
&& !property.valueTypeName().isEmpty()) {
|
||||
query = doubleQuote + property.name() + QLatin1Char(':')
|
||||
+ doubleQuote + QLatin1Char('+') + property.name();
|
||||
+ doubleQuote + QLatin1Char('+')
|
||||
+ property.name();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -282,7 +300,8 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE
|
||||
}
|
||||
|
||||
if (!query.isEmpty()) {
|
||||
m_debugQuery = m_clientProxy->queryExpressionResult(ref.debugId(), query);
|
||||
m_debugQuery
|
||||
= m_clientProxy->queryExpressionResult(ref.debugId(), query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,7 +310,8 @@ void InspectorUi::onResult(quint32 queryId, const QVariant &result)
|
||||
{
|
||||
if (m_showObjectQueryId == queryId) {
|
||||
m_showObjectQueryId = 0;
|
||||
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
||||
QmlDebugObjectReference obj
|
||||
= qvariant_cast<QmlDebugObjectReference>(result);
|
||||
m_clientProxy->addObjectToTree(obj);
|
||||
if (m_onCrumblePathClicked) {
|
||||
m_onCrumblePathClicked = false;
|
||||
@@ -302,7 +322,8 @@ void InspectorUi::onResult(quint32 queryId, const QVariant &result)
|
||||
|
||||
if (m_updateObjectQueryIds.contains(queryId)) {
|
||||
m_updateObjectQueryIds.removeOne(queryId);
|
||||
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
|
||||
QmlDebugObjectReference obj
|
||||
= qvariant_cast<QmlDebugObjectReference>(result);
|
||||
m_clientProxy->addObjectToTree(obj);
|
||||
if (m_updateObjectQueryIds.empty())
|
||||
showObject(obj);
|
||||
@@ -333,21 +354,26 @@ void InspectorUi::connected(ClientProxy *clientProxy)
|
||||
connect(m_clientProxy, SIGNAL(result(quint32,QVariant)),
|
||||
SLOT(onResult(quint32,QVariant)));
|
||||
using namespace QmlJsDebugClient::Constants;
|
||||
if (m_clientProxy->qmlDebugger()->objectName() == QML_DEBUGGER &&
|
||||
m_clientProxy->qmlDebugger()->serviceVersion() >= CURRENT_SUPPORTED_VERSION)
|
||||
if (m_clientProxy->qmlDebugger()->objectName() == QML_DEBUGGER
|
||||
&& m_clientProxy->qmlDebugger()->serviceVersion()
|
||||
>= CURRENT_SUPPORTED_VERSION)
|
||||
m_toolBar->setZoomToolEnabled(false);
|
||||
else
|
||||
m_toolBar->setZoomToolEnabled(true);
|
||||
QmlJS::Snapshot snapshot = modelManager()->snapshot();
|
||||
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it = m_textPreviews.constBegin();
|
||||
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it
|
||||
= m_textPreviews.constBegin();
|
||||
it != m_textPreviews.constEnd(); ++it) {
|
||||
Document::Ptr doc = snapshot.document(it.key());
|
||||
it.value()->resetInitialDoc(doc);
|
||||
}
|
||||
|
||||
if (Debugger::DebuggerEngine *debuggerEngine = clientProxy->qmlAdapter()->debuggerEngine()) {
|
||||
m_projectFinder.setProjectDirectory(debuggerEngine->startParameters().projectSourceDirectory);
|
||||
m_projectFinder.setProjectFiles(debuggerEngine->startParameters().projectSourceFiles);
|
||||
if (Debugger::DebuggerEngine *debuggerEngine
|
||||
= clientProxy->qmlAdapter()->debuggerEngine()) {
|
||||
m_projectFinder.setProjectDirectory(
|
||||
debuggerEngine->startParameters().projectSourceDirectory);
|
||||
m_projectFinder.setProjectFiles(
|
||||
debuggerEngine->startParameters().projectSourceFiles);
|
||||
m_projectFinder.setSysroot(debuggerEngine->startParameters().sysroot);
|
||||
}
|
||||
|
||||
@@ -392,8 +418,9 @@ void InspectorUi::onRootContext(const QVariant &value)
|
||||
value), true);
|
||||
} else {
|
||||
for (int i = 1; i < m_crumblePath->length(); i++) {
|
||||
m_updateObjectQueryIds << m_clientProxy->fetchContextObject(
|
||||
m_crumblePath->dataForIndex(i).toInt());
|
||||
m_updateObjectQueryIds
|
||||
<< m_clientProxy->fetchContextObject(
|
||||
m_crumblePath->dataForIndex(i).toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,7 +450,8 @@ void InspectorUi::updateEngineList()
|
||||
}
|
||||
}
|
||||
|
||||
void InspectorUi::changeSelectedItems(const QList<QmlDebugObjectReference> &objects)
|
||||
void InspectorUi::changeSelectedItems(
|
||||
const QList<QmlDebugObjectReference> &objects)
|
||||
{
|
||||
if (!m_propertyInspector->contentsValid())
|
||||
return;
|
||||
@@ -433,10 +461,12 @@ void InspectorUi::changeSelectedItems(const QList<QmlDebugObjectReference> &obje
|
||||
}
|
||||
m_cursorPositionChangedExternally = true;
|
||||
|
||||
// QmlJSLiveTextPreview doesn't provide valid references, only correct debugIds. We need to remap them
|
||||
// QmlJSLiveTextPreview doesn't provide valid references, only correct
|
||||
// debugIds. We need to remap them
|
||||
QList <QmlDebugObjectReference> realList;
|
||||
foreach (const QmlDebugObjectReference &obj, objects) {
|
||||
QmlDebugObjectReference clientRef = m_clientProxy->objectReferenceForId(obj.debugId());
|
||||
QmlDebugObjectReference clientRef
|
||||
= m_clientProxy->objectReferenceForId(obj.debugId());
|
||||
realList << clientRef;
|
||||
}
|
||||
|
||||
@@ -475,7 +505,8 @@ void InspectorUi::serverReloaded()
|
||||
{
|
||||
QmlJS::Snapshot snapshot = modelManager()->snapshot();
|
||||
m_loadedSnapshot = snapshot;
|
||||
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it = m_textPreviews.constBegin();
|
||||
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it
|
||||
= m_textPreviews.constBegin();
|
||||
it != m_textPreviews.constEnd(); ++it) {
|
||||
Document::Ptr doc = snapshot.document(it.key());
|
||||
it.value()->resetInitialDoc(doc);
|
||||
@@ -486,12 +517,14 @@ void InspectorUi::serverReloaded()
|
||||
|
||||
void InspectorUi::removePreviewForEditor(Core::IEditor *oldEditor)
|
||||
{
|
||||
if (QmlJSLiveTextPreview *preview = m_textPreviews.value(oldEditor->document()->fileName())) {
|
||||
if (QmlJSLiveTextPreview *preview
|
||||
= m_textPreviews.value(oldEditor->document()->fileName())) {
|
||||
preview->unassociateEditor(oldEditor);
|
||||
}
|
||||
}
|
||||
|
||||
QmlJSLiveTextPreview *InspectorUi::createPreviewForEditor(Core::IEditor *newEditor)
|
||||
QmlJSLiveTextPreview *InspectorUi::createPreviewForEditor(
|
||||
Core::IEditor *newEditor)
|
||||
{
|
||||
QmlJSLiveTextPreview *preview = 0;
|
||||
|
||||
@@ -522,13 +555,16 @@ QmlJSLiveTextPreview *InspectorUi::createPreviewForEditor(Core::IEditor *newEdit
|
||||
preview = m_textPreviews.value(filename);
|
||||
preview->associateEditor(newEditor);
|
||||
} else {
|
||||
preview = new QmlJSLiveTextPreview(doc, initdoc, m_clientProxy, this);
|
||||
preview = new QmlJSLiveTextPreview(doc, initdoc, m_clientProxy,
|
||||
this);
|
||||
connect(preview,
|
||||
SIGNAL(selectedItemsChanged(QList<QmlDebugObjectReference>)),
|
||||
SLOT(changeSelectedItems(QList<QmlDebugObjectReference>)));
|
||||
connect(preview, SIGNAL(reloadQmlViewerRequested()),
|
||||
m_clientProxy, SLOT(reloadQmlViewer()));
|
||||
connect(preview, SIGNAL(disableLivePreviewRequested()), SLOT(disableLivePreview()));
|
||||
connect(preview,
|
||||
SIGNAL(disableLivePreviewRequested()),
|
||||
SLOT(disableLivePreview()));
|
||||
|
||||
m_textPreviews.insert(newEditor->document()->fileName(), preview);
|
||||
preview->associateEditor(newEditor);
|
||||
@@ -559,11 +595,13 @@ QmlDebugObjectReference InspectorUi::findParentRecursive(
|
||||
|
||||
foreach (const QmlDebugObjectReference &possibleParent, objectsToSearch) {
|
||||
// Am I a root object? No parent
|
||||
if ( possibleParent.debugId() == goalDebugId && possibleParent.parentId() < 0)
|
||||
if ( possibleParent.debugId() == goalDebugId
|
||||
&& possibleParent.parentId() < 0)
|
||||
return QmlDebugObjectReference();
|
||||
|
||||
// Is the goal one of my children?
|
||||
foreach (const QmlDebugObjectReference &child, possibleParent.children())
|
||||
foreach (const QmlDebugObjectReference &child,
|
||||
possibleParent.children())
|
||||
if ( child.debugId() == goalDebugId ) {
|
||||
m_clientProxy->insertObjectInTreeIfNeeded(child);
|
||||
return possibleParent;
|
||||
@@ -597,12 +635,14 @@ inline QString displayName(const QmlDebugObjectReference &obj)
|
||||
QString objTypeName = obj.className();
|
||||
QString declarativeString("QDeclarative");
|
||||
if (objTypeName.startsWith(declarativeString)) {
|
||||
objTypeName = objTypeName.mid(declarativeString.length()).section('_',0,0);
|
||||
objTypeName
|
||||
= objTypeName.mid(declarativeString.length()).section('_',0,0);
|
||||
}
|
||||
return QString("<%1>").arg(objTypeName);
|
||||
}
|
||||
|
||||
void InspectorUi::selectItems(const QList<QmlDebugObjectReference> &objectReferences)
|
||||
void InspectorUi::selectItems(
|
||||
const QList<QmlDebugObjectReference> &objectReferences)
|
||||
{
|
||||
foreach (const QmlDebugObjectReference &objref, objectReferences) {
|
||||
int debugId = objref.debugId();
|
||||
@@ -636,7 +676,8 @@ void InspectorUi::showObject(const QmlDebugObjectReference &obj)
|
||||
|
||||
bool InspectorUi::isRoot(const QmlDebugObjectReference &obj) const
|
||||
{
|
||||
foreach (const QmlDebugObjectReference &rootObj, m_clientProxy->rootObjectReference())
|
||||
foreach (const QmlDebugObjectReference &rootObj,
|
||||
m_clientProxy->rootObjectReference())
|
||||
if (obj.debugId() == rootObj.debugId() && obj.parentId() < 0)
|
||||
return true;
|
||||
return false;
|
||||
@@ -653,7 +694,8 @@ void InspectorUi::populateCrumblePath(const QmlDebugObjectReference &objRef)
|
||||
crumbleStrings << displayName(objRef);
|
||||
|
||||
while ((!isRoot(ref)) && (ref.debugId()!=-1)) {
|
||||
ref = findParentRecursive(ref.debugId(), m_clientProxy->rootObjectReference());
|
||||
ref = findParentRecursive(ref.debugId(),
|
||||
m_clientProxy->rootObjectReference());
|
||||
crumbleData.push_front( ref.debugId() );
|
||||
crumbleStrings.push_front( displayName(ref) );
|
||||
}
|
||||
@@ -687,7 +729,8 @@ void InspectorUi::showRoot()
|
||||
crumbleData.clear();
|
||||
|
||||
// now append the children
|
||||
foreach (const QmlDebugObjectReference &child, m_clientProxy->rootObjectReference()) {
|
||||
foreach (const QmlDebugObjectReference &child,
|
||||
m_clientProxy->rootObjectReference()) {
|
||||
if (child.parentId() != -1)
|
||||
continue;
|
||||
crumbleData.push_back(child.debugId());
|
||||
@@ -706,7 +749,8 @@ void InspectorUi::selectItems(const QList<int> &objectIds)
|
||||
QList<QmlDebugObjectReference> objectReferences;
|
||||
foreach (int objectId, objectIds)
|
||||
{
|
||||
QmlDebugObjectReference ref = m_clientProxy->objectReferenceForId(objectId);
|
||||
QmlDebugObjectReference ref
|
||||
= m_clientProxy->objectReferenceForId(objectId);
|
||||
if (ref.debugId() == objectId)
|
||||
objectReferences.append(ref);
|
||||
}
|
||||
@@ -715,11 +759,13 @@ void InspectorUi::selectItems(const QList<int> &objectIds)
|
||||
}
|
||||
|
||||
void InspectorUi::changePropertyValue(int debugId, const QString &propertyName,
|
||||
const QString &valueExpression, bool isLiteral)
|
||||
const QString &valueExpression,
|
||||
bool isLiteral)
|
||||
{
|
||||
QmlDebugObjectReference obj = m_clientProxy->objectReferenceForId(debugId);
|
||||
m_clientProxy->setBindingForObject(debugId, propertyName, valueExpression, isLiteral,
|
||||
obj.source().url().toString(), obj.source().lineNumber());
|
||||
m_clientProxy->setBindingForObject(debugId, propertyName, valueExpression,
|
||||
isLiteral, obj.source().url().toString(),
|
||||
obj.source().lineNumber());
|
||||
}
|
||||
|
||||
void InspectorUi::enable()
|
||||
@@ -736,24 +782,29 @@ void InspectorUi::disable()
|
||||
m_propertyInspector->clear();
|
||||
}
|
||||
|
||||
QmlDebugObjectReference InspectorUi::objectReferenceForLocation(const QString &fileName, int cursorPosition) const
|
||||
QmlDebugObjectReference InspectorUi::objectReferenceForLocation(
|
||||
const QString &fileName, int cursorPosition) const
|
||||
{
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
Core::IEditor *editor = editorManager->openEditor(fileName);
|
||||
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
||||
TextEditor::ITextEditor *textEditor
|
||||
= qobject_cast<TextEditor::ITextEditor*>(editor);
|
||||
|
||||
if (textEditor && m_clientProxy && textEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||
if (textEditor && m_clientProxy
|
||||
&& textEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||
if (cursorPosition == -1)
|
||||
cursorPosition = textEditor->position();
|
||||
TextEditor::BaseTextEditor *baseTextEditor =
|
||||
static_cast<TextEditor::BaseTextEditor*>(editor);
|
||||
QPlainTextEdit *editWidget = qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
|
||||
QPlainTextEdit *editWidget
|
||||
= qobject_cast<QPlainTextEdit*>(baseTextEditor->widget());
|
||||
|
||||
QmlJSTools::SemanticInfo semanticInfo = getSemanticInfo(editWidget);
|
||||
|
||||
if (QmlJS::AST::Node *node
|
||||
= semanticInfo.declaringMemberNoProperties(cursorPosition)) {
|
||||
if (QmlJS::AST::UiObjectMember *objMember = node->uiObjectMemberCast()) {
|
||||
if (QmlJS::AST::UiObjectMember *objMember
|
||||
= node->uiObjectMemberCast()) {
|
||||
return m_clientProxy->objectReferenceForLocation(
|
||||
objMember->firstSourceLocation().startLine,
|
||||
objMember->firstSourceLocation().startColumn);
|
||||
@@ -763,7 +814,8 @@ QmlDebugObjectReference InspectorUi::objectReferenceForLocation(const QString &f
|
||||
return QmlDebugObjectReference();
|
||||
}
|
||||
|
||||
void InspectorUi::gotoObjectReferenceDefinition(const QmlDebugObjectReference &obj)
|
||||
void InspectorUi::gotoObjectReferenceDefinition(
|
||||
const QmlDebugObjectReference &obj)
|
||||
{
|
||||
if (m_cursorPositionChangedExternally) {
|
||||
m_cursorPositionChangedExternally = false;
|
||||
@@ -777,7 +829,8 @@ void InspectorUi::gotoObjectReferenceDefinition(const QmlDebugObjectReference &o
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
Core::IEditor *currentEditor = editorManager->currentEditor();
|
||||
Core::IEditor *editor = editorManager->openEditor(fileName);
|
||||
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
||||
TextEditor::ITextEditor *textEditor
|
||||
= qobject_cast<TextEditor::ITextEditor*>(editor);
|
||||
|
||||
if (currentEditor != editor)
|
||||
m_selectionCallbackExpected = true;
|
||||
@@ -805,7 +858,8 @@ void InspectorUi::setupDockWidgets()
|
||||
m_crumblePath->setStyleSheet(QLatin1String("background: #9B9B9B"));
|
||||
m_crumblePath->setObjectName("QmlContextPath");
|
||||
m_crumblePath->setWindowTitle(tr("Context Path"));
|
||||
connect(m_crumblePath, SIGNAL(elementClicked(QVariant)), SLOT(crumblePathElementClicked(QVariant)));
|
||||
connect(m_crumblePath, SIGNAL(elementClicked(QVariant)),
|
||||
SLOT(crumblePathElementClicked(QVariant)));
|
||||
|
||||
m_propertyInspector = new QmlJSPropertyInspector;
|
||||
|
||||
@@ -830,7 +884,8 @@ void InspectorUi::setupDockWidgets()
|
||||
wlay->addWidget(m_propertyInspector);
|
||||
wlay->addWidget(new Core::FindToolBarPlaceHolder(inspectorWidget));
|
||||
|
||||
QDockWidget *dock = mw->createDockWidget(Debugger::QmlLanguage, inspectorWidget);
|
||||
QDockWidget *dock
|
||||
= mw->createDockWidget(Debugger::QmlLanguage, inspectorWidget);
|
||||
dock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
||||
dock->setTitleBarWidget(new QWidget(dock));
|
||||
|
||||
@@ -901,8 +956,9 @@ void InspectorUi::updatePendingPreviewDocuments(QmlJS::Document::Ptr doc)
|
||||
if (idx == -1)
|
||||
return;
|
||||
|
||||
Core::EditorManager *em = Core::EditorManager::instance();
|
||||
QList<Core::IEditor *> editors
|
||||
= Core::EditorManager::instance()->editorsForFileName(doc->fileName());
|
||||
= em->editorsForFileName(doc->fileName());
|
||||
|
||||
if (editors.isEmpty())
|
||||
return;
|
||||
@@ -923,13 +979,17 @@ void InspectorUi::disableLivePreview()
|
||||
|
||||
void InspectorUi::connectSignals()
|
||||
{
|
||||
connect(m_propertyInspector, SIGNAL(changePropertyValue(int,QString,QString,bool)),
|
||||
connect(m_propertyInspector,
|
||||
SIGNAL(changePropertyValue(int,QString,QString,bool)),
|
||||
this, SLOT(changePropertyValue(int,QString,QString,bool)));
|
||||
|
||||
connect(m_clientProxy, SIGNAL(propertyChanged(int,QByteArray,QVariant)),
|
||||
m_propertyInspector, SLOT(propertyValueChanged(int,QByteArray,QVariant)));
|
||||
connect(m_clientProxy,
|
||||
SIGNAL(propertyChanged(int,QByteArray,QVariant)),
|
||||
m_propertyInspector,
|
||||
SLOT(propertyValueChanged(int,QByteArray,QVariant)));
|
||||
|
||||
connect(m_clientProxy, SIGNAL(selectedItemsChanged(QList<QmlDebugObjectReference>)),
|
||||
connect(m_clientProxy,
|
||||
SIGNAL(selectedItemsChanged(QList<QmlDebugObjectReference>)),
|
||||
this, SLOT(selectItems(QList<QmlDebugObjectReference>)));
|
||||
connect(m_clientProxy, SIGNAL(enginesChanged()),
|
||||
this, SLOT(updateEngineList()));
|
||||
|
||||
@@ -134,7 +134,8 @@ private slots:
|
||||
void crumblePathElementClicked(const QVariant &data);
|
||||
|
||||
void updatePendingPreviewDocuments(QmlJS::Document::Ptr doc);
|
||||
void showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
|
||||
void showDebuggerTooltip(const QPoint &mousePos,
|
||||
TextEditor::ITextEditor *editor, int cursorPos);
|
||||
void onEngineStateChanged(Debugger::DebuggerState state);
|
||||
|
||||
private:
|
||||
@@ -147,7 +148,8 @@ private:
|
||||
QString filenameForShadowBuildFile(const QString &filename) const;
|
||||
void populateCrumblePath(const QmlDebugObjectReference &objRef);
|
||||
bool isRoot(const QmlDebugObjectReference &obj) const;
|
||||
QmlDebugObjectReference objectReferenceForLocation(const QString &fileName, int cursorPosition=-1) const;
|
||||
QmlDebugObjectReference objectReferenceForLocation(
|
||||
const QString &fileName, int cursorPosition = -1) const;
|
||||
|
||||
void connectSignals();
|
||||
void disconnectSignals();
|
||||
@@ -155,7 +157,8 @@ private:
|
||||
void showObject(const QmlDebugObjectReference &obj);
|
||||
|
||||
QmlDebugObjectReference findParentRecursive(
|
||||
int goalDebugId, const QList<QmlDebugObjectReference > &objectsToSearch);
|
||||
int goalDebugId,
|
||||
const QList<QmlDebugObjectReference > &objectsToSearch);
|
||||
private:
|
||||
bool m_listeningToEditorManager;
|
||||
QmlJsInspectorToolBar *m_toolBar;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Internal {
|
||||
|
||||
QmlJSInspectorClient::QmlJSInspectorClient(QDeclarativeDebugConnection *client,
|
||||
QObject * /*parent*/)
|
||||
: QDeclarativeDebugClient(QLatin1String("QDeclarativeObserverMode"), client) ,
|
||||
: QDeclarativeDebugClient(QLatin1String("QDeclarativeObserverMode"), client),
|
||||
m_connection(client)
|
||||
{
|
||||
setObjectName(name());
|
||||
@@ -105,7 +105,8 @@ void QmlJSInspectorClient::messageReceived(const QByteArray &message)
|
||||
bool paused;
|
||||
ds >> paused;
|
||||
|
||||
log(LogReceive, type, paused ? QLatin1String("true") : QLatin1String("false"));
|
||||
log(LogReceive, type, paused ? QLatin1String("true")
|
||||
: QLatin1String("false"));
|
||||
|
||||
emit animationPausedChanged(paused);
|
||||
break;
|
||||
@@ -169,7 +170,8 @@ void QmlJSInspectorClient::setCurrentObjects(const QList<int> &debugIds)
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void recurseObjectIdList(const QmlDebugObjectReference &ref, QList<int> &debugIds, QList<QString> &objectIds)
|
||||
void recurseObjectIdList(const QmlDebugObjectReference &ref,
|
||||
QList<int> &debugIds, QList<QString> &objectIds)
|
||||
{
|
||||
debugIds << ref.debugId();
|
||||
objectIds << ref.idString();
|
||||
@@ -177,7 +179,8 @@ void recurseObjectIdList(const QmlDebugObjectReference &ref, QList<int> &debugId
|
||||
recurseObjectIdList(child, debugIds, objectIds);
|
||||
}
|
||||
|
||||
void QmlJSInspectorClient::setObjectIdList(const QList<QmlDebugObjectReference> &objectRoots)
|
||||
void QmlJSInspectorClient::setObjectIdList(
|
||||
const QList<QmlDebugObjectReference> &objectRoots)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
@@ -198,7 +201,8 @@ void QmlJSInspectorClient::setObjectIdList(const QList<QmlDebugObjectReference>
|
||||
ds << debugIds[i] << objectIds[i];
|
||||
}
|
||||
|
||||
log(LogSend, cmd, QString("%1 %2 [list of debug / object ids]").arg(debugIds.length()));
|
||||
log(LogSend, cmd,
|
||||
QString("%1 %2 [list of debug / object ids]").arg(debugIds.length()));
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
@@ -357,8 +361,10 @@ void QmlJSInspectorClient::showAppOnTop(bool showOnTop)
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QmlJSInspectorClient::createQmlObject(const QString &qmlText, int parentDebugId,
|
||||
const QStringList &imports, const QString &filename, int order)
|
||||
void QmlJSInspectorClient::createQmlObject(const QString &qmlText,
|
||||
int parentDebugId,
|
||||
const QStringList &imports,
|
||||
const QString &filename, int order)
|
||||
{
|
||||
if (!m_connection || !m_connection->isConnected())
|
||||
return;
|
||||
@@ -374,7 +380,8 @@ void QmlJSInspectorClient::createQmlObject(const QString &qmlText, int parentDeb
|
||||
<< filename
|
||||
<< order;
|
||||
|
||||
log(LogSend, cmd, QString("%1 %2 [%3] %4").arg(qmlText, QString::number(parentDebugId),
|
||||
log(LogSend, cmd, QString("%1 %2 [%3] %4").arg(qmlText,
|
||||
QString::number(parentDebugId),
|
||||
imports.join(","), filename));
|
||||
|
||||
sendMessage(message);
|
||||
@@ -430,7 +437,8 @@ void QmlJSInspectorClient::applyChangesFromQmlFile()
|
||||
// TODO
|
||||
}
|
||||
|
||||
void QmlJSInspectorClient::log(LogDirection direction, InspectorProtocol::Message message,
|
||||
void QmlJSInspectorClient::log(LogDirection direction,
|
||||
InspectorProtocol::Message message,
|
||||
const QString &extra)
|
||||
{
|
||||
QString msg;
|
||||
|
||||
@@ -57,7 +57,8 @@ public:
|
||||
void showAppOnTop(bool showOnTop);
|
||||
|
||||
void createQmlObject(const QString &qmlText, int parentDebugId,
|
||||
const QStringList &imports, const QString &filename, int order);
|
||||
const QStringList &imports, const QString &filename,
|
||||
int order);
|
||||
void destroyQmlObject(int debugId);
|
||||
void reparentQmlObject(int debugId, int newParent);
|
||||
|
||||
|
||||
@@ -72,7 +72,9 @@ InspectorPlugin::~InspectorPlugin()
|
||||
|
||||
QmlJS::ModelManagerInterface *InspectorPlugin::modelManager() const
|
||||
{
|
||||
return ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>();
|
||||
ExtensionSystem::PluginManager *pluginManager
|
||||
= ExtensionSystem::PluginManager::instance();
|
||||
return pluginManager->getObject<QmlJS::ModelManagerInterface>();
|
||||
}
|
||||
|
||||
InspectorUi *InspectorPlugin::inspector() const
|
||||
@@ -86,7 +88,8 @@ ExtensionSystem::IPlugin::ShutdownFlag InspectorPlugin::aboutToShutdown()
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
bool InspectorPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
bool InspectorPlugin::initialize(const QStringList &arguments,
|
||||
QString *errorString)
|
||||
{
|
||||
Q_UNUSED(arguments);
|
||||
Q_UNUSED(errorString);
|
||||
@@ -96,10 +99,13 @@ bool InspectorPlugin::initialize(const QStringList &arguments, QString *errorStr
|
||||
|
||||
void InspectorPlugin::extensionsInitialized()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
ExtensionSystem::PluginManager *pluginManager
|
||||
= ExtensionSystem::PluginManager::instance();
|
||||
|
||||
connect(pluginManager, SIGNAL(objectAdded(QObject*)), SLOT(objectAdded(QObject*)));
|
||||
connect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
|
||||
connect(pluginManager, SIGNAL(objectAdded(QObject*)),
|
||||
SLOT(objectAdded(QObject*)));
|
||||
connect(Core::ModeManager::instance(),
|
||||
SIGNAL(currentModeAboutToChange(Core::IMode*)),
|
||||
this, SLOT(modeAboutToChange(Core::IMode*)));
|
||||
}
|
||||
|
||||
@@ -113,7 +119,8 @@ void InspectorPlugin::objectAdded(QObject *object)
|
||||
if (m_clientProxy->isConnected()) {
|
||||
clientProxyConnected();
|
||||
} else {
|
||||
connect(m_clientProxy, SIGNAL(connected()), this, SLOT(clientProxyConnected()));
|
||||
connect(m_clientProxy, SIGNAL(connected()),
|
||||
this, SLOT(clientProxyConnected()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -144,7 +151,8 @@ void InspectorPlugin::modeAboutToChange(Core::IMode *newMode)
|
||||
m_inspectorUi->setupUi();
|
||||
|
||||
// Make sure we're not called again.
|
||||
QObject::disconnect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
|
||||
QObject::disconnect(Core::ModeManager::instance(),
|
||||
SIGNAL(currentModeAboutToChange(Core::IMode*)),
|
||||
this, SLOT(modeAboutToChange(Core::IMode*)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@ class InspectorUi;
|
||||
class InspectorPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlJSInspector.json")
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin"
|
||||
FILE "QmlJSInspector.json")
|
||||
|
||||
public:
|
||||
InspectorPlugin();
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
namespace QmlJSInspector {
|
||||
namespace Internal {
|
||||
|
||||
using namespace QmlJSInspector::Constants;
|
||||
|
||||
InspectorSettings::InspectorSettings(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_showLivePreviewWarning(true)
|
||||
@@ -45,15 +47,18 @@ InspectorSettings::InspectorSettings(QObject *parent)
|
||||
|
||||
void InspectorSettings::restoreSettings(QSettings *settings)
|
||||
{
|
||||
settings->beginGroup(QLatin1String(QmlJSInspector::Constants::S_QML_INSPECTOR));
|
||||
m_showLivePreviewWarning = settings->value(QLatin1String(QmlJSInspector::Constants::S_LIVE_PREVIEW_WARNING_KEY), true).toBool();
|
||||
settings->beginGroup(QLatin1String(S_QML_INSPECTOR));
|
||||
m_showLivePreviewWarning
|
||||
= settings->value(QLatin1String(S_LIVE_PREVIEW_WARNING_KEY),
|
||||
true).toBool();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void InspectorSettings::saveSettings(QSettings *settings) const
|
||||
{
|
||||
settings->beginGroup(QLatin1String(QmlJSInspector::Constants::S_QML_INSPECTOR));
|
||||
settings->setValue(QLatin1String(QmlJSInspector::Constants::S_LIVE_PREVIEW_WARNING_KEY), m_showLivePreviewWarning);
|
||||
settings->beginGroup(QLatin1String(S_QML_INSPECTOR));
|
||||
settings->setValue(QLatin1String(S_LIVE_PREVIEW_WARNING_KEY),
|
||||
m_showLivePreviewWarning);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
|
||||
@@ -171,21 +171,23 @@ void QmlJsInspectorToolBar::setZoomToolEnabled(bool enable)
|
||||
|
||||
void QmlJsInspectorToolBar::createActions()
|
||||
{
|
||||
using namespace Constants;
|
||||
|
||||
Core::Context context(Debugger::Constants::C_QMLDEBUGGER);
|
||||
Core::ActionManager *am = Core::ICore::actionManager();
|
||||
|
||||
m_fromQmlAction = new Utils::SavedAction(this);
|
||||
m_fromQmlAction->setDefaultValue(false);
|
||||
m_fromQmlAction->setSettingsKey(QLatin1String(Constants::S_QML_INSPECTOR),
|
||||
QLatin1String(Constants::FROM_QML_ACTION));
|
||||
m_fromQmlAction->setSettingsKey(QLatin1String(S_QML_INSPECTOR),
|
||||
QLatin1String(FROM_QML_ACTION));
|
||||
m_fromQmlAction->setText(tr("Apply Changes on Save"));
|
||||
m_fromQmlAction->setCheckable(true);
|
||||
m_fromQmlAction->setIcon(QIcon(QLatin1String(":/qml/images/from-qml-small.png")));
|
||||
|
||||
m_showAppOnTopAction = new Utils::SavedAction(this);
|
||||
m_showAppOnTopAction->setDefaultValue(false);
|
||||
m_showAppOnTopAction->setSettingsKey(QLatin1String(Constants::S_QML_INSPECTOR),
|
||||
QLatin1String(Constants::SHOW_APP_ON_TOP_ACTION));
|
||||
m_showAppOnTopAction->setSettingsKey(QLatin1String(S_QML_INSPECTOR),
|
||||
QLatin1String(SHOW_APP_ON_TOP_ACTION));
|
||||
m_showAppOnTopAction->setText(tr("Show application on top"));
|
||||
m_showAppOnTopAction->setCheckable(true);
|
||||
m_showAppOnTopAction->setIcon(QIcon(QLatin1String(":/qml/images/app-on-top.png")));
|
||||
@@ -202,40 +204,46 @@ void QmlJsInspectorToolBar::createActions()
|
||||
m_selectAction->setCheckable(true);
|
||||
m_zoomAction->setCheckable(true);
|
||||
|
||||
Core::Command *command = am->registerAction(m_playAction, Constants::PLAY_ACTION, context);
|
||||
Core::Command *command
|
||||
= am->registerAction(m_playAction, PLAY_ACTION, context);
|
||||
command->setAttribute(Core::Command::CA_UpdateIcon);
|
||||
am->registerAction(m_selectAction, Constants::SELECT_ACTION, context);
|
||||
am->registerAction(m_zoomAction, Constants::ZOOM_ACTION, context);
|
||||
am->registerAction(m_fromQmlAction, Constants::FROM_QML_ACTION, context);
|
||||
am->registerAction(m_showAppOnTopAction, Constants::SHOW_APP_ON_TOP_ACTION, context);
|
||||
am->registerAction(m_selectAction, SELECT_ACTION, context);
|
||||
am->registerAction(m_zoomAction, ZOOM_ACTION, context);
|
||||
am->registerAction(m_fromQmlAction, FROM_QML_ACTION, context);
|
||||
am->registerAction(m_showAppOnTopAction, SHOW_APP_ON_TOP_ACTION, context);
|
||||
|
||||
m_barWidget = new QWidget;
|
||||
|
||||
QMenu *playSpeedMenu = new QMenu(m_barWidget);
|
||||
m_playSpeedMenuActions = new QActionGroup(this);
|
||||
m_playSpeedMenuActions->setExclusive(true);
|
||||
QAction *speedAction = playSpeedMenu->addAction(tr("1x"), this, SLOT(changeAnimationSpeed()));
|
||||
QAction *speedAction = playSpeedMenu->addAction(tr("1x"),
|
||||
this, SLOT(changeAnimationSpeed()));
|
||||
speedAction->setCheckable(true);
|
||||
speedAction->setChecked(true);
|
||||
speedAction->setData(1.0f);
|
||||
m_playSpeedMenuActions->addAction(speedAction);
|
||||
|
||||
speedAction = playSpeedMenu->addAction(tr("0.5x"), this, SLOT(changeAnimationSpeed()));
|
||||
speedAction = playSpeedMenu->addAction(tr("0.5x"),
|
||||
this, SLOT(changeAnimationSpeed()));
|
||||
speedAction->setCheckable(true);
|
||||
speedAction->setData(2.0f);
|
||||
m_playSpeedMenuActions->addAction(speedAction);
|
||||
|
||||
speedAction = playSpeedMenu->addAction(tr("0.25x"), this, SLOT(changeAnimationSpeed()));
|
||||
speedAction = playSpeedMenu->addAction(tr("0.25x"),
|
||||
this, SLOT(changeAnimationSpeed()));
|
||||
speedAction->setCheckable(true);
|
||||
speedAction->setData(4.0f);
|
||||
m_playSpeedMenuActions->addAction(speedAction);
|
||||
|
||||
speedAction = playSpeedMenu->addAction(tr("0.125x"), this, SLOT(changeAnimationSpeed()));
|
||||
speedAction = playSpeedMenu->addAction(tr("0.125x"),
|
||||
this, SLOT(changeAnimationSpeed()));
|
||||
speedAction->setCheckable(true);
|
||||
speedAction->setData(8.0f);
|
||||
m_playSpeedMenuActions->addAction(speedAction);
|
||||
|
||||
speedAction = playSpeedMenu->addAction(tr("0.1x"), this, SLOT(changeAnimationSpeed()));
|
||||
speedAction = playSpeedMenu->addAction(tr("0.1x"),
|
||||
this, SLOT(changeAnimationSpeed()));
|
||||
speedAction->setCheckable(true);
|
||||
speedAction->setData(10.0f);
|
||||
m_playSpeedMenuActions->addAction(speedAction);
|
||||
@@ -245,23 +253,29 @@ void QmlJsInspectorToolBar::createActions()
|
||||
toolBarLayout->setSpacing(0);
|
||||
|
||||
// QML Helpers
|
||||
toolBarLayout->addWidget(toolButton(am->command(Constants::FROM_QML_ACTION)->action()));
|
||||
toolBarLayout->addWidget(toolButton(am->command(Constants::SHOW_APP_ON_TOP_ACTION)->action()));
|
||||
m_playButton = toolButton(am->command(Constants::PLAY_ACTION)->action());
|
||||
toolBarLayout->addWidget(toolButton(am->command(FROM_QML_ACTION)->action()));
|
||||
toolBarLayout->addWidget(
|
||||
toolButton(am->command(SHOW_APP_ON_TOP_ACTION)->action()));
|
||||
m_playButton = toolButton(am->command(PLAY_ACTION)->action());
|
||||
m_playButton->setMenu(playSpeedMenu);
|
||||
toolBarLayout->addWidget(m_playButton);
|
||||
|
||||
// Inspector
|
||||
toolBarLayout->addWidget(new Utils::StyledSeparator);
|
||||
toolBarLayout->addWidget(toolButton(am->command(Constants::SELECT_ACTION)->action()));
|
||||
toolBarLayout->addWidget(toolButton(am->command(Constants::ZOOM_ACTION)->action()));
|
||||
toolBarLayout->addWidget(toolButton(am->command(SELECT_ACTION)->action()));
|
||||
toolBarLayout->addWidget(toolButton(am->command(ZOOM_ACTION)->action()));
|
||||
toolBarLayout->addWidget(new Utils::StyledSeparator);
|
||||
|
||||
connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml()));
|
||||
connect(m_showAppOnTopAction, SIGNAL(triggered()), SLOT(showAppOnTopClick()));
|
||||
connect(m_playAction, SIGNAL(triggered()), SLOT(activatePlayOnClick()));
|
||||
connect(m_selectAction, SIGNAL(triggered(bool)), SLOT(selectToolTriggered(bool)));
|
||||
connect(m_zoomAction, SIGNAL(triggered(bool)), SLOT(zoomToolTriggered(bool)));
|
||||
connect(m_fromQmlAction, SIGNAL(triggered()),
|
||||
SLOT(activateFromQml()));
|
||||
connect(m_showAppOnTopAction, SIGNAL(triggered()),
|
||||
SLOT(showAppOnTopClick()));
|
||||
connect(m_playAction, SIGNAL(triggered()),
|
||||
SLOT(activatePlayOnClick()));
|
||||
connect(m_selectAction, SIGNAL(triggered(bool)),
|
||||
SLOT(selectToolTriggered(bool)));
|
||||
connect(m_zoomAction, SIGNAL(triggered(bool)),
|
||||
SLOT(zoomToolTriggered(bool)));
|
||||
|
||||
readSettings();
|
||||
connect(Core::ICore::instance(),
|
||||
@@ -350,8 +364,10 @@ void QmlJsInspectorToolBar::activateFromQml()
|
||||
void QmlJsInspectorToolBar::updateDesignModeActions(DesignTool activeTool)
|
||||
{
|
||||
m_activeTool = activeTool;
|
||||
m_selectAction->setChecked(m_designModeActive && (m_activeTool == SelectionToolMode));
|
||||
m_zoomAction->setChecked(m_designModeActive && (m_activeTool == ZoomMode));
|
||||
m_selectAction->setChecked(m_designModeActive
|
||||
&& (m_activeTool == SelectionToolMode));
|
||||
m_zoomAction->setChecked(m_designModeActive
|
||||
&& (m_activeTool == ZoomMode));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -88,49 +88,51 @@ private:
|
||||
int activated;
|
||||
};
|
||||
|
||||
bool MapObjectWithDebugReference::visit(UiObjectDefinition* ast)
|
||||
bool MapObjectWithDebugReference::visit(UiObjectDefinition *ast)
|
||||
{
|
||||
if (lookupObjects.contains(ast))
|
||||
activated++;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MapObjectWithDebugReference::visit(UiObjectBinding* ast)
|
||||
bool MapObjectWithDebugReference::visit(UiObjectBinding *ast)
|
||||
{
|
||||
if (lookupObjects.contains(ast))
|
||||
activated++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MapObjectWithDebugReference::endVisit(UiObjectDefinition* ast)
|
||||
void MapObjectWithDebugReference::endVisit(UiObjectDefinition *ast)
|
||||
{
|
||||
process(ast);
|
||||
if (lookupObjects.contains(ast))
|
||||
activated--;
|
||||
}
|
||||
|
||||
void MapObjectWithDebugReference::endVisit(UiObjectBinding* ast)
|
||||
void MapObjectWithDebugReference::endVisit(UiObjectBinding *ast)
|
||||
{
|
||||
process(ast);
|
||||
if (lookupObjects.contains(ast))
|
||||
activated--;
|
||||
}
|
||||
|
||||
void MapObjectWithDebugReference::process(UiObjectMember* ast)
|
||||
void MapObjectWithDebugReference::process(UiObjectMember *ast)
|
||||
{
|
||||
if (lookupObjects.isEmpty() || activated) {
|
||||
SourceLocation loc = ast->firstSourceLocation();
|
||||
QHash<QPair<int, int>, DebugIdList>::const_iterator it = ids.constFind(qMakePair<int, int>(loc.startLine, loc.startColumn));
|
||||
QHash<QPair<int, int>, DebugIdList>::const_iterator it
|
||||
= ids.constFind(qMakePair<int, int>(loc.startLine, loc.startColumn));
|
||||
if (it != ids.constEnd())
|
||||
result[ast].append(*it);
|
||||
}
|
||||
}
|
||||
|
||||
void MapObjectWithDebugReference::process(UiObjectBinding* ast)
|
||||
void MapObjectWithDebugReference::process(UiObjectBinding *ast)
|
||||
{
|
||||
if (lookupObjects.isEmpty() || activated) {
|
||||
SourceLocation loc = ast->qualifiedTypeNameId->identifierToken;
|
||||
QHash<QPair<int, int>, DebugIdList>::const_iterator it = ids.constFind(qMakePair<int, int>(loc.startLine, loc.startColumn));
|
||||
QHash<QPair<int, int>, DebugIdList>::const_iterator it
|
||||
= ids.constFind(qMakePair<int, int>(loc.startLine, loc.startColumn));
|
||||
if (it != ids.constEnd())
|
||||
result[ast].append(*it);
|
||||
}
|
||||
@@ -138,7 +140,9 @@ void MapObjectWithDebugReference::process(UiObjectBinding* ast)
|
||||
|
||||
QmlJS::ModelManagerInterface *QmlJSLiveTextPreview::modelManager()
|
||||
{
|
||||
return ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>();
|
||||
ExtensionSystem::PluginManager *pm
|
||||
= ExtensionSystem::PluginManager::instance();
|
||||
return pm->getObject<QmlJS::ModelManagerInterface>();
|
||||
}
|
||||
|
||||
void QmlJSLiveTextPreview::associateEditor(Core::IEditor *editor)
|
||||
@@ -149,13 +153,15 @@ void QmlJSLiveTextPreview::associateEditor(Core::IEditor *editor)
|
||||
QLatin1String("QmlJSEditor::QmlJSTextEditorWidget"),
|
||||
return);
|
||||
|
||||
BaseTextEditorWidget *editWidget = qobject_cast<BaseTextEditorWidget*>(editor->widget());
|
||||
BaseTextEditorWidget *editWidget
|
||||
= qobject_cast<BaseTextEditorWidget*>(editor->widget());
|
||||
QTC_ASSERT(editWidget, return);
|
||||
|
||||
if (!m_editors.contains(editWidget)) {
|
||||
m_editors << editWidget;
|
||||
if (m_clientProxy.data())
|
||||
connect(editWidget, SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
||||
connect(editWidget,
|
||||
SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
||||
SLOT(changeSelectedElements(QList<int>,QString)));
|
||||
}
|
||||
}
|
||||
@@ -164,8 +170,10 @@ void QmlJSLiveTextPreview::associateEditor(Core::IEditor *editor)
|
||||
void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
|
||||
{
|
||||
using namespace TextEditor;
|
||||
if (oldEditor && oldEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||
BaseTextEditorWidget *editWidget = qobject_cast<BaseTextEditorWidget*>(oldEditor->widget());
|
||||
if (oldEditor && oldEditor->id()
|
||||
== QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
|
||||
BaseTextEditorWidget *editWidget
|
||||
= qobject_cast<BaseTextEditorWidget*>(oldEditor->widget());
|
||||
QTC_ASSERT(editWidget, return);
|
||||
|
||||
if (m_editors.contains(editWidget)) {
|
||||
@@ -178,7 +186,7 @@ void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
|
||||
QmlJSLiveTextPreview::QmlJSLiveTextPreview(const QmlJS::Document::Ptr &doc,
|
||||
const QmlJS::Document::Ptr &initDoc,
|
||||
ClientProxy *clientProxy,
|
||||
QObject* parent)
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_previousDoc(doc)
|
||||
, m_initialDoc(initDoc)
|
||||
@@ -194,7 +202,8 @@ QmlJSLiveTextPreview::QmlJSLiveTextPreview(const QmlJS::Document::Ptr &doc,
|
||||
SLOT(documentChanged(QmlJS::Document::Ptr)));
|
||||
|
||||
if (m_clientProxy.data()) {
|
||||
connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()), SLOT(updateDebugIds()));
|
||||
connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()),
|
||||
SLOT(updateDebugIds()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +247,8 @@ QList<int> QmlJSLiveTextPreview::objectReferencesForOffset(quint32 offset)
|
||||
return result;
|
||||
}
|
||||
|
||||
void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QString &wordAtCursor)
|
||||
void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets,
|
||||
const QString &wordAtCursor)
|
||||
{
|
||||
if (m_editors.isEmpty() || !m_previousDoc || !m_clientProxy)
|
||||
return;
|
||||
@@ -246,7 +256,8 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QStr
|
||||
m_updateNodeForOffset = false;
|
||||
m_lastOffsets = offsets;
|
||||
QmlDebugObjectReference objectRefUnderCursor;
|
||||
objectRefUnderCursor = m_clientProxy.data()->objectReferenceForId(wordAtCursor);
|
||||
objectRefUnderCursor
|
||||
= m_clientProxy.data()->objectReferenceForId(wordAtCursor);
|
||||
|
||||
QList<int> selectedReferences;
|
||||
bool containsReferenceUnderCursor = false;
|
||||
@@ -255,7 +266,8 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QStr
|
||||
if (offset >= 0) {
|
||||
QList<int> list = objectReferencesForOffset(offset);
|
||||
|
||||
if (!containsReferenceUnderCursor && objectRefUnderCursor.debugId() != -1) {
|
||||
if (!containsReferenceUnderCursor
|
||||
&& objectRefUnderCursor.debugId() != -1) {
|
||||
foreach(int id, list) {
|
||||
if (id == objectRefUnderCursor.debugId()) {
|
||||
containsReferenceUnderCursor = true;
|
||||
@@ -284,7 +296,8 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList<int> offsets, const QStr
|
||||
}
|
||||
}
|
||||
|
||||
static QList<int> findRootObjectRecursive(const QmlDebugObjectReference &object, const Document::Ptr &doc)
|
||||
static QList<int> findRootObjectRecursive(const QmlDebugObjectReference &object,
|
||||
const Document::Ptr &doc)
|
||||
{
|
||||
QList<int> result;
|
||||
if (object.className() == doc->componentName())
|
||||
@@ -301,13 +314,16 @@ void QmlJSLiveTextPreview::updateDebugIds()
|
||||
if (!m_initialDoc->qmlProgram())
|
||||
return;
|
||||
|
||||
ClientProxy* clientProxy = m_clientProxy.data();
|
||||
ClientProxy *clientProxy = m_clientProxy.data();
|
||||
if (!clientProxy)
|
||||
return;
|
||||
|
||||
DebugIdHash::const_iterator it = clientProxy->debugIdHash().constFind(qMakePair<QString, int>(m_initialDoc->fileName(), 0));
|
||||
DebugIdHash::const_iterator it
|
||||
= clientProxy->debugIdHash().constFind(
|
||||
qMakePair<QString, int>(m_initialDoc->fileName(), 0));
|
||||
if (it != clientProxy->debugIdHash().constEnd()) {
|
||||
// Map all the object that comes from the document as it has been loaded by the server.
|
||||
// Map all the object that comes from the document as it has been loaded
|
||||
// by the server.
|
||||
const QmlJS::Document::Ptr &doc = m_initialDoc;
|
||||
|
||||
MapObjectWithDebugReference visitor;
|
||||
@@ -328,16 +344,19 @@ void QmlJSLiveTextPreview::updateDebugIds()
|
||||
|
||||
// Map the root nodes of the document.
|
||||
if(doc->qmlProgram()->members && doc->qmlProgram()->members->member) {
|
||||
UiObjectMember* root = doc->qmlProgram()->members->member;
|
||||
UiObjectMember *root = doc->qmlProgram()->members->member;
|
||||
QList<int> r;
|
||||
foreach (const QmlDebugObjectReference& it, clientProxy->rootObjectReference())
|
||||
foreach (const QmlDebugObjectReference& it,
|
||||
clientProxy->rootObjectReference()) {
|
||||
r += findRootObjectRecursive(it, doc);
|
||||
}
|
||||
if (!r.isEmpty())
|
||||
m_debugIds[root] += r;
|
||||
}
|
||||
|
||||
// Map the node of the later created objects.
|
||||
for(QHash<Document::Ptr,QSet<UiObjectMember*> >::const_iterator it = m_createdObjects.constBegin();
|
||||
for (QHash<Document::Ptr,QSet<UiObjectMember*> >::const_iterator it
|
||||
= m_createdObjects.constBegin();
|
||||
it != m_createdObjects.constEnd(); ++it) {
|
||||
|
||||
const QmlJS::Document::Ptr &doc = it.key();
|
||||
@@ -373,7 +392,8 @@ private:
|
||||
static inline QString stripQuotes(const QString &str)
|
||||
{
|
||||
if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
|
||||
|| (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
|
||||
|| (str.startsWith(QLatin1Char('\''))
|
||||
&& str.endsWith(QLatin1Char('\''))))
|
||||
return str.mid(1, str.length() - 2);
|
||||
|
||||
return str;
|
||||
@@ -392,11 +412,13 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
static QString cleanExpression(const QString &expression, UiScriptBinding *scriptBinding)
|
||||
static QString cleanExpression(const QString &expression,
|
||||
UiScriptBinding *scriptBinding)
|
||||
{
|
||||
QString trimmedExpression = expression.trimmed();
|
||||
|
||||
if (ExpressionStatement *expStatement = cast<ExpressionStatement*>(scriptBinding->statement)) {
|
||||
if (ExpressionStatement *expStatement
|
||||
= cast<ExpressionStatement*>(scriptBinding->statement)) {
|
||||
if (expStatement->semicolonToken.isValid())
|
||||
trimmedExpression.chop(1);
|
||||
}
|
||||
@@ -410,9 +432,11 @@ private:
|
||||
return true;
|
||||
else if (cast<StringLiteral*>(expr))
|
||||
return true;
|
||||
else if (UnaryPlusExpression *plusExpr = cast<UnaryPlusExpression*>(expr))
|
||||
else if (UnaryPlusExpression *plusExpr
|
||||
= cast<UnaryPlusExpression*>(expr))
|
||||
return isLiteralValue(plusExpr->expression);
|
||||
else if (UnaryMinusExpression *minusExpr = cast<UnaryMinusExpression*>(expr))
|
||||
else if (UnaryMinusExpression *minusExpr
|
||||
= cast<UnaryMinusExpression*>(expr))
|
||||
return isLiteralValue(minusExpr->expression);
|
||||
else if (cast<TrueLiteral*>(expr))
|
||||
return true;
|
||||
@@ -427,19 +451,22 @@ private:
|
||||
if (!script || !script->statement)
|
||||
return false;
|
||||
|
||||
ExpressionStatement *exprStmt = cast<ExpressionStatement *>(script->statement);
|
||||
ExpressionStatement *exprStmt
|
||||
= cast<ExpressionStatement *>(script->statement);
|
||||
if (exprStmt)
|
||||
return isLiteralValue(exprStmt->expression);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static QVariant castToLiteral(const QString &expression, UiScriptBinding *scriptBinding)
|
||||
static QVariant castToLiteral(const QString &expression,
|
||||
UiScriptBinding *scriptBinding)
|
||||
{
|
||||
const QString cleanedValue = cleanExpression(expression, scriptBinding);
|
||||
QVariant castedExpression;
|
||||
|
||||
ExpressionStatement *expStatement = cast<ExpressionStatement*>(scriptBinding->statement);
|
||||
ExpressionStatement *expStatement
|
||||
= cast<ExpressionStatement*>(scriptBinding->statement);
|
||||
|
||||
switch(expStatement->expression->kind) {
|
||||
case Node::Kind_NumericLiteral:
|
||||
@@ -464,8 +491,10 @@ private:
|
||||
|
||||
protected:
|
||||
virtual void updateMethodBody(DebugId debugId,
|
||||
UiObjectMember *parentDefinition, UiScriptBinding* scriptBinding,
|
||||
const QString& methodName, const QString& methodBody)
|
||||
UiObjectMember *parentDefinition,
|
||||
UiScriptBinding *scriptBinding,
|
||||
const QString &methodName,
|
||||
const QString &methodBody)
|
||||
{
|
||||
Q_UNUSED(scriptBinding);
|
||||
Q_UNUSED(parentDefinition);
|
||||
@@ -474,15 +503,21 @@ protected:
|
||||
}
|
||||
|
||||
virtual void updateScriptBinding(DebugId debugId,
|
||||
UiObjectMember *parentDefinition, UiScriptBinding* scriptBinding,
|
||||
const QString& propertyName, const QString& scriptCode)
|
||||
UiObjectMember *parentDefinition,
|
||||
UiScriptBinding *scriptBinding,
|
||||
const QString &propertyName,
|
||||
const QString &scriptCode)
|
||||
{
|
||||
if (unsyncronizableChanges == QmlJSLiveTextPreview::NoUnsyncronizableChanges) {
|
||||
if (unsyncronizableChanges
|
||||
== QmlJSLiveTextPreview::NoUnsyncronizableChanges) {
|
||||
if (propertyName == QLatin1String("id")) {
|
||||
unsyncronizableElementName = propertyName;
|
||||
unsyncronizableChanges = QmlJSLiveTextPreview::AttributeChangeWarning;
|
||||
unsyncronizableChangeLine = parentDefinition->firstSourceLocation().startLine;
|
||||
unsyncronizableChangeColumn = parentDefinition->firstSourceLocation().startColumn;
|
||||
unsyncronizableChanges
|
||||
= QmlJSLiveTextPreview::AttributeChangeWarning;
|
||||
unsyncronizableChangeLine
|
||||
= parentDefinition->firstSourceLocation().startLine;
|
||||
unsyncronizableChangeColumn
|
||||
= parentDefinition->firstSourceLocation().startColumn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,8 +544,10 @@ protected:
|
||||
m_clientProxy->destroyQmlObject(debugId);
|
||||
}
|
||||
|
||||
virtual void createObject(const QString& qmlText, DebugId ref,
|
||||
const QStringList& importList, const QString& filename, int order)
|
||||
virtual void createObject(const QString &qmlText, DebugId ref,
|
||||
const QStringList &importList,
|
||||
const QString &filename,
|
||||
int order)
|
||||
{
|
||||
appliedChangesToViewer = true;
|
||||
referenceRefreshRequired = true;
|
||||
@@ -530,10 +567,14 @@ protected:
|
||||
if (parentDefinition && parentDefinition->qualifiedTypeNameId
|
||||
&& !parentDefinition->qualifiedTypeNameId->name.isEmpty())
|
||||
{
|
||||
unsyncronizableElementName = parentDefinition->qualifiedTypeNameId->name.toString();
|
||||
unsyncronizableChanges = QmlJSLiveTextPreview::ElementChangeWarning;
|
||||
unsyncronizableChangeLine = parentDefinition->firstSourceLocation().startLine;
|
||||
unsyncronizableChangeColumn = parentDefinition->firstSourceLocation().startColumn;
|
||||
unsyncronizableElementName
|
||||
= parentDefinition->qualifiedTypeNameId->name.toString();
|
||||
unsyncronizableChanges
|
||||
= QmlJSLiveTextPreview::ElementChangeWarning;
|
||||
unsyncronizableChangeLine
|
||||
= parentDefinition->firstSourceLocation().startLine;
|
||||
unsyncronizableChangeColumn
|
||||
= parentDefinition->firstSourceLocation().startColumn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -576,15 +617,19 @@ void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
|
||||
if (delta.referenceRefreshRequired)
|
||||
m_clientProxy.data()->refreshObjectTree();
|
||||
|
||||
if (InspectorUi::instance()->showExperimentalWarning() && delta.appliedChangesToViewer) {
|
||||
if (InspectorUi::instance()->showExperimentalWarning()
|
||||
&& delta.appliedChangesToViewer) {
|
||||
showExperimentalWarning();
|
||||
experimentalWarningShown = true;
|
||||
InspectorUi::instance()->setShowExperimentalWarning(false);
|
||||
}
|
||||
|
||||
if (delta.unsyncronizableChanges != NoUnsyncronizableChanges && !experimentalWarningShown)
|
||||
showSyncWarning(delta.unsyncronizableChanges, delta.unsyncronizableElementName,
|
||||
delta.unsyncronizableChangeLine, delta.unsyncronizableChangeColumn);
|
||||
if (delta.unsyncronizableChanges != NoUnsyncronizableChanges
|
||||
&& !experimentalWarningShown)
|
||||
showSyncWarning(delta.unsyncronizableChanges,
|
||||
delta.unsyncronizableElementName,
|
||||
delta.unsyncronizableChangeLine,
|
||||
delta.unsyncronizableChangeColumn);
|
||||
|
||||
m_previousDoc = doc;
|
||||
if (!delta.newObjects.isEmpty())
|
||||
@@ -603,24 +648,30 @@ void QmlJSLiveTextPreview::showExperimentalWarning()
|
||||
if (editor) {
|
||||
Core::InfoBarEntry info(
|
||||
Constants::INFO_EXPERIMENTAL,
|
||||
tr("You changed a QML file in Live Preview mode, which modifies the running QML application. "
|
||||
"In case of unexpected behavior, please reload the QML application."));
|
||||
info.setCustomButtonInfo(tr("Disable Live Preview"), this, SLOT(disableLivePreview()));
|
||||
tr("You changed a QML file in Live Preview mode, which "
|
||||
"modifies the running QML application. In case of "
|
||||
"unexpected behavior, please reload the QML "
|
||||
"application."));
|
||||
info.setCustomButtonInfo(tr("Disable Live Preview"), this,
|
||||
SLOT(disableLivePreview()));
|
||||
editor.data()->editorDocument()->infoBar()->addInfo(info);
|
||||
}
|
||||
}
|
||||
|
||||
void QmlJSLiveTextPreview::showSyncWarning(UnsyncronizableChangeType unsyncronizableChangeType,
|
||||
const QString &elementName, unsigned line, unsigned column)
|
||||
void QmlJSLiveTextPreview::showSyncWarning(
|
||||
UnsyncronizableChangeType unsyncronizableChangeType,
|
||||
const QString &elementName, unsigned line, unsigned column)
|
||||
{
|
||||
QString errorMessage;
|
||||
switch (unsyncronizableChangeType) {
|
||||
case AttributeChangeWarning:
|
||||
errorMessage = tr("The %1 attribute at line %2, column %3 cannot be changed without reloading the QML application. ")
|
||||
errorMessage = tr("The %1 attribute at line %2, column %3 cannot be "
|
||||
"changed without reloading the QML application. ")
|
||||
.arg(elementName, QString::number(line), QString::number(column));
|
||||
break;
|
||||
case ElementChangeWarning:
|
||||
errorMessage = tr("The %1 element at line %2, column %3 cannot be changed without reloading the QML application. ")
|
||||
errorMessage = tr("The %1 element at line %2, column %3 cannot be "
|
||||
"changed without reloading the QML application. ")
|
||||
.arg(elementName, QString::number(line), QString::number(column));
|
||||
break;
|
||||
case QmlJSLiveTextPreview::NoUnsyncronizableChanges:
|
||||
@@ -630,25 +681,35 @@ void QmlJSLiveTextPreview::showSyncWarning(UnsyncronizableChangeType unsyncroniz
|
||||
|
||||
errorMessage.append(tr("You can continue debugging, but behavior can be unexpected."));
|
||||
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
|
||||
if (editor)
|
||||
editor.data()->editorDocument()->infoBar()->addInfo(Core::InfoBarEntry(
|
||||
QLatin1String(Constants::INFO_OUT_OF_SYNC), errorMessage));
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors) {
|
||||
if (editor) {
|
||||
Core::InfoBar *infoBar = editor.data()->editorDocument()->infoBar();
|
||||
infoBar->addInfo(Core::InfoBarEntry(
|
||||
QLatin1String(Constants::INFO_OUT_OF_SYNC),
|
||||
errorMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QmlJSLiveTextPreview::reloadQmlViewer()
|
||||
{
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
|
||||
if (editor)
|
||||
editor.data()->editorDocument()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC);
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors) {
|
||||
if (editor) {
|
||||
Core::InfoBar *infoBar = editor.data()->editorDocument()->infoBar();
|
||||
infoBar->removeInfo(Constants::INFO_OUT_OF_SYNC);
|
||||
}
|
||||
}
|
||||
emit reloadQmlViewerRequested();
|
||||
}
|
||||
|
||||
void QmlJSLiveTextPreview::disableLivePreview()
|
||||
{
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors)
|
||||
if (editor)
|
||||
editor.data()->editorDocument()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC);
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editor, m_editors) {
|
||||
if (editor) {
|
||||
Core::InfoBar *infoBar = editor.data()->editorDocument()->infoBar();
|
||||
infoBar->removeInfo(Constants::INFO_OUT_OF_SYNC);
|
||||
}
|
||||
}
|
||||
emit disableLivePreviewRequested();
|
||||
}
|
||||
|
||||
@@ -677,15 +738,21 @@ void QmlJSLiveTextPreview::setClientProxy(ClientProxy *clientProxy)
|
||||
connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()),
|
||||
SLOT(updateDebugIds()));
|
||||
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget, m_editors)
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget,
|
||||
m_editors)
|
||||
if (editWidget)
|
||||
connect(editWidget.data(), SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
||||
this, SLOT(changeSelectedElements(QList<int>,QString)));
|
||||
connect(editWidget.data(),
|
||||
SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
||||
this,
|
||||
SLOT(changeSelectedElements(QList<int>,QString)));
|
||||
} else {
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget, m_editors)
|
||||
foreach (QWeakPointer<TextEditor::BaseTextEditorWidget> editWidget,
|
||||
m_editors)
|
||||
if (editWidget)
|
||||
disconnect(editWidget.data(), SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
||||
this, SLOT(changeSelectedElements(QList<int>,QString)));
|
||||
disconnect(editWidget.data(),
|
||||
SIGNAL(selectedElementsChanged(QList<int>,QString)),
|
||||
this,
|
||||
SLOT(changeSelectedElements(QList<int>,QString)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,8 +99,10 @@ private slots:
|
||||
private:
|
||||
static QmlJS::ModelManagerInterface *modelManager();
|
||||
QList<int> objectReferencesForOffset(quint32 offset);
|
||||
QVariant castToLiteral(const QString &expression, QmlJS::AST::UiScriptBinding *scriptBinding);
|
||||
void showSyncWarning(UnsyncronizableChangeType unsyncronizableChangeType, const QString &elementName,
|
||||
QVariant castToLiteral(const QString &expression,
|
||||
QmlJS::AST::UiScriptBinding *scriptBinding);
|
||||
void showSyncWarning(UnsyncronizableChangeType unsyncronizableChangeType,
|
||||
const QString &elementName,
|
||||
unsigned line, unsigned column);
|
||||
void showExperimentalWarning();
|
||||
|
||||
|
||||
@@ -76,10 +76,19 @@ public:
|
||||
|
||||
case QmlJSPropertyInspector::BooleanType: {
|
||||
// invert the bool, skip editor
|
||||
int objectId = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::UserRole).toInt();
|
||||
QString propertyName = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::DisplayRole).toString();
|
||||
bool propertyValue = m_treeWidget->getData(index.row(), PROPERTY_VALUE_COLUMN, Qt::DisplayRole).toBool();
|
||||
m_treeWidget->propertyValueEdited(objectId, propertyName, !propertyValue?"true":"false", true);
|
||||
int objectId = m_treeWidget->getData(index.row(),
|
||||
PROPERTY_NAME_COLUMN,
|
||||
Qt::UserRole).toInt();
|
||||
QString propertyName
|
||||
= m_treeWidget->getData(index.row(),
|
||||
PROPERTY_NAME_COLUMN,
|
||||
Qt::DisplayRole).toString();
|
||||
bool propertyValue
|
||||
= m_treeWidget->getData(index.row(), PROPERTY_VALUE_COLUMN,
|
||||
Qt::DisplayRole).toBool();
|
||||
m_treeWidget->propertyValueEdited(objectId, propertyName,
|
||||
!propertyValue?"true":"false",
|
||||
true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -99,23 +108,29 @@ public:
|
||||
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
QVariant data = m_treeWidget->getData(index.row(), PROPERTY_VALUE_COLUMN, Qt::DisplayRole);
|
||||
QVariant data = m_treeWidget->getData(index.row(), PROPERTY_VALUE_COLUMN,
|
||||
Qt::DisplayRole);
|
||||
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
|
||||
lineEdit->setText(data.toString());
|
||||
}
|
||||
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(model);
|
||||
|
||||
int objectId = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::UserRole).toInt();
|
||||
int objectId = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN,
|
||||
Qt::UserRole).toInt();
|
||||
if (objectId == -1)
|
||||
return;
|
||||
|
||||
QString propertyName = m_treeWidget->getData(index.row(), PROPERTY_NAME_COLUMN, Qt::DisplayRole).toString();
|
||||
QString propertyName = m_treeWidget->getData(index.row(),
|
||||
PROPERTY_NAME_COLUMN,
|
||||
Qt::DisplayRole).toString();
|
||||
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
|
||||
QString propertyValue = lineEdit->text();
|
||||
m_treeWidget->propertyValueEdited(objectId, propertyName, propertyValue, true);
|
||||
m_treeWidget->propertyValueEdited(objectId, propertyName, propertyValue,
|
||||
true);
|
||||
lineEdit->clearFocus();
|
||||
}
|
||||
|
||||
@@ -138,7 +153,8 @@ private:
|
||||
|
||||
ExpressionEdit::ExpressionEdit(const QString &title, QDialog *parent)
|
||||
: QDialog(parent)
|
||||
, m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel))
|
||||
, m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok
|
||||
| QDialogButtonBox::Cancel))
|
||||
, m_exprInput(new QLineEdit(this))
|
||||
{
|
||||
setWindowTitle(title);
|
||||
@@ -179,7 +195,9 @@ inline QString extendedNameFromColor(QColor color)
|
||||
{
|
||||
int alphaValue = color.alpha();
|
||||
if (alphaValue < 255)
|
||||
return QLatin1String("#") + QString("%1").arg(alphaValue, 2, 16, QChar('0')) + color.name().right(6) ;
|
||||
return QLatin1String("#")
|
||||
+ QString("%1").arg(alphaValue, 2, 16, QChar('0'))
|
||||
+ color.name().right(6) ;
|
||||
else
|
||||
return color.name();
|
||||
}
|
||||
@@ -214,7 +232,8 @@ ColorChooserDialog::ColorChooserDialog(const QString &title, QDialog *parent)
|
||||
connect(m_mainFrame,SIGNAL(rejected()),this,SLOT(reject()));
|
||||
}
|
||||
|
||||
void ColorChooserDialog::setItemData(int objectId, const QString &propertyName, const QString& colorName)
|
||||
void ColorChooserDialog::setItemData(int objectId, const QString &propertyName,
|
||||
const QString &colorName)
|
||||
{
|
||||
m_debugId = objectId;
|
||||
m_paramName = propertyName;
|
||||
@@ -224,7 +243,8 @@ void ColorChooserDialog::setItemData(int objectId, const QString &propertyName,
|
||||
void ColorChooserDialog::acceptColor(const QColor &color)
|
||||
{
|
||||
QDialog::accept();
|
||||
emit dataChanged(m_debugId, m_paramName, QChar('\"')+color.name()+QChar('\"'));
|
||||
emit dataChanged(m_debugId, m_paramName,
|
||||
QChar('\"') + color.name() + QChar('\"'));
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
@@ -253,7 +273,8 @@ Qt::ItemFlags QmlJSPropertyInspectorModel::flags(const QModelIndex &index) const
|
||||
return m_contentsValid ? QStandardItemModel::flags(index) : Qt::ItemFlags();
|
||||
}
|
||||
|
||||
QVariant QmlJSPropertyInspectorModel::headerData(int section, Qt::Orientation orient, int role) const
|
||||
QVariant QmlJSPropertyInspectorModel::headerData(
|
||||
int section, Qt::Orientation orient, int role) const
|
||||
{
|
||||
if (orient == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||
switch (section) {
|
||||
@@ -278,7 +299,8 @@ bool QmlJSPropertyInspectorModel::contentsValid() const
|
||||
QmlJSPropertyInspector::QmlJSPropertyInspector(QWidget *parent)
|
||||
: Utils::BaseTreeView(parent)
|
||||
{
|
||||
setItemDelegateForColumn(PROPERTY_VALUE_COLUMN, new PropertyEditDelegate(this));
|
||||
setItemDelegateForColumn(PROPERTY_VALUE_COLUMN,
|
||||
new PropertyEditDelegate(this));
|
||||
|
||||
setModel(&m_model);
|
||||
//Add an empty Row to make the headers visible!
|
||||
@@ -301,7 +323,8 @@ bool QmlJSPropertyInspector::contentsValid() const
|
||||
return m_model.contentsValid();
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::setCurrentObjects(const QList<QmlDebugObjectReference> &objectList)
|
||||
void QmlJSPropertyInspector::setCurrentObjects(
|
||||
const QList<QmlDebugObjectReference> &objectList)
|
||||
{
|
||||
if (objectList.isEmpty())
|
||||
return;
|
||||
@@ -319,26 +342,35 @@ QVariant QmlJSPropertyInspector::getData(int row, int column, int role) const
|
||||
return m_model.data(m_model.index(row, column), role);
|
||||
}
|
||||
|
||||
QmlJSPropertyInspector::PropertyType QmlJSPropertyInspector::getTypeFor(int row) const
|
||||
QmlJSPropertyInspector::PropertyType
|
||||
QmlJSPropertyInspector::getTypeFor(int row) const
|
||||
{
|
||||
return static_cast<QmlJSPropertyInspector::PropertyType>(m_model.data(m_model.index(row, PROPERTY_TYPE_COLUMN), Qt::UserRole).toInt());
|
||||
return static_cast<QmlJSPropertyInspector::PropertyType>(
|
||||
m_model.data(m_model.index(row, PROPERTY_TYPE_COLUMN),
|
||||
Qt::UserRole).toInt());
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue)
|
||||
void QmlJSPropertyInspector::propertyValueChanged(int debugId,
|
||||
const QByteArray &propertyName,
|
||||
const QVariant &propertyValue)
|
||||
{
|
||||
if (m_model.rowCount() == 0)
|
||||
return;
|
||||
|
||||
QString propertyNameS = QString(propertyName);
|
||||
for (int i = 0; i < m_model.rowCount(); i++) {
|
||||
if (m_model.data(m_model.index(i, PROPERTY_NAME_COLUMN), Qt::DisplayRole).toString() == propertyNameS &&
|
||||
m_model.data(m_model.index(i, PROPERTY_NAME_COLUMN), Qt::UserRole).toInt() == debugId) {
|
||||
QString oldData = m_model.data(m_model.index(i, PROPERTY_VALUE_COLUMN), Qt::DisplayRole).toString();
|
||||
if (m_model.data(m_model.index(i, PROPERTY_NAME_COLUMN),
|
||||
Qt::DisplayRole).toString() == propertyNameS &&
|
||||
m_model.data(m_model.index(i, PROPERTY_NAME_COLUMN),
|
||||
Qt::UserRole).toInt() == debugId) {
|
||||
QString oldData = m_model.data(m_model.index(i, PROPERTY_VALUE_COLUMN),
|
||||
Qt::DisplayRole).toString();
|
||||
QString newData = propertyValue.toString();
|
||||
if (QString(propertyValue.typeName()) == "QColor")
|
||||
newData = extendedNameFromColor(propertyValue);
|
||||
if (oldData != newData) {
|
||||
m_model.setData(m_model.index(i, PROPERTY_VALUE_COLUMN), newData, Qt::DisplayRole);
|
||||
m_model.setData(m_model.index(i, PROPERTY_VALUE_COLUMN), newData,
|
||||
Qt::DisplayRole);
|
||||
m_model.item(i, PROPERTY_VALUE_COLUMN)->setToolTip(newData);
|
||||
m_model.item(i, PROPERTY_NAME_COLUMN)->setForeground(QBrush(Qt::red));
|
||||
m_model.item(i, PROPERTY_VALUE_COLUMN)->setForeground(QBrush(Qt::red));
|
||||
@@ -352,8 +384,8 @@ void QmlJSPropertyInspector::propertyValueChanged(int debugId, const QByteArray
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::propertyValueEdited(const int objectId,
|
||||
const QString& propertyName,
|
||||
const QString& propertyValue,
|
||||
const QString &propertyName,
|
||||
const QString &propertyValue,
|
||||
bool isLiteral)
|
||||
{
|
||||
emit changePropertyValue(objectId, propertyName, propertyValue, isLiteral);
|
||||
@@ -365,7 +397,8 @@ void QmlJSPropertyInspector::buildPropertyTree(const QmlDebugObjectReference &ob
|
||||
QString objTypeName = obj.className();
|
||||
QString declarativeString("QDeclarative");
|
||||
if (objTypeName.startsWith(declarativeString)) {
|
||||
objTypeName = objTypeName.mid(declarativeString.length()).section('_',0,0);
|
||||
objTypeName = objTypeName.mid(declarativeString.length()).section('_',
|
||||
0, 0);
|
||||
}
|
||||
|
||||
// class
|
||||
@@ -395,7 +428,8 @@ void QmlJSPropertyInspector::buildPropertyTree(const QmlDebugObjectReference &ob
|
||||
propertyValue = extendedNameFromColor(prop.value());
|
||||
}
|
||||
|
||||
addRow(propertyName, propertyValue, prop.valueTypeName(), obj.debugId(), prop.hasNotifySignal());
|
||||
addRow(propertyName, propertyValue, prop.valueTypeName(), obj.debugId(),
|
||||
prop.hasNotifySignal());
|
||||
}
|
||||
|
||||
m_model.setHeaderData(PROPERTY_NAME_COLUMN, Qt::Horizontal,QVariant("name"));
|
||||
@@ -404,8 +438,9 @@ void QmlJSPropertyInspector::buildPropertyTree(const QmlDebugObjectReference &ob
|
||||
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::addRow(const QString &name,const QString &value, const QString &type,
|
||||
const int debugId, bool editable)
|
||||
void QmlJSPropertyInspector::addRow(const QString &name,const QString &value,
|
||||
const QString &type, const int debugId,
|
||||
bool editable)
|
||||
{
|
||||
QStandardItem *nameColumn = new QStandardItem(name);
|
||||
nameColumn->setToolTip(name);
|
||||
@@ -422,7 +457,8 @@ void QmlJSPropertyInspector::addRow(const QString &name,const QString &value, co
|
||||
typeColumn->setEditable(false);
|
||||
|
||||
// encode type for easy lookup
|
||||
QmlJSPropertyInspector::PropertyType typeCode = QmlJSPropertyInspector::OtherType;
|
||||
QmlJSPropertyInspector::PropertyType typeCode
|
||||
= QmlJSPropertyInspector::OtherType;
|
||||
if (type == "bool")
|
||||
typeCode = QmlJSPropertyInspector::BooleanType;
|
||||
else if (type == "qreal")
|
||||
@@ -492,9 +528,11 @@ void QmlJSPropertyInspector::contextMenuEvent(QContextMenuEvent *ev)
|
||||
|
||||
void QmlJSPropertyInspector::openExpressionEditor(const QModelIndex &itemIndex)
|
||||
{
|
||||
const QString propertyName = getData(itemIndex.row(), PROPERTY_NAME_COLUMN, Qt::DisplayRole).toString();
|
||||
const QString propertyName = getData(itemIndex.row(), PROPERTY_NAME_COLUMN,
|
||||
Qt::DisplayRole).toString();
|
||||
const QString dialogText = tr("JavaScript expression for %1").arg(propertyName);
|
||||
const int objectId = getData(itemIndex.row(), PROPERTY_NAME_COLUMN, Qt::UserRole).toInt();
|
||||
const int objectId = getData(itemIndex.row(), PROPERTY_NAME_COLUMN,
|
||||
Qt::UserRole).toInt();
|
||||
|
||||
ExpressionEdit *expressionDialog = new ExpressionEdit(dialogText);
|
||||
expressionDialog->setItemData(objectId, propertyName);
|
||||
@@ -507,10 +545,13 @@ void QmlJSPropertyInspector::openExpressionEditor(const QModelIndex &itemIndex)
|
||||
|
||||
void QmlJSPropertyInspector::openColorSelector(const QModelIndex &itemIndex)
|
||||
{
|
||||
const QString propertyName = getData(itemIndex.row(), PROPERTY_NAME_COLUMN, Qt::DisplayRole).toString();
|
||||
const QString propertyName = getData(itemIndex.row(), PROPERTY_NAME_COLUMN,
|
||||
Qt::DisplayRole).toString();
|
||||
const QString dialogText = tr("Color selection for %1").arg(propertyName);
|
||||
const int objectId = getData(itemIndex.row(), PROPERTY_NAME_COLUMN, Qt::UserRole).toInt();
|
||||
const QString propertyValue = getData(itemIndex.row(), PROPERTY_VALUE_COLUMN, Qt::DisplayRole).toString();
|
||||
const int objectId = getData(itemIndex.row(), PROPERTY_NAME_COLUMN,
|
||||
Qt::UserRole).toInt();
|
||||
const QString propertyValue = getData(itemIndex.row(), PROPERTY_VALUE_COLUMN,
|
||||
Qt::DisplayRole).toString();
|
||||
|
||||
ColorChooserDialog *colorDialog = new ColorChooserDialog(dialogText);
|
||||
colorDialog->setItemData(objectId, propertyName, propertyValue);
|
||||
|
||||
@@ -62,7 +62,8 @@ public:
|
||||
virtual void accept();
|
||||
|
||||
signals:
|
||||
void dataChanged(int debugId, const QString ¶mName, const QString &newExpression);
|
||||
void dataChanged(int debugId, const QString ¶mName,
|
||||
const QString &newExpression);
|
||||
|
||||
private:
|
||||
QDialogButtonBox *m_buttonBox;
|
||||
@@ -77,13 +78,15 @@ class ColorChooserDialog : public QDialog
|
||||
public:
|
||||
explicit ColorChooserDialog(const QString &title, QDialog *parent = 0);
|
||||
|
||||
void setItemData(int objectId,const QString &propertyName, const QString &colorName);
|
||||
void setItemData(int objectId,const QString &propertyName,
|
||||
const QString &colorName);
|
||||
|
||||
public slots:
|
||||
void acceptColor(const QColor &color);
|
||||
|
||||
signals:
|
||||
void dataChanged(int debugId, const QString ¶mName, const QString &newExpression);
|
||||
void dataChanged(int debugId, const QString ¶mName,
|
||||
const QString &newExpression);
|
||||
|
||||
|
||||
private:
|
||||
@@ -127,15 +130,16 @@ public:
|
||||
bool contentsValid() const;
|
||||
|
||||
signals:
|
||||
void changePropertyValue(int debugId, QString propertyName, QString valueExpression,
|
||||
bool isLiteral);
|
||||
void changePropertyValue(int debugId, QString propertyName,
|
||||
QString valueExpression, bool isLiteral);
|
||||
void customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
public slots:
|
||||
void setCurrentObjects(const QList<QmlDebugObjectReference> &);
|
||||
void propertyValueEdited(const int objectId,const QString &propertyName, const QString &propertyValue,
|
||||
bool isLiteral = false);
|
||||
void propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
||||
void propertyValueEdited(const int objectId,const QString &propertyName,
|
||||
const QString &propertyValue, bool isLiteral = false);
|
||||
void propertyValueChanged(int debugId, const QByteArray &propertyName,
|
||||
const QVariant &propertyValue);
|
||||
|
||||
void openExpressionEditor(const QModelIndex &itemIndex);
|
||||
void openColorSelector(const QModelIndex &itemIndex);
|
||||
|
||||
Reference in New Issue
Block a user