Skip to content
Permalink
Browse files
[wfs] Unlock static build support
  • Loading branch information
nirvn committed Oct 31, 2021
1 parent 7240356 commit f3f76161f8cb4f707bd383af5df16e4cdde6f9b9
@@ -2138,6 +2138,7 @@ if (FORCE_STATIC_LIBS)
if (HAVE_SPATIALITE)
target_link_libraries(qgis_core
provider_spatialite_a
provider_wfs_a
)
endif()
if (HAVE_POSTGRESQL)
@@ -47,6 +47,8 @@
#include "qgsdelimitedtextprovider.h"
#ifdef HAVE_SPATIALITE
#include "qgsspatialiteprovider.h"
#include "qgswfsprovider.h"
#include "qgsoapifprovider.h"
#endif
#ifdef HAVE_POSTGRESQL
#include "qgspostgresprovider.h"
@@ -199,6 +201,8 @@ void QgsProviderRegistry::init()
mProviders[ QgsDelimitedTextProvider::providerKey() ] = new QgsDelimitedTextProviderMetadata();
#ifdef HAVE_SPATIALITE
mProviders[ QgsSpatiaLiteProvider::providerKey() ] = new QgsSpatiaLiteProviderMetadata();
mProviders[ QgsWFSProvider::providerKey() ] = new QgsWfsProviderMetadata();
mProviders[ QgsOapifProvider::providerKey() ] = new QgsOapifProviderMetadata();
#endif
#ifdef HAVE_POSTGRESQL
mProviders[ QgsPostgresProvider::providerKey() ] = new QgsPostgresProviderMetadata();
@@ -1549,6 +1549,7 @@ if (FORCE_STATIC_LIBS)
if (HAVE_SPATIALITE)
target_link_libraries(qgis_gui
provider_spatialite_gui_a
provider_wfs_gui_a
)
endif()
if (HAVE_POSTGRESQL)
@@ -38,6 +38,7 @@
#include "qgsdelimitedtextprovidergui.h"
#ifdef HAVE_SPATIALITE
#include "qgsspatialiteprovidergui.h"
#include "qgswfsprovidergui.h"
#endif
#ifdef HAVE_POSTGRESQL
#include "qgspostgresprovidergui.h"
@@ -104,6 +105,8 @@ void QgsProviderGuiRegistry::loadStaticProviders( )
#ifdef HAVE_SPATIALITE
QgsProviderGuiMetadata *spatialite = new QgsSpatiaLiteProviderGuiMetadata();
mProviders[ spatialite->key() ] = spatialite;
QgsProviderGuiMetadata *wfs = new QgsWfsProviderGuiMetadata();
mProviders[ wfs->key() ] = wfs;
#endif
#ifdef HAVE_POSTGRESQL
QgsProviderGuiMetadata *postgres = new QgsPostgresProviderGuiMetadata();
@@ -8,6 +8,7 @@ add_subdirectory(delimitedtext)

if (WITH_SPATIALITE)
add_subdirectory(spatialite)
add_subdirectory(wfs)
endif()

if (POSTGRES_FOUND)
@@ -28,7 +29,6 @@ if (NOT FORCE_STATIC_LIBS)

if (WITH_SPATIALITE)
add_subdirectory(virtual)
add_subdirectory(wfs)
endif()

if (WITH_ORACLE)
@@ -29,50 +29,93 @@ set(WFS_SRCS
)

