Skip To Content ArcGIS for Developers Sign In Dashboard

LegendInfoListModel Class

(Esri::ArcGISRuntime::LegendInfoListModel)

A list model storing a list of LegendInfos available for a LayerContent type. More...

Header: #include <LegendInfoListModel>
Since: Esri::ArcGISRuntime 100.0
Inherits: QAbstractListModel and Iterable<LegendInfo *>

Public Types

enum LegendInfoRoles { LegendInfoNameRole, LegendInfoSymbolUrlRole, LegendInfoSymbolWidthRole, LegendInfoSymbolHeightRole, ..., LegendInfoLayerMaxScaleRole }

Public Functions

~LegendInfoListModel()
LegendInfo *at(int index) const
void clear()
TaskWatcher fetchLegendInfos(bool recursive = true)
bool isEmpty() const
int size() const

Reimplemented Public Functions

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

Signals

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

Additional Inherited Members

Detailed Description

A list model storing a list of LegendInfos available for a LayerContent type.

By default, legend information will be fetched recursively (from base layer type to sublayer types) and added to the list model. This automatic fetching of legend information can be changed by calling the setAutoFetchLegendInfos method on LayerContent or Map, whichever was the source for the model. This list model contains roles for accessing particular legend information.

This class is a subclass of QAbstractListModel.

The model returns data for the following roles:

RoleTypeDescription
nameQStringThe name of the legend info value.
symbolUrlQUrlA temporary file path to a symbol image contained in the legend info. This temporary file is deleted when the list model is destroyed.
symbolWidthfloatThe width of the symbol image.
symbolHeightfloatThe height of the symbol image.
layerNameQStringThe name of the layer that the legend information belongs to.
layerMinScaledoubleThe minimum scale of the layer that the legend information belongs to.
layerMaxScaledoubleThe maximum scale of the layer that the legend information belongs to.

See also LegendInfo.

Member Type Documentation

enum LegendInfoListModel::LegendInfoRoles

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

ConstantValueDescription
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoNameRoleQt::DisplayRoleThe name of the legend info value.
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoSymbolUrlRoleQt::UserRole + 1A temporary file path to a symbol image contained in the legend info.
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoSymbolWidthRoleQt::UserRole + 2The width of the symbol image.
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoSymbolHeightRoleQt::UserRole + 3The height of the symbol image.
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoLayerNameRoleQt::UserRole + 4The name of the layer that the legend information belongs to.
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoLayerMinScaleRoleQt::UserRole + 5The minimum scale of the layer that the legend information belongs to.
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoLayerMaxScaleRoleQt::UserRole + 6The maximum scale of the layer that the legend information belongs to.

Member Function Documentation

LegendInfoListModel::~LegendInfoListModel()

Destructor.

LegendInfo *LegendInfoListModel::at(int index) const

Returns the legend info at the specified index.

void LegendInfoListModel::clear()

Removes all legend infos from the list model.

After clearing the list model, you can repopulate the model by calling fetchLegendInfos.

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

Reimplemented from QAbstractItemModel::data().

Returns the data stored under the given role for the legend info 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 LegendInfoListModel::errorOccurred(Esri::ArcGISRuntime::Error error)

Signal emitted when an error occurs.

  • error - Details about the error.

TaskWatcher LegendInfoListModel::fetchLegendInfos(bool recursive = true)

Fetches legend information from its source layer or map, adds to the list model, and returns a TaskWatcher for the asynchronous task.

To fetch legend information recursively through the source layer and its sublayers, pass in true (the default) for the recursive parameter.

If the model's source LayerContent type or Map is configured to automatically fetch legend infos, this method will be called automatically.

[signal] void LegendInfoListModel::fetchLegendInfosCompleted()

Signal emitted when the model has completed fetching all requested legend infos.

bool LegendInfoListModel::isEmpty() const

Returns true if the list model contains no legend infos.

int LegendInfoListModel::size() const

Returns the number of legend infos contained in the list model.


Feedback on this topic?