-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit a254a04.
- Loading branch information
1 parent
a254a04
commit e155a75
Showing
102 changed files
with
495 additions
and
31,617 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,4 @@ Desktop.ini | |
ehthumbs.db | ||
Thumbs.db | ||
|
||
# ignore all build directories | ||
|
||
*build* | ||
*.user.2.7pre1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
ArcGISRuntimeSDKQt_SampleViewers/ArcGISRuntimeSDKQt_CppSamples/CppSampleManager.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
// [Legal] | ||
// Copyright 2022 Esri. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// [Legal] | ||
|
||
#include "pch.hpp" | ||
|
||
#include "CppSampleManager.h" | ||
|
||
#include "ArcGISQt_global.h" // for LOCALSERVER_SUPPORTED | ||
#include "AuthenticationManager.h" | ||
#include "Portal.h" | ||
#include "PortalItem.h" | ||
#include "SampleManager_definitions.h" | ||
#include "MapTypes.h" | ||
#include "Error.h" | ||
#include "CredentialCache.h" | ||
#include "PortalTypes.h" | ||
#include "NetworkRequestProgress.h" | ||
|
||
using namespace Esri::ArcGISRuntime; | ||
|
||
#ifdef LOCALSERVER_SUPPORTED | ||
#include "LocalServer.h" | ||
#endif // LOCALSERVER_SUPPORTED | ||
|
||
#include <QQmlEngine> | ||
|
||
CppSampleManager::CppSampleManager(QObject* parent): | ||
DownloadSampleManager(parent), | ||
m_portal(new Portal(QUrl("https://arcgis.com"), this)) | ||
{ | ||
connect(m_portal, &Portal::doneLoading, this, [this](const Error& error) | ||
{ | ||
emit portalDoneLoading(error.isEmpty()); | ||
}); | ||
} | ||
|
||
CppSampleManager::~CppSampleManager() = default; | ||
|
||
void CppSampleManager::init() | ||
{ | ||
// Register the AuthenticationManager for QML | ||
qmlRegisterUncreatableType<AuthenticationManager>( | ||
"Esri.ArcGISRuntimeSamples", 1, 0, | ||
"AuthenticationManager", "AuthenticationManager is uncreateable"); | ||
|
||
DownloadSampleManager::init(); | ||
} | ||
|
||
void CppSampleManager::clearCredentialCache() | ||
{ | ||
AuthenticationManager::credentialCache()->removeAndRevokeAllCredentials(); | ||
} | ||
|
||
void CppSampleManager::buildCategoriesList() | ||
{ | ||
DownloadSampleManager::buildCategoriesList(); | ||
// If Local Server is supported and installed, add the category | ||
#ifdef LOCALSERVER_SUPPORTED | ||
if (LocalServer::isInstallValid()) | ||
{ | ||
const QDir dir(DIRNAMESAMPLES); | ||
appendCategoryToManager(createCategory("LocalServer", "Local Server", dir)); | ||
} | ||
#endif // LOCALSERVER_SUPPORTED | ||
} | ||
|
||
AuthenticationManager* CppSampleManager::authenticationManager() const | ||
{ | ||
return AuthenticationManager::instance(); | ||
} | ||
|
||
void CppSampleManager::loadPortal() | ||
{ | ||
m_portal->load(); | ||
} | ||
|
||
bool CppSampleManager::isPortalLoaded() const | ||
{ | ||
return m_portal->loadStatus() == LoadStatus::Loaded; | ||
} | ||
|
||
void CppSampleManager::createPortalItem(const QString& itemId) | ||
{ | ||
m_portalItem = new PortalItem(m_portal, itemId, this); | ||
|
||
connect(m_portalItem, &PortalItem::doneLoading, this, | ||
[this](const Error& error) | ||
{ | ||
bool success = error.isEmpty(); | ||
|
||
// Copy important parts before potential delete. | ||
auto type = m_portalItem->type(); | ||
auto name = m_portalItem->name(); | ||
auto id = m_portalItem->itemId(); | ||
|
||
if (!success) | ||
{ | ||
delete m_portalItem; | ||
m_portalItem = nullptr; | ||
} | ||
|
||
emit portalItemDoneLoading( | ||
success, | ||
id, | ||
type == PortalItemType::CodeSample ? name : QString()); | ||
|
||
}); | ||
|
||
connect(m_portalItem, &PortalItem::fetchDataProgressChanged, this, | ||
[this](const NetworkRequestProgress& progress) | ||
{ | ||
emit portalItemFetchDataProgress(m_portalItem->itemId(), progress.progressPercentage()); | ||
}); | ||
|
||
connect(m_portalItem, &PortalItem::fetchDataCompleted, | ||
this, [this](bool success) | ||
{ | ||
auto id = m_portalItem->itemId(); | ||
delete m_portalItem; | ||
m_portalItem = nullptr; | ||
emit portalItemFetchDataCompleted(id, success); | ||
}); | ||
|
||
m_portalItem->load(); | ||
} | ||
|
||
void CppSampleManager::fetchData(const QString& outputPath) | ||
{ | ||
m_portalItem->fetchData(outputPath); | ||
} | ||
|
||
QString CppSampleManager::api() const | ||
{ | ||
return QStringLiteral("C++"); | ||
} |
60 changes: 60 additions & 0 deletions
60
ArcGISRuntimeSDKQt_SampleViewers/ArcGISRuntimeSDKQt_CppSamples/CppSampleManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// [Legal] | ||
// Copyright 2022 Esri. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// [Legal] | ||
|
||
#ifndef CPPSAMPLEMANAGER_H | ||
#define CPPSAMPLEMANAGER_H | ||
|
||
#include "DownloadSampleManager.h" | ||
#include <QObject> | ||
|
||
Q_MOC_INCLUDE("AuthenticationManager.h") | ||
|
||
namespace Esri::ArcGISRuntime | ||
{ | ||
class AuthenticationManager; | ||
class Portal; | ||
class PortalItem; | ||
} | ||
|
||
class CppSampleManager : public DownloadSampleManager | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PROPERTY(Esri::ArcGISRuntime::AuthenticationManager* authenticationManager READ authenticationManager CONSTANT) | ||
|
||
public: | ||
explicit CppSampleManager(QObject* parent = nullptr); | ||
~CppSampleManager() override; | ||
|
||
void init() override; | ||
void clearCredentialCache() override; | ||
|
||
protected: | ||
QString api() const override; | ||
void buildCategoriesList() override; | ||
void loadPortal() override; | ||
bool isPortalLoaded() const override; | ||
void createPortalItem(const QString& itemId) override; | ||
void fetchData(const QString& outputPath) override; | ||
|
||
private: | ||
Esri::ArcGISRuntime::AuthenticationManager* authenticationManager() const; | ||
|
||
private: | ||
Esri::ArcGISRuntime::Portal* m_portal = nullptr; | ||
Esri::ArcGISRuntime::PortalItem* m_portalItem = nullptr; | ||
}; | ||
|
||
#endif // CPPSAMPLEMANAGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.