if (WITH_GUI)
set(WFS_SRCS ${WFS_SRCS}
set(WFS_GUI_SRCS
qgswfsprovidergui.cpp
qgswfsdataitemguiprovider.cpp
qgswfssourceselect.cpp
qgswfsnewconnection.cpp
qgswfsguiutils.cpp
qgswfssubsetstringeditor.cpp
)

set(WFS_UIS qgswfssourceselectbase.ui)
endif()

########################################################
# Build
# Static
add_library(provider_wfs_a STATIC ${WFS_SRCS})

include_directories (
target_include_directories(provider_wfs_a PUBLIC
${CMAKE_SOURCE_DIR}/src/providers/wfs
)

${CMAKE_BINARY_DIR}/src/ui
target_link_libraries(provider_wfs_a
${EXPAT_LIBRARY}
qgis_core
)

# require c++17
target_compile_features(provider_wfs_a PRIVATE cxx_std_17)

target_compile_definitions(provider_wfs_a PRIVATE "-DQT_NO_FOREACH")

if (WITH_GUI)
if (WITH_QT6)
QT6_WRAP_UI(WFS_UIS_H ${WFS_UIS})
else()
QT5_WRAP_UI(WFS_UIS_H ${WFS_UIS})
endif()

add_library(provider_wfs_gui_a STATIC ${WFS_GUI_SRCS} ${WFS_UIS_H})

target_include_directories(provider_wfs_gui_a PUBLIC
${CMAKE_BINARY_DIR}/src/providers/wfs
)

target_link_libraries(provider_wfs_gui_a
qgis_gui
)

# require c++17
target_compile_features(provider_wfs_gui_a PRIVATE cxx_std_17)

target_compile_definitions(provider_wfs_gui_a PRIVATE "-DQT_NO_FOREACH")

add_dependencies(provider_wfs_gui_a ui)

include_directories(SYSTEM
${QSCINTILLA_INCLUDE_DIR}
${CMAKE_BINARY_DIR}/src/ui
)
endif()

add_library (provider_wfs MODULE ${WFS_SRCS})
if (FORCE_STATIC_LIBS)
# for (external) mobile apps to be able to pick up provider for linking
install (TARGETS provider_wfs_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
if (WITH_GUI)
install (TARGETS provider_wfs_gui_a ARCHIVE DESTINATION ${QGIS_PLUGIN_DIR})
endif()
else()
add_library(provider_wfs MODULE ${WFS_SRCS} ${WFS_GUI_SRCS})

# require c++17
target_compile_features(provider_wfs PRIVATE cxx_std_17)
# require c++17
target_compile_features(provider_wfs PRIVATE cxx_std_17)

target_link_libraries (provider_wfs
${EXPAT_LIBRARY}
qgis_core
)
target_compile_definitions(provider_wfs PRIVATE "-DQT_NO_FOREACH")

if (WITH_GUI)
target_link_libraries (provider_wfs
qgis_gui
${EXPAT_LIBRARY}
qgis_core
)
add_dependencies(provider_wfs ui)
endif()

########################################################
# Install

install(TARGETS provider_wfs
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
if (WITH_GUI)
target_link_libraries (provider_wfs
qgis_gui
)
add_dependencies(provider_wfs ui)
endif()

install(TARGETS provider_wfs
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
endif()
@@ -216,7 +216,7 @@ bool QgsBaseNetworkRequest::sendGET( const QUrl &url, const QString &acceptHeade

if ( synchronous && QThread::currentThread() == QApplication::instance()->thread() )
{
std::unique_ptr<DownloaderThread> downloaderThread = std::make_unique<DownloaderThread>( downloaderFunction );
std::unique_ptr<_DownloaderThread> downloaderThread = std::make_unique<_DownloaderThread>( downloaderFunction );
downloaderThread->start();

while ( true )
@@ -128,12 +128,12 @@ class QgsBaseNetworkRequest : public QObject
};


class DownloaderThread : public QThread
class _DownloaderThread : public QThread
{
Q_OBJECT

public:
DownloaderThread( std::function<void()> function, QObject *parent = nullptr )
_DownloaderThread( std::function<void()> function, QObject *parent = nullptr )
: QThread( parent )
, mFunction( function )
{
@@ -340,6 +340,11 @@ QString QgsOapifProvider::name() const
return OAPIF_PROVIDER_KEY;
}

QString QgsOapifProvider::providerKey()
{
return OAPIF_PROVIDER_KEY;
}

QString QgsOapifProvider::description() const
{
return OAPIF_PROVIDER_DESCRIPTION;
@@ -68,6 +68,8 @@ class QgsOapifProvider final: public QgsVectorDataProvider
QString name() const override;
QString description() const override;

static QString providerKey();

QgsVectorDataProvider::Capabilities capabilities() const override;

QgsLayerMetadata layerMetadata() const override { return mLayerMetadata; }
@@ -1636,6 +1636,11 @@ QString QgsWFSProvider::name() const
return WFS_PROVIDER_KEY;
}

QString QgsWFSProvider::providerKey()
{
return WFS_PROVIDER_KEY;
}

QString QgsWFSProvider::description() const
{
return WFS_PROVIDER_DESCRIPTION;
@@ -2034,7 +2039,10 @@ QList<QgsDataItemProvider *> QgsWfsProviderMetadata::dataItemProviders() const
QgsWfsProviderMetadata::QgsWfsProviderMetadata():
QgsProviderMetadata( QgsWFSProvider::WFS_PROVIDER_KEY, QgsWFSProvider::WFS_PROVIDER_DESCRIPTION ) {}


#ifndef HAVE_STATIC_PROVIDERS
QGISEXTERN void *multipleProviderMetadataFactory()
{
return new std::vector<QgsProviderMetadata *> { new QgsWfsProviderMetadata(), new QgsOapifProviderMetadata() };
}
#endif
@@ -98,6 +98,8 @@ class QgsWFSProvider final: public QgsVectorDataProvider
QString name() const override;
QString description() const override;

static QString providerKey();

QgsVectorDataProvider::Capabilities capabilities() const override;

QString storageType() const override { return QStringLiteral( "OGC WFS (Web Feature Service)" ); }
@@ -60,37 +60,34 @@ class QgsWfsSubsetStringEditorProvider: public QgsSubsetStringEditorProvider
};


class QgsWfsProviderGuiMetadata: public QgsProviderGuiMetadata
QgsWfsProviderGuiMetadata::QgsWfsProviderGuiMetadata()
: QgsProviderGuiMetadata( QgsWFSProvider::WFS_PROVIDER_KEY )
{
public:
QgsWfsProviderGuiMetadata()
: QgsProviderGuiMetadata( QgsWFSProvider::WFS_PROVIDER_KEY )
{
}

QList<QgsSourceSelectProvider *> sourceSelectProviders() override
{
QList<QgsSourceSelectProvider *> providers;
providers << new QgsWfsSourceSelectProvider;
return providers;
}
}

QList<QgsDataItemGuiProvider *> dataItemGuiProviders() override
{
return QList<QgsDataItemGuiProvider *>()
<< new QgsWfsDataItemGuiProvider;
}
QList<QgsSourceSelectProvider *> QgsWfsProviderGuiMetadata::sourceSelectProviders() override
{
QList<QgsSourceSelectProvider *> providers;
providers << new QgsWfsSourceSelectProvider;
return providers;
}

QList<QgsSubsetStringEditorProvider *> subsetStringEditorProviders() override
{
return QList<QgsSubsetStringEditorProvider *>()
<< new QgsWfsSubsetStringEditorProvider;
}
QList<QgsDataItemGuiProvider *> QgsWfsProviderGuiMetadata::dataItemGuiProviders() override
{
return QList<QgsDataItemGuiProvider *>()
<< new QgsWfsDataItemGuiProvider;
}

};
QList<QgsSubsetStringEditorProvider *> QgsWfsProviderGuiMetadata::subsetStringEditorProviders() override
{
return QList<QgsSubsetStringEditorProvider *>()
<< new QgsWfsSubsetStringEditorProvider;
}


#ifndef HAVE_STATIC_PROVIDERS
QGISEXTERN QgsProviderGuiMetadata *providerGuiMetadataFactory()
{
return new QgsWfsProviderGuiMetadata();
}
#endif
@@ -0,0 +1,30 @@
/***************************************************************************
qgswfsprovidergui.cpp
--------------------------------------
Date : June 2019
Copyright : (C) 2019 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgswfsprovider.h"
#include "qgswfssourceselect.h"
#include "qgssourceselectprovider.h"
#include "qgsproviderguimetadata.h"


class QgsWfsProviderGuiMetadata: public QgsProviderGuiMetadata
{
public:
QgsWfsProviderGuiMetadata();

QList<QgsSourceSelectProvider *> sourceSelectProviders() override;
QList<QgsDataItemGuiProvider *> dataItemGuiProviders() override;
QList<QgsSubsetStringEditorProvider *> subsetStringEditorProviders() override;
};

0 comments on commit f3f7616

Please sign in to comment.