;

LayerListModel Class

  • LayerListModel
  • class Esri::ArcGISRuntime::LayerListModel

    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:

    RoleTypeDescription
    nameQStringThe layer's name.
    descriptionQStringThe layer's description.
    layerVisibleboolWhether the layer is visible.
    canChangeVisibilityboolWhether the layer's visibility can be changed.
    loadErrorErrorTypeThe layer's load error type.
    loadStatusLoadStatusThe layer's load status.
    layerTypeLayerTypeThe layer's type.
    attributionQStringThe layer's attribution if any is available.
    showInLegendboolWhether the layer will be shown in the legend.
    layerIdQStringThe layer's ID specified in the web map JSON.
    minScaledoubleThe minimum scale at which the layer displays.
    maxScaledoubleThe maximum scale at which the layer displays.
    layerOpacityfloatThe 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.

    ConstantValueDescription
    Esri::ArcGISRuntime::LayerListModel::LayerNameRoleQt::UserRole + 1The layer's name.
    Esri::ArcGISRuntime::LayerListModel::LayerDescriptionRoleQt::UserRole + 2The layer's description.
    Esri::ArcGISRuntime::LayerListModel::LayerVisibleRoleQt::UserRole + 3Whether the layer is visible.
    Esri::ArcGISRuntime::LayerListModel::LayerCanChangeVisibilityQt::UserRole + 4Whether the layer's visibility can be changed.
    Esri::ArcGISRuntime::LayerListModel::LayerLoadErrorRoleQt::UserRole + 5The layer's load error type.
    Esri::ArcGISRuntime::LayerListModel::LayerLoadStatusRoleQt::UserRole + 6The layer's load status.
    Esri::ArcGISRuntime::LayerListModel::LayerTypeRoleQt::UserRole + 7The layer's type.
    Esri::ArcGISRuntime::LayerListModel::LayerAttributionRoleQt::UserRole + 8The layer's attribution if any is available.
    Esri::ArcGISRuntime::LayerListModel::LayerShowInLegendRoleQt::UserRole + 9Whether the layer will be shown in the legend.
    Esri::ArcGISRuntime::LayerListModel::LayerIdRoleQt::UserRole + 10The layer's ID specified in the web map JSON.
    Esri::ArcGISRuntime::LayerListModel::LayerMinScaleRoleQt::UserRole + 11The minimum scale at which the layer displays.
    Esri::ArcGISRuntime::LayerListModel::LayerMaxScaleRoleQt::UserRole + 12The maximum scale at which the layer displays.
    Esri::ArcGISRuntime::LayerListModel::LayerOpacityRoleQt::UserRole + 13The 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.

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