LayerListModel Class
A list model storing a list of layers available in a map. More...
Header: | #include <LayerListModel> |
Since: | Esri::ArcGISRuntime 100.0 |
Inherits: | QAbstractListModel and Esri::ArcGISRuntime::Iterable |
This class was introduced in Esri::ArcGISRuntime 100.0.
Public Types
enum | LayerRoles { LayerNameRole, LayerDescriptionRole, LayerVisibleRole, LayerCanChangeVisibility, LayerLoadErrorRole, …, 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(Esri::ArcGISRuntime::Error error) |
void | layerAdded(int index) |
void | layerRemoved(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. |
loadError | ErrorType | The layer's load error type. |
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(BasemapType::NationalGeographic, -117, 34, 15, this);
ServiceFeatureTable *featureTable = new ServiceFeatureTable(featureServiceUrl, this);
FeatureLayer *featureLayer = new FeatureLayer(featureTable, this);
LayerListModel* llModel = map->operationalLayers();
llModel->insert(1,featureLayer);
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::LayerLoadErrorRole | Qt::UserRole + 5 | The layer's load error type. |
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
[signal]
void LayerListModel::errorOccurred(Esri::ArcGISRuntime::Error error)
Signal emitted when an error occurs.
- error - Details about the error.
[signal]
void LayerListModel::layerAdded(int index)
Signal emitted when a layer is added to the list model.
index is the index of the added layer.
[signal]
void LayerListModel::layerRemoved(int index)
Signal emitted when a layer is removed from the list model.
index is the index of the removed layer.
[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.
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.
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.
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.
void LayerListModel::removeOne(Esri::ArcGISRuntime::Layer *layer)
Removes the specified layer from the list model.
[override virtual]
int LayerListModel::size() const
Returns the number of layers contained in the list model.