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:
Role | Type | Description |
---|---|---|
name | QString | The name of the legend info value. |
symbolUrl | QUrl | A temporary file path to a symbol image contained in the legend info. This temporary file is deleted when the list model is destroyed. |
symbolWidth | float | The width of the symbol image. |
symbolHeight | float | The height of the symbol image. |
layerName | QString | The name of the layer that the legend information belongs to. |
layerMinScale | double | The minimum scale of the layer that the legend information belongs to. |
layerMaxScale | double | The 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.
Constant | Value | Description |
---|---|---|
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoNameRole | Qt::DisplayRole | The name of the legend info value. |
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoSymbolUrlRole | Qt::UserRole + 1 | A temporary file path to a symbol image contained in the legend info. |
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoSymbolWidthRole | Qt::UserRole + 2 | The width of the symbol image. |
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoSymbolHeightRole | Qt::UserRole + 3 | The height of the symbol image. |
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoLayerNameRole | Qt::UserRole + 4 | The name of the layer that the legend information belongs to. |
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoLayerMinScaleRole | Qt::UserRole + 5 | The minimum scale of the layer that the legend information belongs to. |
Esri::ArcGISRuntime::LegendInfoListModel::LegendInfoLayerMaxScaleRole | Qt::UserRole + 6 | The 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.