Commit 0bc0a2df authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlObserver: showing a warning when changes cannot be synchronized

Reviewed by:  Thomas Hartmann
parent 02283ea8
......@@ -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
......@@ -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;
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment