Add a very trivial registry GeoCMS providers to app

Currently it's only used to register GeoNode source select dialogs.
As additional GeoCMS handling is added to QGIS we can start
refining this class to handle common functionality.

For now, it's locked away in app so we don't need to worry
about frozen API restricting us when this happens.
This commit is contained in:
Nyall Dawson 2017-09-06 08:33:45 +10:00
parent 15f9241109
commit 33b1380413
6 changed files with 103 additions and 0 deletions

View File

@ -153,6 +153,7 @@ SET(QGIS_APP_SRCS
composer/qgscompositionwidget.cpp composer/qgscompositionwidget.cpp
composer/qgsatlascompositionwidget.cpp composer/qgsatlascompositionwidget.cpp
geocms/qgsgeocmsproviderregistry.cpp
geocms/geonode/qgsgeonodesourceselect.cpp geocms/geonode/qgsgeonodesourceselect.cpp
layout/qgslayoutaddpagesdialog.cpp layout/qgslayoutaddpagesdialog.cpp
@ -502,6 +503,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/app/openstreetmap ${CMAKE_SOURCE_DIR}/src/app/openstreetmap
${CMAKE_SOURCE_DIR}/src/app/dwg ${CMAKE_SOURCE_DIR}/src/app/dwg
${CMAKE_SOURCE_DIR}/src/app/dwg/libdxfrw ${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/geocms/geonode
${CMAKE_SOURCE_DIR}/src/app/locator ${CMAKE_SOURCE_DIR}/src/app/locator
${CMAKE_SOURCE_DIR}/src/analysis/raster ${CMAKE_SOURCE_DIR}/src/analysis/raster

View File

@ -22,6 +22,8 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "qgsabstractdatasourcewidget.h" #include "qgsabstractdatasourcewidget.h"
#include "qgssourceselectprovider.h"
#include "qgsapplication.h"
#include "ui_qgsgeonodesourceselectbase.h" #include "ui_qgsgeonodesourceselectbase.h"
#include "qgis_gui.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 #endif

View File

@ -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() );
}

View File

@ -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

View File

@ -1166,6 +1166,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
connect( QgsApplication::taskManager(), &QgsTaskManager::allTasksFinished, taskProgress, &QWinTaskbarProgress::hide ); connect( QgsApplication::taskManager(), &QgsTaskManager::allTasksFinished, taskProgress, &QWinTaskbarProgress::hide );
#endif #endif
mGeoCmsProviderRegistry.reset( new QgsGeoCmsProviderRegistry() );
// supposedly all actions have been added, now register them to the shortcut manager // supposedly all actions have been added, now register them to the shortcut manager
QgsGui::shortcutsManager()->registerAllChildren( this ); QgsGui::shortcutsManager()->registerAllChildren( this );

View File

@ -124,6 +124,7 @@ class QgsDiagramProperties;
class QgsLocatorWidget; class QgsLocatorWidget;
class QgsDataSourceManagerDialog; class QgsDataSourceManagerDialog;
class QgsBrowserModel; class QgsBrowserModel;
class QgsGeoCmsProviderRegistry;
#include <QMainWindow> #include <QMainWindow>
@ -145,6 +146,7 @@ class QgsBrowserModel;
#include "qgsrasterminmaxorigin.h" #include "qgsrasterminmaxorigin.h"
#include "qgsmaplayeractionregistry.h" #include "qgsmaplayeractionregistry.h"
#include "qgsoptionswidgetfactory.h" #include "qgsoptionswidgetfactory.h"
#include "geocms/qgsgeocmsproviderregistry.h"
#include "ui_qgisapp.h" #include "ui_qgisapp.h"
#include "qgis_app.h" #include "qgis_app.h"
@ -2076,6 +2078,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QTimer mRenderProgressBarTimer; QTimer mRenderProgressBarTimer;
QMetaObject::Connection mRenderProgressBarTimerConnection; QMetaObject::Connection mRenderProgressBarTimerConnection;
std::unique_ptr< QgsGeoCmsProviderRegistry > mGeoCmsProviderRegistry;
QgsBrowserModel *mBrowserModel = nullptr; QgsBrowserModel *mBrowserModel = nullptr;
friend class TestQgisAppPython; friend class TestQgisAppPython;