Repeater

Description

The Repeater object is a PropertyModifier object which dynamically creates multiple instances of a delegate object based on a provided model. The created objects are inserted into the target list which the Repeater is operating on.

› Inherits:PropertyModifier

Properties

alternativeParent

This property holds an object which to use as parent for the created delegate objects, i.e. the objects become direct children of the specified object. In most cases this property can be left unset which will create the objects as children of the Repeater’s parent. The resulting object relationships then look exactly as if the objects were created manually without a Repeater.

Note

This property may be set once on initialization only. Later changes to it are ignored.

› Type:Object
› Signal:alternativeParentChanged()
› Attributes:Writable, Optional

delegate

This property holds a component (QML/object type) which is instantiated multiple times depending on the model. Use the local index or modelData properties to parametrize the delegate instances.

› Type:<QML component>
› Signal:delegateChanged()
› Attributes:Writable

error

This property holds the most recently occurred error or Repeater.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.

› Type:Error
› Signal:errorChanged()
› Attributes:Readonly

errorString

This property holds the current human readable error string corresponding to the current value in the error property. It may include additional information such as failure reasons or locations.

› Type:String
› Signal:errorStringChanged()
› Attributes:Readonly

model

This property holds the model which describes the data for the individual delegate instances. This can be a single number, a value array or a different List. Every change to the model will result in a recreation of the delegate objects.

When specifying a single number, N delegates are created with a local property index holding the current delegate index in the range [0..N-1].

For value arrays a delegate for each value is created while the current value is available in a local modelData property.

When using a List object delegates for each list element are created. The corresponding list element is available through a local modelData property.

› Type:Variant
› Signal:modelChanged()
› Attributes:Writable

populated

This property holds whether the target list has been populated completely, i.e. the number of created delegate objects equals the number of items specified by the model and is greater than zero.

› Type:Boolean
› Signal:populatedChanged()
› Attributes:Readonly

updating

This property holds whether the repeater is currently performing updates, i.e. is populating objects and updating the target list (if set). This can be used to defer updates in some places until a repeater has finished populating objects.

This property was introduced in InCore 2.0.

› Type:Boolean
› Signal:updatingChanged()
› Attributes:Readonly

Signals

errorOccurred()

This signal is emitted whenever an error has occurred, regardless of whether the error property has changed or not. In contrast to the change notification signal of the error property this signal is also emitted several times if a certain error occurs several times in succession.

objectAdded(Object item)

This signal is emitted when an object has been instantiated and added to the target list.

This signal was introduced in InCore 2.5.

objectRemoved(Object item)

This signal is emitted when an object has been removed from the target list and is going to be destroyed.

This signal was introduced in InCore 2.5.

Enumerations

Error

This enumeration describes all errors which can occur in Repeater objects. The most recently occurred error is stored in the error property.

Name Value Description
Repeater.NoError 0 No error occurred or was detected.
Repeater.InvalidPropertyType 1 Repeater not supported for non-list property “”.
Repeater.NotWritableError 2 Repeater not supported for readonly property “”.
Repeater.InvalidObjectTypeError 3 Can’t add incompatible object to property “”.
Repeater.ObjectInsertionError 4 Error inserting object to property “”.

Example

import InCore.Foundation 2.5
import InCore.Modbus 2.5

Application {

    DataObjectGroup {
        Repeater on objects {
            model: [ "A", "B", "C" ]
            delegate: DataObject {
                name: modelData
            }
        }
        onCompleted: {
            for( var i = 0; i < objects.length; ++i )
            {
                console.log( "Object", i, "has name", objects[i].name )
            }
        }
    }

    // create Modbus client
    ModbusTcpClient {
        id: modbusTcpClient
        networkAddress: "192.168.5.2"

        //create a slave object
        ModbusSlave {
            id: slave
            address: 1
            // repeat over 3 registers
            Repeater on registers {
                model: 3
                ModbusRegister {
                    address: index + 50
                    dataType: ModbusRegister.Float
                    type: ModbusRegister.Input
                    count: 2
                }

                // handle signal explicitly
                onPopulatedChanged: {
                    if( populated ) {
                        console.log( "repeater did the job" )
                    } else {
                        console.log( "repeater is working" )
                    }
                }
            }
        }
        Polling on slaves { interval: 5000 }
    }

    // MeasurementGroup to handle data
    MeasurementGroup {
        Repeater on objects {
            // handle signal populated implicitly
            model: slave.registers
            Measurement {
                objectId: "measurement" + index
                data: slave.registers[index].data
            }
        }
    }
}