diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 026905ec42f..4cc3eca1215 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -153,6 +153,7 @@ SET(QGIS_APP_SRCS composer/qgscompositionwidget.cpp composer/qgsatlascompositionwidget.cpp + geocms/qgsgeocmsproviderregistry.cpp geocms/geonode/qgsgeonodesourceselect.cpp layout/qgslayoutaddpagesdialog.cpp @@ -502,6 +503,7 @@ 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 diff --git a/src/app/geocms/geonode/qgsgeonodesourceselect.h b/src/app/geocms/geonode/qgsgeonodesourceselect.h index c31374499bb..22847c96813 100644 --- a/src/app/geocms/geonode/qgsgeonodesourceselect.h +++ b/src/app/geocms/geonode/qgsgeonodesourceselect.h @@ -22,6 +22,8 @@ #include #include #include "qgsabstractdatasourcewidget.h" +#include "qgssourceselectprovider.h" +#include "qgsapplication.h" #include "ui_qgsgeonodesourceselectbase.h" #include "qgis_gui.h" @@ -75,5 +77,20 @@ class QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, private Ui::Qg }; +//! Provider for GeoNode source select +class QgsGeoNodeSourceSelectProvider : public QgsSourceSelectProvider +{ + public: + + virtual QString providerKey() const override { return QStringLiteral( "geonode" ); } + virtual QString text() const override { return QObject::tr( "GeoNode" ); } + virtual int ordering() const override { return QgsSourceSelectProvider::OrderGeoCmsProvider + 10; } + virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddGeonodeLayer.svg" ) ); } + virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override + { + return new QgsGeoNodeSourceSelect( parent, fl, widgetMode ); + } +}; + #endif diff --git a/src/app/geocms/qgsgeocmsproviderregistry.cpp b/src/app/geocms/qgsgeocmsproviderregistry.cpp new file mode 100644 index 00000000000..0b74a630ff0 --- /dev/null +++ b/src/app/geocms/qgsgeocmsproviderregistry.cpp @@ -0,0 +1,29 @@ +/*************************************************************************** + qgsgeocmsproviderregistry.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 * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgsgeocmsproviderregistry.h" +#include "qgsgui.h" +#include "qgssourceselectproviderregistry.h" +#include "geocms/geonode/qgsgeonodesourceselect.h" + +QgsGeoCmsProviderRegistry::QgsGeoCmsProviderRegistry() +{ + init(); +} + +void QgsGeoCmsProviderRegistry::init() +{ + QgsGui::sourceSelectProviderRegistry()->addProvider( new QgsGeoNodeSourceSelectProvider() ); +} diff --git a/src/app/geocms/qgsgeocmsproviderregistry.h b/src/app/geocms/qgsgeocmsproviderregistry.h new file mode 100644 index 00000000000..172c22d0ed9 --- /dev/null +++ b/src/app/geocms/qgsgeocmsproviderregistry.h @@ -0,0 +1,49 @@ +/*************************************************************************** + 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 2c29771413c..ab49bd5658d 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1166,6 +1166,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh connect( QgsApplication::taskManager(), &QgsTaskManager::allTasksFinished, taskProgress, &QWinTaskbarProgress::hide ); #endif + mGeoCmsProviderRegistry.reset( new QgsGeoCmsProviderRegistry() ); + // supposedly all actions have been added, now register them to the shortcut manager QgsGui::shortcutsManager()->registerAllChildren( this ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 7ca3cef0cae..75a427d917e 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -124,6 +124,7 @@ class QgsDiagramProperties; class QgsLocatorWidget; class QgsDataSourceManagerDialog; class QgsBrowserModel; +class QgsGeoCmsProviderRegistry; #include @@ -145,6 +146,7 @@ class QgsBrowserModel; #include "qgsrasterminmaxorigin.h" #include "qgsmaplayeractionregistry.h" #include "qgsoptionswidgetfactory.h" +#include "geocms/qgsgeocmsproviderregistry.h" #include "ui_qgisapp.h" #include "qgis_app.h" @@ -2076,6 +2078,8 @@ 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;