Skip to content

Commit

Permalink
Change QMLProperty value constructor to object
Browse files Browse the repository at this point in the history
Constructors are objects so use new keyword.
Change QMLProperty val property to value everywhere
  • Loading branch information
labsin committed Jul 10, 2015
1 parent 0be9fc1 commit 1c200b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
30 changes: 15 additions & 15 deletions src/qtcore/qml/QMLProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ QMLProperty.prototype.update = function() {
if (!this.binding)
return;

var oldVal = this.val;
var oldVal = this.value;
evaluatingProperty = this;
this.val = this.binding.eval(this.objectScope, this.componentScope);
this.value = this.binding.eval(this.objectScope, this.componentScope);
evaluatingProperty = undefined;

if (this.animation) {
this.animation.$actions = [{
target: this.animation.target || this.obj,
property: this.animation.property || this.name,
from: this.animation.from || oldVal,
to: this.animation.to || this.val
to: this.animation.to || this.value
}];
this.animation.restart();
}

if (this.val !== oldVal)
this.changed(this.val, oldVal, this.name);
if (this.value !== oldVal)
this.changed(this.value, oldVal, this.name);
}

// Define getter
Expand All @@ -46,13 +46,13 @@ QMLProperty.prototype.get = function() {
if (evaluatingProperty && !this.changed.isConnected(evaluatingProperty, QMLProperty.prototype.update))
this.changed.connect(evaluatingProperty, QMLProperty.prototype.update);

return this.val;
return this.value;
}

// Define setter
QMLProperty.prototype.set = function(newVal, fromAnimation, objectScope, componentScope) {
var i,
oldVal = this.val;
oldVal = this.value;

if (newVal instanceof QMLBinding) {
if (!objectScope || !componentScope)
Expand Down Expand Up @@ -80,30 +80,30 @@ QMLProperty.prototype.set = function(newVal, fromAnimation, objectScope, compone
}

if (constructors[this.type] == QMLList) {
this.val = QMLList({ object: newVal, parent: this.obj, context: componentScope });
this.value = QMLList({ object: newVal, parent: this.obj, context: componentScope });
} else if (newVal instanceof QMLMetaElement) {
if (constructors[newVal.$class] == QMLComponent || constructors[this.type] == QMLComponent)
this.val = new QMLComponent({ object: newVal, parent: this.obj, context: componentScope });
this.value = new QMLComponent({ object: newVal, parent: this.obj, context: componentScope });
else
this.val = construct({ object: newVal, parent: this.obj, context: componentScope });
this.value = construct({ object: newVal, parent: this.obj, context: componentScope });
} else if (newVal instanceof Object || !newVal) {
this.val = newVal;
this.value = newVal;
} else {
this.val = constructors[this.type](newVal);
this.value = new constructors[this.type](newVal);
}

if (this.val !== oldVal) {
if (this.value !== oldVal) {
if (this.animation && !fromAnimation) {
this.animation.running = false;
this.animation.$actions = [{
target: this.animation.target || this.obj,
property: this.animation.property || this.name,
from: this.animation.from || oldVal,
to: this.animation.to || this.val
to: this.animation.to || this.value
}];
this.animation.running = true;
}
this.changed(this.val, oldVal, this.name);
this.changed(this.value, oldVal, this.name);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/qtcore/qml/qml.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,15 @@ function applyProperties(metaObject, item, objectScope, componentScope) {
} else if (value instanceof QMLAliasDefinition) {
createSimpleProperty("alias", item, i);
item.$properties[i].componentScope = componentScope;
item.$properties[i].val = value;
item.$properties[i].value = value;
item.$properties[i].get = function() {
var obj = this.componentScope[this.val.objectName];
return this.val.propertyName ? obj.$properties[this.val.propertyName].get() : obj;
var obj = this.componentScope[this.value.objectName];
return this.value.propertyName ? obj.$properties[this.value.propertyName].get() : obj;
}
item.$properties[i].set = function(newVal, fromAnimation, objectScope, componentScope) {
if (!this.val.propertyName)
if (!this.value.propertyName)
throw "Cannot set alias property pointing to an QML object.";
this.componentScope[this.val.objectName].$properties[this.val.propertyName].set(newVal, fromAnimation, objectScope, componentScope);
this.componentScope[this.value.objectName].$properties[this.value.propertyName].set(newVal, fromAnimation, objectScope, componentScope);
}
continue;
} else if (value instanceof QMLPropertyDefinition) {
Expand Down

0 comments on commit 1c200b2

Please sign in to comment.