Skip to content

Commit

Permalink
Add a very trivial registry GeoCMS providers to app
Browse files Browse the repository at this point in the history
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 12, 2017
1 parent 15f9241 commit 33b1380
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -153,6 +153,7 @@ SET(QGIS_APP_SRCS
composer/qgscompositionwidget.cpp
composer/qgsatlascompositionwidget.cpp

geocms/qgsgeocmsproviderregistry.cpp
geocms/geonode/qgsgeonodesourceselect.cpp

layout/qgslayoutaddpagesdialog.cpp
Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions src/app/geocms/geonode/qgsgeonodesourceselect.h
Expand Up @@ -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"

Expand Down Expand Up @@ -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
29 changes: 29 additions & 0 deletions 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() );
}
49 changes: 49 additions & 0 deletions 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
2 changes: 2 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -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 );

Expand Down
4 changes: 4 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -124,6 +124,7 @@ class QgsDiagramProperties;
class QgsLocatorWidget;
class QgsDataSourceManagerDialog;
class QgsBrowserModel;
class QgsGeoCmsProviderRegistry;


#include <QMainWindow>
Expand All @@ -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"
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 33b1380

Please sign in to comment.