AttributeListModel Class

  • AttributeListModel
  • class Esri::ArcGISRuntime::AttributeListModel

    A list model storing a list of key-value pairs to be used as attributes for a Feature or Graphic. More...

    Header: #include <AttributeListModel.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: QAbstractListModel

    This class was introduced in Esri::ArcGISRuntime 100.0.

    Public Types

    enum AttributeRoles { AttributeNameRole, AttributeValueRole }

    Public Functions

    virtual ~AttributeListModel() override
    QStringList attributeNames() const
    QVariant attributeValue(const QString &attributeName) const
    QVariantMap attributesMap() const
    bool containsAttribute(const QString &attributeName) const
    void insertAttribute(const QString &attributeName, const QVariant &attributeValue)
    bool isEmpty() const
    void removeAllAttributes()
    void removeAttribute(const QString &attributeName)
    void replaceAttribute(const QString &attributeName, const QVariant &attributeValue)
    void setAttributesMap(const QVariantMap &attributes)
    int size() const
    Esri::ArcGISRuntime::AttributeListModel &operator+=(const QPair<QString, QVariant> &attribute)
    Esri::ArcGISRuntime::AttributeListModel &operator<<(const QPair<QString, QVariant> &attribute)
    bool operator==(Esri::ArcGISRuntime::AttributeListModel *other) const
    QVariant operator[](const QString &attributeName) const

    Reimplemented Public Functions

    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override

    Signals

    void errorOccurred(Esri::ArcGISRuntime::Error error)

    Detailed Description

    Modifying this model (adding or removing) will update the attributes available in the feature or graphic.

    The model returns data for the following roles:

    RoleTypeDescriptionAttributeRoles
    attributeNameQStringThe name/key for the attribute.AttributeNameRole
    attributeValueQVariantThe value for the attribute.AttributeValueRole

    JSON null values are specified as a default constructed QJsonValue when used with the AttributeListModel, for example:

    const QVariant jsonNull(QJsonValue());

    Values that don't exist are returned as a default constructed, invalid QVariant.

    Member Type Documentation

    enum AttributeListModel::AttributeRoles

    This enum specifies the custom roles which can be used with AttributeListModel::data.

    ConstantValueDescription
    Esri::ArcGISRuntime::AttributeListModel::AttributeNameRoleQt::UserRole + 1The name/key for the attribute.
    Esri::ArcGISRuntime::AttributeListModel::AttributeValueRoleQt::UserRole + 2The value for the attribute.

    Member Function Documentation

    [signal] void AttributeListModel::errorOccurred(Esri::ArcGISRuntime::Error error)

    Signal emitted when an error occurs.

    • error - Details about the error.

    [override virtual] AttributeListModel::~AttributeListModel()

    Destructor.

    QStringList AttributeListModel::attributeNames() const

    Returns a list of all the attribute names in the model.

    QVariant AttributeListModel::attributeValue(const QString &attributeName) const

    Returns an attribute value by attributeName.

    QVariantMap AttributeListModel::attributesMap() const

    Returns the attributes in the model as a variant map.

    See also setAttributesMap().

    bool AttributeListModel::containsAttribute(const QString &attributeName) const

    Returns true if the model contains the provided attributeName.

    [override virtual] QVariant AttributeListModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const

    Reimplements: QAbstractItemModel::data(const QModelIndex &index, int role) const.

    Returns the data stored under the given role for the attribute referred to by the index.

    • index - The index in the model for which to return data.
    • role - The role for which to return data.

    void AttributeListModel::insertAttribute(const QString &attributeName, const QVariant &attributeValue)

    Inserts the value attributeValue of the attribute named attributeName.

    See also operator+= and operator<<.

    bool AttributeListModel::isEmpty() const

    Returns true if the model contains no attributes.

    void AttributeListModel::removeAllAttributes()

    Removes all attributes from the model.

    void AttributeListModel::removeAttribute(const QString &attributeName)

    Removes the attribute named attributeName from the model.

    void AttributeListModel::replaceAttribute(const QString &attributeName, const QVariant &attributeValue)

    Replaces the value attributeValue of the attribute named attributeName.

    void AttributeListModel::setAttributesMap(const QVariantMap &attributes)

    Replaces all attributes in the model with the provided attributes.

    See also attributesMap().

    int AttributeListModel::size() const

    Returns the number of attributes in the model.

    Esri::ArcGISRuntime::AttributeListModel &AttributeListModel::operator+=(const QPair<QString, QVariant> &attribute)

    Inserts a key-value pair attribute into the model and returns a reference to the model.

    See also insertAttribute and operator<<.

    Esri::ArcGISRuntime::AttributeListModel &AttributeListModel::operator<<(const QPair<QString, QVariant> &attribute)

    Inserts a key-value pair attribute into the model and returns a reference to the model.

    See also insertAttribute and operator+=.

    bool AttributeListModel::operator==(Esri::ArcGISRuntime::AttributeListModel *other) const

    Equivalency operator.

    Returns true if this object and other are equivalent.

    QVariant AttributeListModel::operator[](const QString &attributeName) const

    Returns the attribute value matching the provided attributeName.

    See also attributeValue.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.