A list model storing a list of layers available in a map. More...
Header: | #include <LayerListModel.h> |
Since: | Esri::ArcGISRuntime 100.0 |
Inherits: | QAbstractListModel and Esri::ArcGISRuntime::Iterable |
Public Types
enum | LayerRoles { LayerNameRole, LayerDescriptionRole, LayerVisibleRole, LayerCanChangeVisibility, LayerLoadStatusRole, …, LayerOpacityRole } |
Public Functions
virtual | ~LayerListModel() override |
void | append(Esri::ArcGISRuntime::Layer *layer) |
void | clear() |
bool | contains(Esri::ArcGISRuntime::Layer *layer) const |
Esri::ArcGISRuntime::Layer * | first() const |
int | indexOf(Esri::ArcGISRuntime::Layer *layer) const |
void | insert(int index, Esri::ArcGISRuntime::Layer *layer) |
bool | isEmpty() const |
Esri::ArcGISRuntime::Layer * | last() const |
void | move(int from, int to) |
void | removeAt(int index) |
void | removeOne(Esri::ArcGISRuntime::Layer *layer) |
Reimplemented Public Functions
virtual Esri::ArcGISRuntime::Layer * | at(int index) const override |
virtual QVariant | data(const QModelIndex &index, int role = Qt::DisplayRole) const override |
virtual int | size() const override |
Signals
void | errorOccurred(const Esri::ArcGISRuntime::Error &error) |
void | itemAdded(int index) |
void | itemRemoved(int index) |
Detailed Description
Modifying this model (adding, removing, moving) will update the layers available in the map.
The model returns data for the following roles:
Role | Type | Description |
---|---|---|
name | QString | The layer's name. |
description | QString | The layer's description. |
layerVisible | bool | Whether the layer is visible. |
canChangeVisibility | bool | Whether the layer's visibility can be changed. |
loadStatus | LoadStatus | The layer's load status. |
layerType | LayerType | The layer's type. |
attribution | QString | The layer's attribution if any is available. |
showInLegend | bool | Whether the layer will be shown in the legend. |
layerId | QString | The layer's ID specified in the web map JSON. |
minScale | double | The minimum scale at which the layer displays. |
maxScale | double | The maximum scale at which the layer displays. |
layerOpacity | float | The opacity of the layer between 0.0 and 1.0. |
Map *map = new Map(BasemapStyle::ArcGISCommunity, this); auto* featureTable = new ServiceFeatureTable(featureServiceUrl, this); auto* featureLayer = new FeatureLayer(featureTable, this); LayerListModel* llModel = map->operationalLayers(); llModel->insert(1,featureLayer);
Relevant samples:
- Group layers: Group a collection of layers together and toggle their visibility as a group.
- Manage operational layers: Add, remove, and reorder operational layers in a map.
Member Type Documentation
enum LayerListModel::LayerRoles
This enum specifies the custom roles which can be used with LayerListModel::data.
Constant | Value | Description |
---|---|---|
Esri::ArcGISRuntime::LayerListModel::LayerNameRole | Qt::UserRole + 1 | The layer's name. |
Esri::ArcGISRuntime::LayerListModel::LayerDescriptionRole | Qt::UserRole + 2 | The layer's description. |
Esri::ArcGISRuntime::LayerListModel::LayerVisibleRole | Qt::UserRole + 3 | Whether the layer is visible. |
Esri::ArcGISRuntime::LayerListModel::LayerCanChangeVisibility | Qt::UserRole + 4 | Whether the layer's visibility can be changed. |
Esri::ArcGISRuntime::LayerListModel::LayerLoadStatusRole | Qt::UserRole + 6 | The layer's load status. |
Esri::ArcGISRuntime::LayerListModel::LayerTypeRole | Qt::UserRole + 7 | The layer's type. |
Esri::ArcGISRuntime::LayerListModel::LayerAttributionRole | Qt::UserRole + 8 | The layer's attribution if any is available. |
Esri::ArcGISRuntime::LayerListModel::LayerShowInLegendRole | Qt::UserRole + 9 | Whether the layer will be shown in the legend. |
Esri::ArcGISRuntime::LayerListModel::LayerIdRole | Qt::UserRole + 10 | The layer's ID specified in the web map JSON. |
Esri::ArcGISRuntime::LayerListModel::LayerMinScaleRole | Qt::UserRole + 11 | The minimum scale at which the layer displays. |
Esri::ArcGISRuntime::LayerListModel::LayerMaxScaleRole | Qt::UserRole + 12 | The maximum scale at which the layer displays. |
Esri::ArcGISRuntime::LayerListModel::LayerOpacityRole | Qt::UserRole + 13 | The opacity of the layer between 0.0 and 1.0. |
Member Function Documentation
[override virtual]
LayerListModel::~LayerListModel ()
Destructor.
void LayerListModel::append(Esri::ArcGISRuntime::Layer *layer)
Appends a layer to the layer list model.
[override virtual]
Esri::ArcGISRuntime::Layer *LayerListModel::at(int index) const
Returns the Layer at the specified index.
void LayerListModel::clear()
Removes all layers from the list model.
List models do not take ownership of the objects they contain. Therefore, removing or clearing objects from the list model will not delete those objects. An RAII technique should be used to ensure that memory is properly deallocated.
bool LayerListModel::contains(Esri::ArcGISRuntime::Layer *layer) const
Returns true
if the list model contains the specified layer.
[override virtual]
QVariant LayerListModel::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 layer 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 LayerListModel::errorOccurred (const Esri::ArcGISRuntime::Error &error)
Signal emitted when an error occurs.
- error - Details about the error.
Esri::ArcGISRuntime::Layer *LayerListModel::first() const
Returns the first layer in the list model.
int LayerListModel::indexOf (Esri::ArcGISRuntime::Layer *layer) const
Returns the index of the layer specified.
void LayerListModel::insert(int index, Esri::ArcGISRuntime::Layer *layer)
Inserts a layer at a specified index in the list model.
This method will append to the list if the index is greater than the current size of the list model.
bool LayerListModel::isEmpty () const
Returns true
if the list model contains no layers.
[signal, since Esri::ArcGISRuntime 100.15]
void LayerListModel::itemAdded (int index)
Signal emitted when an item is added to the list model.
index is the index of the added item.
This function was introduced in Esri::ArcGISRuntime 100.15.
[signal, since Esri::ArcGISRuntime 100.15]
void LayerListModel::itemRemoved (int index)
Signal emitted when an item is removed from the list model.
index is the index of the removed item.
This function was introduced in Esri::ArcGISRuntime 100.15.
Esri::ArcGISRuntime::Layer *LayerListModel::last() const
Returns the last layer in the list model.
void LayerListModel::move(int from, int to)
Moves one layer from an index in the list model to a different index.
void LayerListModel::removeAt (int index)
Removes a layer at the specified index.
List models do not take ownership of the objects they contain. Therefore, removing or clearing objects from the list model will not delete those objects. An RAII technique should be used to ensure that memory is properly deallocated.
void LayerListModel::removeOne (Esri::ArcGISRuntime::Layer *layer)
Removes the specified layer from the list model.
List models do not take ownership of the objects they contain. Therefore, removing or clearing objects from the list model will not delete those objects. An RAII technique should be used to ensure that memory is properly deallocated.
[override virtual]
int LayerListModel::size() const
Returns the number of layers contained in the list model.