QIfZonedFeatureInterface Class

QIfZonedFeatureInterface defines the base interface for all QIfAbstractZonedFeature derived classes. More...

Header: #include <QIfZonedFeatureInterface>
qmake: QT += interfaceframework
Inherits: QIfFeatureInterface
Inherited By:

QIfClimateControlBackendInterface and QIfWindowControlBackendInterface

Public Functions

QIfZonedFeatureInterface(QObject *parent = nullptr)
virtual QStringList availableZones() const = 0

Signals

void availableZonesChanged(const QStringList &zones)

Detailed Description

Implementing QIfZonedFeatureInterface follows the same pattern as described in QIfFeatureInterface, but to support zones some additional functions need to be implemented: all setters and signals which are zoned need to be adapted like described below.

Providing Available Zones

Before making any further calls to the backend, The zoned feature will query the list of available zones. Zones are string keys and can be anything defined by the backend developer. In this case we have two zones: "Left" and "Right":

QStringList Backend::availableZones() const {
    QStringList zones;
    zones << "Left";
    zones << "Right";
    return zones;
}

Signal Definition

A zoned signal or a change signal for a zoned property needs to provide the zone as the second parameter. Here an example for a zoned signal:

void fanSpeedLevelChanged(int value, const QString &zone);

Similar to implementing a QIfFeatureInterface, the backend needs to emit all property change signals with the initial values in the initialize() function. In a zoned backend, the implementation has to emit all supported property signals, passing the zone as a parameter. The zone parameter can be omitted if the property is unzoned.

void Backend::initialize() {
    emit fanSpeedLevelChanged(2, "Left");
    emit fanSpeedLevelChanged(2, "Right");
    emit steeringWheelHeaterChanged(0); // Generic, no zone specified
    emit initializationDone();
}

Setter implementation

A setter for a zoned property takes the zone as the second parameter after the property value. Validating the requested zone is the responsibility of the backend implementation and in case an unsupported zone is passed, a QIfAbstractFeature::InvalidZone error should be reported.

In the example, the fanSpeedLevel property is zoned. If zone is valid, the actual fan speed level is adjusted and afterwards the change signal is emitted to indicate the change to the feature.

void Backend::setFanSpeedLevel(int value, const QString &zone) {
    if (!m_fanSpeedZones.contains(zone)) {
        emit errorChanged(QIfAbstractFeature::InvalidZone);
    } else {
        // Set specified zone fan to value
        ...
        emit fanSpeedLevelChanged(value, zone);
    }
}

See also QIfAbstractZonedFeature.

Member Function Documentation

[explicit] QIfZonedFeatureInterface::QIfZonedFeatureInterface(QObject *parent = nullptr)

Constructs a backend base interface.

The parent is sent to the QObject constructor.

[pure virtual] QStringList QIfZonedFeatureInterface::availableZones() const

Returns a list of supported zone names. This is called from the client after having connected.

The returned names must be valid QML property names, i.e. [a-z_][A-Za-z0-9_]*.

See also availableZonesChanged() and Providing Available Zones.

[signal] void QIfZonedFeatureInterface::availableZonesChanged(const QStringList &zones)

Emitted when the available zones changed.

Use this signal when the list of available zones need to be retrieved first, and are not available when the backend instance is created.

See also availableZones() and Providing Available Zones.

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.