Skip to content
Permalink
Browse files

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.
  • Loading branch information
nyalldawson committed Sep 5, 2017
1 parent 15f9241 commit 33b1380413fe77b39a5e141a5dae254df888e680
@@ -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
@@ -22,6 +22,8 @@
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#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
@@ -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() );
}
@@ -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
@@ -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 );

@@ -124,6 +124,7 @@ class QgsDiagramProperties;
class QgsLocatorWidget;
class QgsDataSourceManagerDialog;
class QgsBrowserModel;
class QgsGeoCmsProviderRegistry;


#include <QMainWindow>
@@ -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;

0 comments on commit 33b1380

Please sign in to comment.
You can’t perform that action at this time.