summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristiaan Janssen <christiaan.janssen@nokia.com>2010-09-22 16:28:13 +0200
committerChristiaan Janssen <christiaan.janssen@nokia.com>2010-09-22 16:30:21 +0200
commit0bc0a2df5a8faf4286800c6530a515e26a54a0c0 (patch)
treece2fee1868f2099cc5fae4a723a6ea1c05d93cba
parent02283ea84de4ff8c5d91050bd2e8aaae4a60d9bd (diff)
downloadqt-creator-0bc0a2df5a8faf4286800c6530a515e26a54a0c0.tar.gz
QmlObserver: showing a warning when changes cannot be synchronized
Reviewed by: Thomas Hartmann
-rw-r--r--src/libs/qmljs/qmljsdelta.cpp20
-rw-r--r--src/libs/qmljs/qmljsdelta.h1
-rw-r--r--src/plugins/qmljsinspector/qmljslivetextpreview.cpp38
3 files changed, 24 insertions, 35 deletions
diff --git a/src/libs/qmljs/qmljsdelta.cpp b/src/libs/qmljs/qmljsdelta.cpp
index 4cadf2f334..da0022a419 100644
--- a/src/libs/qmljs/qmljsdelta.cpp
+++ b/src/libs/qmljs/qmljsdelta.cpp
@@ -390,6 +390,9 @@ void Delta::update(UiObjectMember* oldObject, const QmlJS::Document::Ptr& oldDoc
const QString scriptCode = _scriptCode(script, newDoc);
UiScriptBinding *previousScript = cast<UiScriptBinding *>(oldMember);
if (!previousScript || _scriptCode(previousScript, oldDoc) != scriptCode) {
+ if (debugReferences.count()==0) {
+ notifyUnsyncronizableElementChange(newObject);
+ }
foreach (DebugId ref, debugReferences) {
if (ref != -1)
updateScriptBinding(ref, newObject, script, property, scriptCode);
@@ -401,6 +404,9 @@ void Delta::update(UiObjectMember* oldObject, const QmlJS::Document::Ptr& oldDoc
UiSourceElement *previousSource = cast<UiSourceElement*>(oldMember);
if (!previousSource || _methodCode(previousSource, oldDoc) != methodCode) {
+ if (debugReferences.count()==0) {
+ notifyUnsyncronizableElementChange(newObject);
+ }
foreach (DebugId ref, debugReferences) {
if (ref != -1)
updateMethodBody(ref, newObject, script, methodName, methodCode);
@@ -476,10 +482,13 @@ Delta::DebugIdMap Delta::operator()(const Document::Ptr &doc1, const Document::P
UiObjectMember *x = M.way2[y];
Q_ASSERT(cast<UiObjectDefinition *>(x) || cast<UiObjectBinding *>(x) );
- if (debugIds.contains(x)) {
- QList<DebugId> ids = debugIds[x];
- newDebuggIds[y] = ids;
- update(x, doc1, y, doc2, ids);
+ {
+ QList<DebugId> updateIds;
+ if (debugIds.contains(x)) {
+ updateIds = debugIds[x];
+ newDebuggIds[y] = updateIds;
+ }
+ update(x, doc1, y, doc2, updateIds);
}
//qDebug() << "Delta::operator(): match "<< label(x, doc1) << "with parent " << label(parents1.parent.value(x), doc1)
// << " to "<< label(y, doc2) << "with parent " << label(parents2.parent.value(y), doc2);
@@ -533,5 +542,8 @@ void Delta::updateMethodBody(DebugId, UiObjectMember *, UiScriptBinding *, const
void Delta::updateScriptBinding(DebugId, UiObjectMember *, UiScriptBinding *, const QString &, const QString &)
{}
+void Delta::notifyUnsyncronizableElementChange(UiObjectMember *)
+{}
+
} //namespace QmlJs
diff --git a/src/libs/qmljs/qmljsdelta.h b/src/libs/qmljs/qmljsdelta.h
index d6c6660b0e..385d0f6934 100644
--- a/src/libs/qmljs/qmljsdelta.h
+++ b/src/libs/qmljs/qmljsdelta.h
@@ -72,6 +72,7 @@ protected:
virtual void reparentObject(int debugId, int newParent);
virtual void createObject(const QString &qmlText, DebugId ref,
const QStringList &importList, const QString &filename);
+ virtual void notifyUnsyncronizableElementChange(AST::UiObjectMember *parent);
private:
QmlJS::Document::Ptr m_currentDoc;
diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
index 94dbe08ee7..7dca4c4e42 100644
--- a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
+++ b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp
@@ -426,7 +426,7 @@ protected:
const QString& methodName, const QString& methodBody)
{
Q_UNUSED(scriptBinding);
- checkUnsyncronizableElementChanges(parentDefinition);
+ Q_UNUSED(parentDefinition);
appliedChangesToViewer = true;
m_clientProxy->setMethodBodyForObject(debugId, methodName, methodBody);
}
@@ -442,7 +442,6 @@ protected:
unsyncronizableChangeLine = parentDefinition->firstSourceLocation().startLine;
unsyncronizableChangeColumn = parentDefinition->firstSourceLocation().startColumn;
}
- checkUnsyncronizableElementChanges(parentDefinition);
}
QVariant expr = scriptCode;
@@ -479,38 +478,15 @@ protected:
m_clientProxy->reparentQmlObject(debugId, newParent);
}
- void checkUnsyncronizableElementChanges(UiObjectMember *parent)
+ void notifyUnsyncronizableElementChange(UiObjectMember *parent)
{
- UiObjectDefinition *parentDefinition = cast<UiObjectDefinition *>(parent);
- if (parentDefinition &&
- unsyncronizableChanges == QmlJSLiveTextPreview::NoUnsyncronizableChanges) {
-
- if (parentDefinition->qualifiedTypeNameId
+ if (unsyncronizableChanges == QmlJSLiveTextPreview::NoUnsyncronizableChanges) {
+ UiObjectDefinition *parentDefinition = cast<UiObjectDefinition *>(parent);
+ if (parentDefinition && parentDefinition->qualifiedTypeNameId
&& parentDefinition->qualifiedTypeNameId->name)
{
- QString elementName = parentDefinition->qualifiedTypeNameId->name->asString();
- if (elementName == QLatin1String("PropertyChanges")
- // State element can be changed, but not its contents like PropertyChanges.
- || elementName == QLatin1String("StateGroup")
- || elementName == QLatin1String("StateChangeScript")
- || elementName == QLatin1String("ParentChange")
- || elementName == QLatin1String("AnchorChanges")
- || elementName == QLatin1String("Connections")
- || elementName == QLatin1String("Binding")
- || elementName == QLatin1String("ListModel")
- || elementName == QLatin1String("ListElement")
- || elementName == QLatin1String("VisualItemModel")
- || elementName == QLatin1String("VisualDataModel")
- || elementName == QLatin1String("Package")
- // XmlListModel properties *can* be edited but XmlRole doesn't refresh the model when changed
- || elementName == QLatin1String("XmlRole"))
- {
- unsyncronizableElementName = elementName;
- unsyncronizableChanges = QmlJSLiveTextPreview::ElementChangeWarning;
- }
- }
-
- if (unsyncronizableChanges != QmlJSLiveTextPreview::NoUnsyncronizableChanges) {
+ unsyncronizableElementName = parentDefinition->qualifiedTypeNameId->name->asString();
+ unsyncronizableChanges = QmlJSLiveTextPreview::ElementChangeWarning;
unsyncronizableChangeLine = parentDefinition->firstSourceLocation().startLine;
unsyncronizableChangeColumn = parentDefinition->firstSourceLocation().startColumn;
}