From 220c5e85e36d24e883673e044216dd0487e94e0a Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 12 Sep 2017 20:46:07 +1000 Subject: [PATCH] Move GeoNode browser/source select from app -> new 'geonode' provider Instead of including these classes in app, we instead make a shell data provider which implements only the dataItemProviders() and sourceSelectProviders() methods. Helps keep GeoNode GUI related code partitioned --- debian/qgis-providers.install.in | 1 + ms-windows/osgeo4w/package.cmd | 1 + src/app/CMakeLists.txt | 11 ---- src/app/geocms/qgsgeocmsproviderregistry.h | 49 ---------------- src/app/qgisapp.cpp | 4 -- src/app/qgisapp.h | 3 - src/providers/CMakeLists.txt | 1 + src/providers/geonode/CMakeLists.txt | 58 +++++++++++++++++++ .../geonode/qgsgeonodedataitems.cpp | 9 +++ .../geonode/qgsgeonodedataitems.h | 0 .../geonode/qgsgeonodenewconnection.cpp | 0 .../geonode/qgsgeonodenewconnection.h | 0 .../geonode/qgsgeonodeprovider.cpp} | 43 ++++++++------ .../geonode/qgsgeonodesourceselect.cpp | 10 ++++ .../geonode/qgsgeonodesourceselect.h | 0 15 files changed, 106 insertions(+), 84 deletions(-) delete mode 100644 src/app/geocms/qgsgeocmsproviderregistry.h create mode 100644 src/providers/geonode/CMakeLists.txt rename src/{app/geocms => providers}/geonode/qgsgeonodedataitems.cpp (97%) rename src/{app/geocms => providers}/geonode/qgsgeonodedataitems.h (100%) rename src/{app/geocms => providers}/geonode/qgsgeonodenewconnection.cpp (100%) rename src/{app/geocms => providers}/geonode/qgsgeonodenewconnection.h (100%) rename src/{app/geocms/qgsgeocmsproviderregistry.cpp => providers/geonode/qgsgeonodeprovider.cpp} (54%) rename src/{app/geocms => providers}/geonode/qgsgeonodesourceselect.cpp (98%) rename src/{app/geocms => providers}/geonode/qgsgeonodesourceselect.h (100%) diff --git a/debian/qgis-providers.install.in b/debian/qgis-providers.install.in index 23ab5200209..ef488eb717e 100644 --- a/debian/qgis-providers.install.in +++ b/debian/qgis-providers.install.in @@ -2,6 +2,7 @@ usr/lib/qgis/crssync usr/lib/qgis/plugins/libbasicauthmethod.so usr/lib/qgis/plugins/libdelimitedtextprovider.so usr/lib/qgis/plugins/libgdalprovider.so +usr/lib/qgis/plugins/libgeonodeprovider.so usr/lib/qgis/plugins/libgpxprovider.so usr/lib/qgis/plugins/libidentcertauthmethod.so usr/lib/qgis/plugins/libmssqlprovider.so diff --git a/ms-windows/osgeo4w/package.cmd b/ms-windows/osgeo4w/package.cmd index b26db6dcef4..d75fd1931c4 100644 --- a/ms-windows/osgeo4w/package.cmd +++ b/ms-windows/osgeo4w/package.cmd @@ -301,6 +301,7 @@ tar -C %OSGEO4W_ROOT% -cjf %ARCH%/release/qgis/%PACKAGENAME%-common/%PACKAGENAME "apps/%PACKAGENAME%/plugins/basicauthmethod.dll" ^ "apps/%PACKAGENAME%/plugins/delimitedtextprovider.dll" ^ "apps/%PACKAGENAME%/plugins/gdalprovider.dll" ^ + "apps/%PACKAGENAME%/plugins/geonodeprovider.dll" ^ "apps/%PACKAGENAME%/plugins/gpxprovider.dll" ^ "apps/%PACKAGENAME%/plugins/identcertauthmethod.dll" ^ "apps/%PACKAGENAME%/plugins/mssqlprovider.dll" ^ diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 9a8d2bc39f7..e39106eba38 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -153,11 +153,6 @@ SET(QGIS_APP_SRCS composer/qgscompositionwidget.cpp composer/qgsatlascompositionwidget.cpp - geocms/qgsgeocmsproviderregistry.cpp - geocms/geonode/qgsgeonodedataitems.cpp - geocms/geonode/qgsgeonodenewconnection.cpp - geocms/geonode/qgsgeonodesourceselect.cpp - layout/qgslayoutaddpagesdialog.cpp layout/qgslayoutdesignerdialog.cpp layout/qgslayoutguidewidget.cpp @@ -338,10 +333,6 @@ SET (QGIS_APP_MOC_HDRS composer/qgscompositionwidget.h composer/qgsatlascompositionwidget.h - geocms/geonode/qgsgeonodedataitems.h - geocms/geonode/qgsgeonodenewconnection.h - geocms/geonode/qgsgeonodesourceselect.h - layout/qgslayoutaddpagesdialog.h layout/qgslayoutappmenuprovider.h layout/qgslayoutdesignerdialog.h @@ -507,8 +498,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/app/openstreetmap ${CMAKE_SOURCE_DIR}/src/app/dwg ${CMAKE_SOURCE_DIR}/src/app/dwg/libdxfrw - ${CMAKE_SOURCE_DIR}/src/app/geocms - ${CMAKE_SOURCE_DIR}/src/app/geocms/geonode ${CMAKE_SOURCE_DIR}/src/app/locator ${CMAKE_SOURCE_DIR}/src/analysis/raster ${CMAKE_SOURCE_DIR}/src/analysis/openstreetmap diff --git a/src/app/geocms/qgsgeocmsproviderregistry.h b/src/app/geocms/qgsgeocmsproviderregistry.h deleted file mode 100644 index 172c22d0ed9..00000000000 --- a/src/app/geocms/qgsgeocmsproviderregistry.h +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - qgsgeocmsproviderregistry.h - --------------------------- - begin : September 2017 - copyright : (C) 2017 by Nyall Dawson - email : nyall dot dawson 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. * - * * - ***************************************************************************/ - -#ifndef QGSGEOCMSPROVIDERREGISTRY_H -#define QGSGEOCMSPROVIDERREGISTRY_H - -#include "qgis.h" - -/** - * \ingroup app - * - * This is a trivial registry for GeoCMS providers. It will be 'fleshed out' - * as additional GeoCMS providers are added, and the required common functionality - * between the different providers is determined. - * - * \since QGIS 3.0 - */ -class QgsGeoCmsProviderRegistry -{ - - public: - QgsGeoCmsProviderRegistry(); - - //! QgsGeoCmsProviderRegistry cannot be copied. - QgsGeoCmsProviderRegistry( const QgsGeoCmsProviderRegistry &rh ) = delete; - - //! QgsGeoCmsProviderRegistry cannot be copied. - QgsGeoCmsProviderRegistry &operator=( const QgsGeoCmsProviderRegistry &rh ) = delete; - - private: - - //! Initializes the registry - void init(); - -}; - -#endif // QGSGEOCMSPROVIDERREGISTRY_H diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 24207e3ccee..2c29771413c 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1081,10 +1081,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh QgsStyle::defaultStyle(); endProfile(); - startProfile( QStringLiteral( "Loading GeoCMS providers" ) ); - mGeoCmsProviderRegistry.reset( new QgsGeoCmsProviderRegistry() ); - endProfile(); - mSplash->showMessage( tr( "QGIS Ready!" ), Qt::AlignHCenter | Qt::AlignBottom ); QgsMessageLog::logMessage( QgsApplication::showSettings(), QString(), QgsMessageLog::INFO ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 75a427d917e..b2c24085fe4 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -146,7 +146,6 @@ class QgsGeoCmsProviderRegistry; #include "qgsrasterminmaxorigin.h" #include "qgsmaplayeractionregistry.h" #include "qgsoptionswidgetfactory.h" -#include "geocms/qgsgeocmsproviderregistry.h" #include "ui_qgisapp.h" #include "qgis_app.h" @@ -2078,8 +2077,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QTimer mRenderProgressBarTimer; QMetaObject::Connection mRenderProgressBarTimerConnection; - std::unique_ptr< QgsGeoCmsProviderRegistry > mGeoCmsProviderRegistry; - QgsBrowserModel *mBrowserModel = nullptr; friend class TestQgisAppPython; diff --git a/src/providers/CMakeLists.txt b/src/providers/CMakeLists.txt index 95171db24de..258069639c8 100644 --- a/src/providers/CMakeLists.txt +++ b/src/providers/CMakeLists.txt @@ -7,6 +7,7 @@ ADD_SUBDIRECTORY(ogr) ADD_SUBDIRECTORY(wms) ADD_SUBDIRECTORY(delimitedtext) ADD_SUBDIRECTORY(gdal) +ADD_SUBDIRECTORY(geonode) ADD_SUBDIRECTORY(mssql) ADD_SUBDIRECTORY(ows) ADD_SUBDIRECTORY(wcs) diff --git a/src/providers/geonode/CMakeLists.txt b/src/providers/geonode/CMakeLists.txt new file mode 100644 index 00000000000..7f5556efab5 --- /dev/null +++ b/src/providers/geonode/CMakeLists.txt @@ -0,0 +1,58 @@ + +SET (GEONODE_SRCS + qgsgeonodedataitems.cpp + qgsgeonodenewconnection.cpp + qgsgeonodeprovider.cpp + qgsgeonodesourceselect.cpp +) + +SET(GEONODE_MOC_HDRS + qgsgeonodedataitems.h + qgsgeonodenewconnection.h + qgsgeonodesourceselect.h +) + +######################################################## +# Build + +QT5_WRAP_CPP(GEONODE_MOC_SRCS ${GEONODE_MOC_HDRS}) + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/src/core + ${CMAKE_SOURCE_DIR}/src/core/raster + ${CMAKE_SOURCE_DIR}/src/core/geocms/geonode + ${CMAKE_SOURCE_DIR}/src/core/geometry + ${CMAKE_SOURCE_DIR}/src/core/metadata + ${CMAKE_SOURCE_DIR}/src/core/symbology + ${CMAKE_SOURCE_DIR}/src/core/expression + ${CMAKE_SOURCE_DIR}/src/gui + + ${CMAKE_BINARY_DIR}/src/core + ${CMAKE_BINARY_DIR}/src/gui + ${CMAKE_BINARY_DIR}/src/ui +) + +ADD_LIBRARY(geonodeprovider MODULE ${GEONODE_SRCS} ${GEONODE_MOC_SRCS}) + +TARGET_LINK_LIBRARIES(geonodeprovider + qgis_core +) + +IF (WITH_GUI) + TARGET_LINK_LIBRARIES (geonodeprovider + qgis_gui + ) +ENDIF () + +# clang-tidy +IF(CLANG_TIDY_EXE) + SET_TARGET_PROPERTIES( + geonodeprovider PROPERTIES + CXX_CLANG_TIDY "${DO_CLANG_TIDY}" + ) +ENDIF(CLANG_TIDY_EXE) + +INSTALL (TARGETS geonodeprovider + RUNTIME DESTINATION ${QGIS_PLUGIN_DIR} + LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}) + diff --git a/src/app/geocms/geonode/qgsgeonodedataitems.cpp b/src/providers/geonode/qgsgeonodedataitems.cpp similarity index 97% rename from src/app/geocms/geonode/qgsgeonodedataitems.cpp rename to src/providers/geonode/qgsgeonodedataitems.cpp index f97f8825f64..9e1d746977e 100644 --- a/src/app/geocms/geonode/qgsgeonodedataitems.cpp +++ b/src/providers/geonode/qgsgeonodedataitems.cpp @@ -278,3 +278,12 @@ QgsDataItem *QgsGeoNodeDataItemProvider::createDataItem( const QString &path, Qg return nullptr; } + +QGISEXTERN QList *dataItemProviders() +{ + QList *providers = new QList(); + + *providers << new QgsGeoNodeDataItemProvider(); + + return providers; +} diff --git a/src/app/geocms/geonode/qgsgeonodedataitems.h b/src/providers/geonode/qgsgeonodedataitems.h similarity index 100% rename from src/app/geocms/geonode/qgsgeonodedataitems.h rename to src/providers/geonode/qgsgeonodedataitems.h diff --git a/src/app/geocms/geonode/qgsgeonodenewconnection.cpp b/src/providers/geonode/qgsgeonodenewconnection.cpp similarity index 100% rename from src/app/geocms/geonode/qgsgeonodenewconnection.cpp rename to src/providers/geonode/qgsgeonodenewconnection.cpp diff --git a/src/app/geocms/geonode/qgsgeonodenewconnection.h b/src/providers/geonode/qgsgeonodenewconnection.h similarity index 100% rename from src/app/geocms/geonode/qgsgeonodenewconnection.h rename to src/providers/geonode/qgsgeonodenewconnection.h diff --git a/src/app/geocms/qgsgeocmsproviderregistry.cpp b/src/providers/geonode/qgsgeonodeprovider.cpp similarity index 54% rename from src/app/geocms/qgsgeocmsproviderregistry.cpp rename to src/providers/geonode/qgsgeonodeprovider.cpp index 260e3dd3a26..60481aa93a6 100644 --- a/src/app/geocms/qgsgeocmsproviderregistry.cpp +++ b/src/providers/geonode/qgsgeonodeprovider.cpp @@ -1,10 +1,12 @@ /*************************************************************************** - qgsgeocmsproviderregistry.cpp - ----------------------------- + qgsgeonodeprovider.cpp + ---------------------- begin : September 2017 copyright : (C) 2017 by Nyall Dawson email : nyall dot dawson 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 * @@ -13,23 +15,30 @@ * * ***************************************************************************/ -#include "qgsgeocmsproviderregistry.h" -#include "qgsdataitemproviderregistry.h" -#include "qgsgui.h" -#include "qgssourceselectproviderregistry.h" -#include "geocms/geonode/qgsgeonodesourceselect.h" -#include "geocms/geonode/qgsgeonodedataitems.h" +#include "qgis.h" -QgsGeoCmsProviderRegistry::QgsGeoCmsProviderRegistry() + +/** Required key function (used to map the plugin to a data store type) +*/ +QGISEXTERN QString providerKey() { - init(); + return QStringLiteral( "geonode" ); } -void QgsGeoCmsProviderRegistry::init() +/** + * Required description function + */ +QGISEXTERN QString description() { - // source select providers - QgsGui::sourceSelectProviderRegistry()->addProvider( new QgsGeoNodeSourceSelectProvider() ); - - // data item providers - QgsApplication::dataItemProviderRegistry()->addProvider( new QgsGeoNodeDataItemProvider() ); + return QStringLiteral( "GeoNode provider" ); +} + +/** + * Required isProvider function. Used to determine if this shared library + * is a data provider plugin + */ + +QGISEXTERN bool isProvider() +{ + return true; } diff --git a/src/app/geocms/geonode/qgsgeonodesourceselect.cpp b/src/providers/geonode/qgsgeonodesourceselect.cpp similarity index 98% rename from src/app/geocms/geonode/qgsgeonodesourceselect.cpp rename to src/providers/geonode/qgsgeonodesourceselect.cpp index f200d1add4b..eea029a1316 100644 --- a/src/app/geocms/geonode/qgsgeonodesourceselect.cpp +++ b/src/providers/geonode/qgsgeonodesourceselect.cpp @@ -470,3 +470,13 @@ QgsGeoNodeConnection QgsGeoNodeSourceSelect::currentConnection() const { return QgsGeoNodeConnection( cmbConnections->currentText() ); } + +QGISEXTERN QList *sourceSelectProviders() +{ + QList *providers = new QList(); + + *providers + << new QgsGeoNodeSourceSelectProvider; + + return providers; +} diff --git a/src/app/geocms/geonode/qgsgeonodesourceselect.h b/src/providers/geonode/qgsgeonodesourceselect.h similarity index 100% rename from src/app/geocms/geonode/qgsgeonodesourceselect.h rename to src/providers/geonode/qgsgeonodesourceselect.h