Commit 034898ca authored by Don Gagne's avatar Don Gagne

parent cfc8d1ab
...@@ -10,29 +10,41 @@ Item { ...@@ -10,29 +10,41 @@ Item {
visible: false visible: false
property var rgDynamicObjects: [ ] property var rgDynamicObjects: [ ]
property bool empty: rgDynamicObjects.length === 0
function createObject(sourceComponent, parentObject, parentObjectIsMap) { Component.onDestruction: destroyObjects()
function createObject(sourceComponent, parentObject, addMapItem) {
var obj = sourceComponent.createObject(parentObject) var obj = sourceComponent.createObject(parentObject)
if (obj.status === Component.Error) { if (obj.status === Component.Error) {
console.log(obj.errorString()) console.log(obj.errorString())
} }
rgDynamicObjects.push(obj) rgDynamicObjects.push(obj)
if (arguments.length < 3) { if (arguments.length < 3) {
parentObjectIsMap = false addMapItem = false
} }
if (parentObjectIsMap) { if (addMapItem) {
map.addMapItem(obj) parentObject.addMapItem(obj)
} }
return obj return obj
} }
function createObjects(rgSourceComponents, parentObject, parentObjectIsMap) { function createObjects(rgSourceComponents, parentObject, addMapItem) {
if (arguments.length < 3) { if (arguments.length < 3) {
parentObjectIsMap = false addMapItem = false
} }
for (var i=0; i<rgSourceComponents.length; i++) { for (var i=0; i<rgSourceComponents.length; i++) {
createObject(rgSourceComponents[i], parentObject, parentObjectIsMap) createObject(rgSourceComponents[i], parentObject, addMapItem)
}
}
/// Adds the object to the list. If mapControl is specified it will aso be added to the map.
function addObject(object, mapControl) {
rgDynamicObjects.push(object)
if (arguments.length == 2) {
mapControl.addMapItem(object)
} }
return object
} }
function destroyObjects() { function destroyObjects() {
......
Markdown is supported
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