Skip To Content ArcGIS for Developers Sign In Dashboard

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>
Since: Esri::ArcGISRuntime 100.0
Inherits: QAbstractListModel

Public Types

enum AttributeRoles { AttributeNameRole, AttributeValueRole }

Public Functions

~AttributeListModel()
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
AttributeListModel &operator+=(const QPair<QString, QVariant> &attribute)
AttributeListModel &operator<<(const QPair<QString, QVariant> &attribute)
bool operator==(AttributeListModel *other) const
QVariant operator[](const QString &attributeName) const

Reimplemented Public Functions

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

Signals

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

Additional Inherited Members

Detailed Description

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

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

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.

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

Reimplemented from QAbstractItemModel::data().

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.

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

Signal emitted when an error occurs.

  • error - Details about the error.

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.

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<<.

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==(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.


Feedback on this topic?