Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Jared/remove extras dependency (#1707)" #1709

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,4 @@ Desktop.ini
ehthumbs.db
Thumbs.db

# ignore all build directories

*build*
*.user.2.7pre1
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ exists($$PWD/../../../../DevBuildCpp.pri) {
include($$PWD/../../../toolkit/uitools/toolkitcpp.pri)

INCLUDEPATH += \
$$SAMPLEPATHCPP \
$$COMMONVIEWER \
$$COMMONVIEWER/SyntaxHighlighter \
$$PWD/../../../../api/qt_cpp/Include \
$$PWD/../../../../api/qt_cpp/Include/LocalServer/
$$PWD/../../../../api/qt_cpp/Include/LocalServer/ \
} else {
message("Building against the installed SDK")
CONFIG += build_from_setup
Expand All @@ -72,7 +71,6 @@ exists($$PWD/../../../../DevBuildCpp.pri) {
}

INCLUDEPATH += \
$$SAMPLEPATHCPP \
$$COMMONVIEWER \
$$COMMONVIEWER/SyntaxHighlighter \
$$priLocation/sdk/include \
Expand All @@ -86,16 +84,19 @@ exists($$PWD/../../../../DevBuildCpp.pri) {
else {
PLATFORM = "linux/x64"
}
ARCGIS_RUNTIME_IMPORT_PATH = $${priLocation}/sdk/$${PLATFORM}/qml
}

macx:{
PLATFORM = "macOS"
ARCGIS_RUNTIME_IMPORT_PATH = $${priLocation}/sdk/$${PLATFORM}/universal/qml
}

win32:{
contains(QT_ARCH, x86_64):{
PLATFORM = "windows/x64"
}
ARCGIS_RUNTIME_IMPORT_PATH = $${priLocation}/sdk/$${PLATFORM}/qml
}

android {
Expand All @@ -115,13 +116,26 @@ exists($$PWD/../../../../DevBuildCpp.pri) {
}
contains(QMAKE_HOST.os, Windows):{
ANDROIDDIR = $$clean_path($$(ALLUSERSPROFILE)\\EsriRuntimeQt)
ARCGIS_RUNTIME_IMPORT_PATH = $${ANDROIDDIR}/Qt$${ARCGIS_RUNTIME_VERSION}/$${PLATFORM}/$${ANDROID_ARCH_FOLDER}/qml
}
else {
ARCGIS_RUNTIME_IMPORT_PATH = $${priLocation}/sdk/$${PLATFORM}/$${ANDROID_ARCH_FOLDER}/qml
}
}

ios {
PLATFORM = "iOS"
ARCGIS_RUNTIME_IMPORT_PATH = $${priLocation}/sdk/$${PLATFORM}/universal/qml
}

# Add plugin paths to QML_IMPORT_PATH
QML_IMPORT_PATH += $${ARCGIS_RUNTIME_IMPORT_PATH}

# Add plugin paths to QMLPATHS
QMLPATHS += $${ARCGIS_RUNTIME_IMPORT_PATH}

# Set ArcGIS Runtime QML import path for ArcGISExtras
DEFINES += ARCGIS_RUNTIME_IMPORT_PATH=\"$$ARCGIS_RUNTIME_IMPORT_PATH\"
DEFINES += BUILD_FROM_SETUP
}

Expand All @@ -138,9 +152,6 @@ QMAKE_TARGET_COPYRIGHT = Copyright 2017 Esri Inc.
# include the samples.pri, which contains all the sample resources
include(samples.pri)

# contains source files for zlib-ng and minizip-ng and the helper that uses them
include(zlib_minizip_ng.pri)

CONFIG(precompile_header): DEFINES += PCH_BUILD

android {
Expand All @@ -149,12 +160,14 @@ android {
}

HEADERS += \
CppSampleManager.h \
$$PCH_HEADER \
$$COMMONVIEWER/SyntaxHighlighter/syntax_highlighter.h \
$$COMMONVIEWER/SyntaxHighlighter/QMLHighlighter.h \
$$COMMONVIEWER/CategoryListModel.h \
$$COMMONVIEWER/DataItem.h \
$$COMMONVIEWER/DataItemListModel.h \
$$COMMONVIEWER/DownloadSampleManager.h \
$$COMMONVIEWER/Sample.h \
$$COMMONVIEWER/SampleCategory.h \
$$COMMONVIEWER/SampleListModel.h \
Expand All @@ -167,11 +180,13 @@ HEADERS += \
$$COMMONVIEWER/SourceCodeListModel.h

SOURCES += \
CppSampleManager.cpp \
$$COMMONVIEWER/SyntaxHighlighter/syntax_highlighter.cpp \
$$COMMONVIEWER/SyntaxHighlighter/QMLHighlighter.cpp \
$$COMMONVIEWER/CategoryListModel.cpp \
$$COMMONVIEWER/DataItem.cpp \
$$COMMONVIEWER/DataItemListModel.cpp \
$$COMMONVIEWER/DownloadSampleManager.cpp \
$$COMMONVIEWER/Sample.cpp \
$$COMMONVIEWER/SampleCategory.cpp \
$$COMMONVIEWER/SampleListModel.cpp \
Expand All @@ -191,6 +206,7 @@ RESOURCES += \
$$PWD/imports.qrc

DEFINES += QT_DEPRECATED_WARNINGS

#-------------------------------------------------
# Application Icon
#-------------------------------------------------
Expand Down
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++");
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import QtSensors
import QtPositioning
import QtQuick.XmlListModel
import QtWebView
import Esri.ArcGISExtras
import Esri.ArcGISRuntime.Toolkit

Item {
Expand Down
Loading
Loading