Skip to content
Permalink
Browse files

Add a QgsDataItemGuiProvider interface and registry for providers

These providers will be used to control how the browser data items
behave within GUI, and to allow separation of GUI related
properties of browser items from the core code.

A new registry QgsDataItemGuiProviderRegistry has been created
(modeled off QgsDataItemProviderRegistry), with an application
wide instance available from QgsGui::instance()->dataItemGuiProviderRegistry()
  • Loading branch information
nyalldawson committed Oct 27, 2018
1 parent 0b17db6 commit 6ec7f02e83524e798a9b921cc4f467a76f5e09b0
@@ -34,17 +34,19 @@ QgsDataItemProviderRegistry is not usually directly created, but rather accessed

QList<QgsDataItemProvider *> providers() const;
%Docstring
Gets list of available providers
Returns the list of available providers.
%End

void addProvider( QgsDataItemProvider *provider /Transfer/ );
%Docstring
Add a provider implementation. Takes ownership of the object.
Adds a ``provider`` implementation to the registry. Ownership of the provider
is transferred to the registry.
%End

void removeProvider( QgsDataItemProvider *provider );
%Docstring
Remove provider implementation from the list (provider object is deleted)
Removes a ``provider`` implementation from the registry.
The provider object is automatically deleted.
%End

private:
@@ -0,0 +1,44 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsdataitemguiprovider.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsDataItemGuiProvider
{
%Docstring

Abstract base class for providers which affect how QgsDataItem items behave
within the application GUI.

Providers must be registered via QgsDataItemGuiProviderRegistry.

.. versionadded:: 3.6
%End

%TypeHeaderCode
#include "qgsdataitemguiprovider.h"
%End
public:

virtual ~QgsDataItemGuiProvider();

virtual QString name() = 0;
%Docstring
Returns the provider's name.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsdataitemguiprovider.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -0,0 +1,61 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsdataitemguiproviderregistry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsDataItemGuiProviderRegistry
{
%Docstring
This class keeps a list of data item GUI providers that may affect how QgsDataItems
behave within the application GUI.

QgsDataItemGuiProviderRegistry is not usually directly created, but rather accessed through
QgsGui.instance()->dataItemGuiProviderRegistry().

.. versionadded:: 3.6
%End

%TypeHeaderCode
#include "qgsdataitemguiproviderregistry.h"
%End
public:

QgsDataItemGuiProviderRegistry();

~QgsDataItemGuiProviderRegistry();


QList<QgsDataItemGuiProvider *> providers() const;
%Docstring
Returns the list of available providers.
%End

void addProvider( QgsDataItemGuiProvider *provider /Transfer/ );
%Docstring
Adds a ``provider`` implementation to the registry. Ownership of the provider
is transferred to the registry.
%End

void removeProvider( QgsDataItemGuiProvider *provider );
%Docstring
Removes a ``provider`` implementation from the registry.
The provider object is automatically deleted.
%End

private:
QgsDataItemGuiProviderRegistry( const QgsDataItemGuiProviderRegistry &rh );
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsdataitemguiproviderregistry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -74,6 +74,14 @@ Returns the global processing gui registry, used for registering the GUI behavio
Returns the global processing recent algorithm log, used for tracking recently used processing algorithms.

.. versionadded:: 3.4
%End

static QgsDataItemGuiProviderRegistry *dataItemGuiProviderRegistry();
%Docstring
Returns the global data item GUI provider registry, used for tracking providers which affect the browser
GUI.

.. versionadded:: 3.6
%End

static void enableAutoGeometryRestore( QWidget *widget, const QString &key = QString() );
@@ -1,5 +1,7 @@
// Include auto-generated SIP files
%Include auto_generated/qgsattributeforminterface.sip
%Include auto_generated/qgsdataitemguiprovider.sip
%Include auto_generated/qgsdataitemguiproviderregistry.sip
%Include auto_generated/qgsdetaileditemdata.sip
%Include auto_generated/qgsexpressionbuilderdialog.sip
%Include auto_generated/qgsgeometryrubberband.sip
@@ -46,21 +46,29 @@ class CORE_EXPORT QgsDataItemProviderRegistry
//! QgsDataItemProviderRegistry cannot be copied.
QgsDataItemProviderRegistry &operator=( const QgsDataItemProviderRegistry &rh ) = delete;

//! Gets list of available providers
/**
* Returns the list of available providers.
*/
QList<QgsDataItemProvider *> providers() const { return mProviders; }

//! Add a provider implementation. Takes ownership of the object.
/**
* Adds a \a provider implementation to the registry. Ownership of the provider
* is transferred to the registry.
*/
void addProvider( QgsDataItemProvider *provider SIP_TRANSFER );

//! Remove provider implementation from the list (provider object is deleted)
/**
* Removes a \a provider implementation from the registry.
* The provider object is automatically deleted.
*/
void removeProvider( QgsDataItemProvider *provider );

private:
#ifdef SIP_RUN
QgsDataItemProviderRegistry( const QgsDataItemProviderRegistry &rh );
#endif

//! available providers. this class owns the pointers
//! Available providers, owned by this class
QList<QgsDataItemProvider *> mProviders;

};
@@ -243,6 +243,8 @@ SET(QGIS_GUI_SRCS
qgscredentialdialog.cpp
qgscustomdrophandler.cpp
qgscurveeditorwidget.cpp
qgsdataitemguiprovider.cpp
qgsdataitemguiproviderregistry.cpp
qgsdatumtransformdialog.cpp
qgsdatasourceselectdialog.cpp
qgsdetaileditemdata.cpp
@@ -767,6 +769,8 @@ ENDIF(MSVC)
SET(QGIS_GUI_HDRS
qgsattributeforminterface.h
qgsattributeformlegacyinterface.h
qgsdataitemguiprovider.h
qgsdataitemguiproviderregistry.h
qgsdetaileditemdata.h
qgsexpressionbuilderdialog.h
qgsgeometryrubberband.h
@@ -0,0 +1,18 @@
/***************************************************************************
qgsdataitemguiprovider.cpp
--------------------------------------
Date : October 2018
Copyright : (C) 2018 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 "qgsdataitemguiprovider.h"

// no implementation currently
@@ -0,0 +1,47 @@
/***************************************************************************
qgsdataitemguiprovider.h
--------------------------------------
Date : October 2018
Copyright : (C) 2018 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 QGSDATAITEMGUIPROVIDER_H
#define QGSDATAITEMGUIPROVIDER_H

#include "qgis_gui.h"

class QString;

/**
* \class QgsDataItemGuiProvider
* \ingroup gui
*
* Abstract base class for providers which affect how QgsDataItem items behave
* within the application GUI.
*
* Providers must be registered via QgsDataItemGuiProviderRegistry.
*
* \since QGIS 3.6
*/
class GUI_EXPORT QgsDataItemGuiProvider
{
public:

virtual ~QgsDataItemGuiProvider() = default;

/**
* Returns the provider's name.
*/
virtual QString name() = 0;

};

#endif // QGSDATAITEMGUIPROVIDER_H
@@ -0,0 +1,38 @@
/***************************************************************************
qgsdataitemguiproviderregistry.cpp
--------------------------------------
Date : October 2018
Copyright : (C) 2018 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 "qgsdataitemguiproviderregistry.h"
#include "qgsdataitemguiprovider.h"

QgsDataItemGuiProviderRegistry::QgsDataItemGuiProviderRegistry()
{
}

QgsDataItemGuiProviderRegistry::~QgsDataItemGuiProviderRegistry()
{
qDeleteAll( mProviders );
}

void QgsDataItemGuiProviderRegistry::addProvider( QgsDataItemGuiProvider *provider )
{
mProviders.append( provider );
}

void QgsDataItemGuiProviderRegistry::removeProvider( QgsDataItemGuiProvider *provider )
{
int index = mProviders.indexOf( provider );
if ( index >= 0 )
delete mProviders.takeAt( index );
}
@@ -0,0 +1,76 @@
/***************************************************************************
qgsdataitemguiproviderregistry.h
--------------------------------------
Date : October 2018
Copyright : (C) 2018 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 QGSDATAITEMGUIPROVIDERREGISTRY_H
#define QGSDATAITEMGUIPROVIDERREGISTRY_H

#include "qgis_gui.h"
#include "qgis_sip.h"
#include <QList>

class QgsDataItemGuiProvider;

/**
* \class QgsDataItemGuiProviderRegistry
* \ingroup gui
* This class keeps a list of data item GUI providers that may affect how QgsDataItems
* behave within the application GUI.
*
* QgsDataItemGuiProviderRegistry is not usually directly created, but rather accessed through
* QgsGui::instance()->dataItemGuiProviderRegistry().
*
* \since QGIS 3.6
*/
class GUI_EXPORT QgsDataItemGuiProviderRegistry
{
public:

QgsDataItemGuiProviderRegistry();

~QgsDataItemGuiProviderRegistry();

//! QgsDataItemGuiProviderRegistry cannot be copied.
QgsDataItemGuiProviderRegistry( const QgsDataItemGuiProviderRegistry &rh ) = delete;
//! QgsDataItemGuiProviderRegistry cannot be copied.
QgsDataItemGuiProviderRegistry &operator=( const QgsDataItemGuiProviderRegistry &rh ) = delete;

/**
* Returns the list of available providers.
*/
QList<QgsDataItemGuiProvider *> providers() const { return mProviders; }

/**
* Adds a \a provider implementation to the registry. Ownership of the provider
* is transferred to the registry.
*/
void addProvider( QgsDataItemGuiProvider *provider SIP_TRANSFER );

/**
* Removes a \a provider implementation from the registry.
* The provider object is automatically deleted.
*/
void removeProvider( QgsDataItemGuiProvider *provider );

private:
#ifdef SIP_RUN
QgsDataItemGuiProviderRegistry( const QgsDataItemGuiProviderRegistry &rh );
#endif

//! Available providers, owned by this class
QList<QgsDataItemGuiProvider *> mProviders;

};

#endif // QGSDATAITEMGUIPROVIDERREGISTRY_H

0 comments on commit 6ec7f02

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