LegendInfoListModel QML Type

LegendInfos available for a LayerContent type."> LegendInfoListModel QML Type | ArcGISQtQml
  • Esri.ArcGISRuntime
  • LegendInfoListModel
  • A list model storing a list of LegendInfos available for a LayerContent type. More...

    Import Statement: import Esri.ArcGISRuntime
    Since: Esri.ArcGISRuntime 100.0

    Properties

    Signals

    Methods

    Detailed Description

    Note: You cannot declare or create a component of this type in QML code.

    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 setting the autoFetchLegendInfos property on LayerConent 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
    namestringThe name of the legend info value.
    symbolUrlurlA temporary file path to a symbol image contained in the legend info. This temporary file is deleted when the list model is destroyed.
    symbolWidthrealThe width of the symbol image.
    symbolHeightrealThe height of the symbol image.
    layerNamestringThe 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 Cancelable and LegendInfo.

    Property Documentation

    [read-only] count : int

    Returns the number of rows in the model (read-only).


    [read-only] error : Error

    Returns the Error object (read-only).


    [read-only] fetchLegendInfosStatus : Enums.TaskStatus

    Returns the status for the fetchLegendInfos task (read-only).

    See also Enums.TaskStatus.


    Signal Documentation

    countChanged()

    Emitted when the count property changes.

    Note: The corresponding handler is onCountChanged.


    errorChanged()

    Emitted when the error property changes, which can indicate that an error occurred.

    Note: The corresponding handler is onErrorChanged.


    fetchLegendInfosStatusChanged()

    Emitted when the fetchLegendInfosStatus property changes.

    Note: The corresponding handler is onFetchLegendInfosStatusChanged.


    Method Documentation

    bool cancelTask(string taskId)

    Cancel the task with the ID taskId.

    Returns false if the task cannot be canceled or there is no task with the specified id taskId.

    See also Cancelable.


    void clear()

    Removes all legend infos from the list model.


    string fetchLegendInfos(bool recursive)

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

    • recursive - Whether legend information is fetched recursively through the source layer and its sublayers. The default is true.

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

    Returns a task ID that can be used to cancel the fetchLegendInfos task.

    See also Cancelable.


    error forEach(callback)

    Receives a callback function to execute for each legend info in the model.

    The callback function can take 0 to 3 optional arguments, in order:

    • element Current legend info.
    • index Current index in array.
    • array Reference to LegendInfoListModel.

    Returns undefined if no error occurred, and an error message otherwise.

    const error = legendInfoListModel.forEach(function(element, index, array) {
        ...
    });
    if (error) {
        console.error(error.message);
    }

    LegendInfo get(int index)

    Returns the legend info at the specified index.


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