Skip To Content ArcGIS for Developers Sign In Dashboard

BasemapListModel Class

class Esri::ArcGISRuntime::BasemapListModel

The result of fetching the basemaps available for a portal. More...

Header: #include <BasemapListModel>
Since: Esri::ArcGISRuntime 100.0
Inherits: QAbstractListModel and Esri::ArcGISRuntime::Iterable

This class was introduced in Esri::ArcGISRuntime 100.0.

Public Types

enum BasemapRoles { BasemapNameRole, BasemapUrlRole, BasemapItemAccessInformationRole, BasemapItemCreatedRole, BasemapItemDescriptionRole, …, BasemapItemThumbnailUrlRole }

Public Functions

virtual ~BasemapListModel() override
void append(Esri::ArcGISRuntime::Basemap *basemap)
void clear()
bool contains(Esri::ArcGISRuntime::Basemap *basemap) const
Esri::ArcGISRuntime::Basemap *first() const
int indexOf(Esri::ArcGISRuntime::Basemap *basemap) const
void insert(int index, Esri::ArcGISRuntime::Basemap *basemap)
bool isEmpty() const
Esri::ArcGISRuntime::Basemap *last() const
void move(int from, int to)
void removeAt(int index)
void removeOne(Esri::ArcGISRuntime::Basemap *basemap)

Reimplemented Public Functions

virtual Esri::ArcGISRuntime::Basemap *at(int index) const override
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
virtual int size() const override

Signals

void basemapAdded(int index)
void basemapRemoved(int index)
void errorOccurred(Esri::ArcGISRuntime::Error error)

Detailed Description

The request is made by calling fetchBasemaps and if the operation is succesful, this type is returned by the portal's basemaps method.

The basemaps contained in the model are initially unloaded.

The model returns data for the following roles:

RoleTypeDescriptionBasemapRoles
namestringThe basemap's name.BasemapNameRole
urlurlThe basemap's URL.BasemapUrlRole
accessInformationstringThe item's access information.BasemapItemAccessInformationRole
createddateThe date this item was created.BasemapItemCreatedRole
descriptionstringThe item's description.BasemapItemDescriptionRole
itemIdstringThe item's ID.BasemapItemIdRole
typePortalItemTypeThe item's type.BasemapItemTypeRole
modifieddateThe date this item was last modified.BasemapItemModifiedRole
snippetstringThe item's snippet.BasemapItemSnippetRole
tagslist<string>The item's tags.BasemapItemTagsRole
titlestringThe item's title.BasemapItemTitleRole
thumbnailUrlurlThe local file URL of the thumbnail image for this item.BasemapItemThumbnailUrlRole

Example: Accessing roles from a BasemapListModel from within a QML delegate:

Image {
    id: basemapImg
    anchors {
        bottom: basemapLabel.top;
        horizontalCenter: parent.horizontalCenter
    }
    height: parent.height - ( basemapLabel.height * 2 );
    source: thumbnailUrl // use the thumbnailUrl role of the model
    width: height
    fillMode: Image.PreserveAspectCrop
}

Text {
    id: basemapLabel
    anchors {
        bottom: parent.bottom;
        left: parent.left;
        right: parent.right
    }
    height: 16
    z: 100
    wrapMode: Text.Wrap
    horizontalAlignment: Text.AlignHCenter
    elide: Text.ElideRight
    text: title // use the title role of the model
    font.pointSize: 8
    font.bold: index === basemapsGrid.currentIndex
}

See also Portal, Basemap, and Loadable.

Member Type Documentation

enum BasemapListModel::BasemapRoles

This enum specifies the custom roles which can be used with BasemapListModel::data.

ConstantValueDescription
Esri::ArcGISRuntime::BasemapListModel::BasemapNameRoleQt::UserRole + 1The basemap's name.
Esri::ArcGISRuntime::BasemapListModel::BasemapUrlRoleQt::UserRole + 2The basemap's URL.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemAccessInformationRoleQt::UserRole + 3The item's access information.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemCreatedRoleQt::UserRole + 4The date this item was created.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemDescriptionRoleQt::UserRole + 5The item's description.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemIdRoleQt::UserRole + 6The item's ID.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemTypeRoleQt::UserRole + 7The item's type.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemModifiedRoleQt::UserRole + 8The date this item was last modified.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemSnippetRoleQt::UserRole + 9The item's snippet.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemTagsRoleQt::UserRole + 10The item's tags.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemTitleRoleQt::UserRole + 11The item's title.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemThumbnailUrlRoleQt::UserRole + 12The local file URL of the thumbnail image for this item.

Member Function Documentation

[signal] void BasemapListModel::basemapAdded(int index)

Signal emitted when a basemap is added to the list model.

index is the index of the added basemap.

[signal] void BasemapListModel::basemapRemoved(int index)

Signal emitted when a basemap is removed from the list model.

index is the index of the removed basemap.

[signal] void BasemapListModel::errorOccurred(Esri::ArcGISRuntime::Error error)

Signal emitted when an error occurs.

  • error - Details about the error.

[override virtual] BasemapListModel::~BasemapListModel()

Destructor.

void BasemapListModel::append(Esri::ArcGISRuntime::Basemap *basemap)

Appends a basemap to the basemap list model.

[override virtual] Esri::ArcGISRuntime::Basemap *BasemapListModel::at(int index) const

Returns the basemap at the specified index.

void BasemapListModel::clear()

Removes all basemaps from the list model.

bool BasemapListModel::contains(Esri::ArcGISRuntime::Basemap *basemap) const

Returns true if the list model contains the specified basemap.

[override virtual] QVariant BasemapListModel::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 basemap 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::Basemap *BasemapListModel::first() const

Returns the first basemap in the list model.

int BasemapListModel::indexOf(Esri::ArcGISRuntime::Basemap *basemap) const

Returns the index of the basemap specified.

void BasemapListModel::insert(int index, Esri::ArcGISRuntime::Basemap *basemap)

Inserts a basemap at a specified index in the list model.

This method will append to the list model if the index is greater than the current size of the list.

bool BasemapListModel::isEmpty() const

Returns true if the list model contains no basemaps.

Esri::ArcGISRuntime::Basemap *BasemapListModel::last() const

Returns the last basemap in the list model.

void BasemapListModel::move(int from, int to)

Moves one basemap from an index in the list model to a different index.

void BasemapListModel::removeAt(int index)

Removes a basemap at the specified index.

void BasemapListModel::removeOne(Esri::ArcGISRuntime::Basemap *basemap)

Removes the specified basemap from the list model.

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

Returns the number of basemaps contained in the list model.


Feedback on this topic?