LegendInfoListModel Class

  • LegendInfoListModel
  • class Esri::ArcGISRuntime::LegendInfoListModel

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

    Header: #include <LegendInfoListModel.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: QAbstractListModel and Esri::ArcGISRuntime::Iterable

    Public Types

    enum LegendInfoRoles { LegendInfoNameRole, LegendInfoSymbolUrlRole, LegendInfoSymbolWidthRole, LegendInfoSymbolHeightRole, LegendInfoLayerNameRole, …, LegendInfoLayerMaxScaleRole }

    Public Functions

    virtual ~LegendInfoListModel() override
    void clear()
    QFuture<void> fetchLegendInfosAsync(bool recursive = true)
    bool isEmpty() const

    Reimplemented Public Functions

    virtual Esri::ArcGISRuntime::LegendInfo *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)

    Detailed Description

    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

    [override virtual] LegendInfoListModel::~LegendInfoListModel()

    Destructor.

    [override virtual] Esri::ArcGISRuntime::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 fetchLegendInfosAsync.

    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] QVariant LegendInfoListModel::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 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(const Esri::ArcGISRuntime::Error &error)

    Signal emitted when an error occurs.

    • error - Details about the error.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> LegendInfoListModel::fetchLegendInfosAsync(bool recursive = true)

    Fetches legend information from its source layer or map and adds to the list model.

    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 does not need to be called.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    bool LegendInfoListModel::isEmpty() const

    Returns true if the list model contains no legend infos.

    [override virtual] int LegendInfoListModel::size() const

    Returns the number of legend infos 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.