|
34 | 34 | #include <SpatialReference.h> |
35 | 35 |
|
36 | 36 | // Qt headers |
| 37 | +#include <QFuture> |
37 | 38 | #include <QPersistentModelIndex> |
38 | 39 | #include <QPointer> |
39 | 40 |
|
@@ -240,29 +241,29 @@ namespace Esri::ArcGISRuntime::Toolkit { |
240 | 241 |
|
241 | 242 | /*! |
242 | 243 | \internal |
243 | | - Calls Portal::fetchDeveloperBasemaps on the portal. Note that we do |
244 | | - not call Portal::fetchBasemaps. The former call is for retrieving the modern API-key |
| 244 | + Calls Portal::fetchDeveloperBasemapsAsync on the portal. Note that we do |
| 245 | + not call Portal::fetchBasemapsAsync. The former call is for retrieving the modern API-key |
245 | 246 | metered basemaps, while the latter returns older-style basemaps. The latter is required |
246 | 247 | only when the user applies a custom portal, as it is also the call for retrieving an |
247 | 248 | enterprises's custom basemaps if set. |
248 | 249 | */ |
249 | 250 | void setToDefaultBasemaps(BasemapGalleryController* self, Portal* portal) |
250 | 251 | { |
251 | | - // For every "discovered" basemap we add it to our gallery. |
252 | | - QObject::connect( |
253 | | - portal, &Portal::developerBasemapsChanged, self, [portal, self]() |
254 | | - { |
255 | | - BasemapListModel* basemaps = portal->developerBasemaps(); |
256 | | - |
257 | | - sortBasemapsAndAddToGallery(self, basemaps); |
258 | | - }); |
259 | | - |
260 | 252 | // Load the portal and kick-off the group discovery. |
261 | | - QObject::connect(portal, &Portal::doneLoading, self, [portal](Error e) |
| 253 | + QObject::connect(portal, &Portal::doneLoading, self, [portal, self](Error e) |
262 | 254 | { |
263 | 255 | if (!e.isEmpty()) |
264 | 256 | return; |
265 | | - portal->fetchDeveloperBasemaps(); |
| 257 | + |
| 258 | + portal->fetchDeveloperBasemapsAsync().then( |
| 259 | + [portal, self]() |
| 260 | + { |
| 261 | + // Sort and append the basemaps to the gallery. |
| 262 | + BasemapListModel* basemaps = portal->developerBasemaps(); |
| 263 | + sortBasemapsAndAddToGallery(self, basemaps); |
| 264 | + // Notify the demo that the basemaps have changed. |
| 265 | + emit self->basemapsChanged(); |
| 266 | + }); |
266 | 267 | }); |
267 | 268 | portal->load(); |
268 | 269 | } |
@@ -411,7 +412,7 @@ namespace Esri::ArcGISRuntime::Toolkit { |
411 | 412 | \brief Sets the current portal. This resets the gallery. |
412 | 413 |
|
413 | 414 | When \a portal is set, the basemaps of the Portal |
414 | | - are fetched via \c{Portal::fetchBasemaps}. |
| 415 | + are fetched via \c{Portal::fetchBasemapsAsync}. |
415 | 416 |
|
416 | 417 | This is useful for displaying an organization's basemaps or to display a gallery of the old-style basemaps |
417 | 418 | (which do not require an API key or named user.) |
@@ -457,13 +458,13 @@ namespace Esri::ArcGISRuntime::Toolkit { |
457 | 458 | } |
458 | 459 | else |
459 | 460 | { |
460 | | - connect(m_portal, &Portal::basemapsChanged, this, [this] |
461 | | - { |
462 | | - BasemapListModel* basemaps = m_portal->basemaps(); |
463 | | - |
464 | | - sortBasemapsAndAddToGallery(this, basemaps); |
465 | | - }); |
466 | | - m_portal->fetchBasemaps(); |
| 461 | + m_portal->fetchBasemapsAsync().then( |
| 462 | + [this]() |
| 463 | + { |
| 464 | + BasemapListModel* basemaps = m_portal->basemaps(); |
| 465 | + sortBasemapsAndAddToGallery(this, basemaps); |
| 466 | + emit basemapsChanged(); |
| 467 | + }); |
467 | 468 | } |
468 | 469 | }); |
469 | 470 | } |
|
0 commit comments