Skip to content
Permalink
Browse files

Start on registry for numeric format configuration widgets

  • Loading branch information
nyalldawson committed Jan 7, 2020
1 parent 552913c commit ccf6898eb95b250de014cd638aa70a9a7ce0a80d
@@ -0,0 +1,83 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/numericformats/qgsnumericformatguiregistry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsNumericFormatConfigurationWidgetFactory
{
%Docstring
Interface base class for factories for numeric format configuration widgets.

.. versionadded:: 3.12
%End

%TypeHeaderCode
#include "qgsnumericformatguiregistry.h"
%End
public:
virtual ~QgsNumericFormatConfigurationWidgetFactory();

virtual QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const = 0 /Factory/;
%Docstring
Create a new configuration widget for a format.
%End
};

class QgsNumericFormatGuiRegistry
{
%Docstring
The QgsNumericFormatGuiRegistry is a home for widgets for configuring QgsNumericFormat objects.

QgsNumericFormatGuiRegistry is not usually directly created, but rather accessed through
:py:func:`QgsGui.numericFormatGuiRegistry()`

.. versionadded:: 3.12
%End

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

QgsNumericFormatGuiRegistry();
%Docstring
Constructor. Should never be called manually, is already
created by :py:class:`QgsGui`.
%End
~QgsNumericFormatGuiRegistry();

void addFormatConfigurationWidgetFactory( const QString &id, QgsNumericFormatConfigurationWidgetFactory *factory /Transfer/ );
%Docstring
Add a new configuration widget factory for customizing a numeric format with the specified ``id``.

Ownership is taken by the reigstry.
%End

void removeFormatConfigurationWidgetFactory( const QString &id );
%Docstring
Removes the configuration widget factory for customizing numeric formats with the specified ``id``.
%End

QgsNumericFormatWidget *formatConfigurationWidget( const QgsNumericFormat *format ) const /Factory/;
%Docstring
Returns a new configuration widget for an ``format``.

Returns ``None`` if no configuration widgets are available for the specified ``format``.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/numericformats/qgsnumericformatguiregistry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -73,6 +73,13 @@ Returns the global layout item GUI registry, used for registering the GUI behavi
Returns the global processing gui registry, used for registering the GUI behavior of processing algorithms.

.. versionadded:: 3.2
%End

static QgsNumericFormatGuiRegistry *numericFormatGuiRegistry() /KeepReference/;
%Docstring
Returns the global numeric format gui registry, used for registering the GUI widgets associated with :py:class:`QgsNumericFormats`.

.. versionadded:: 3.12
%End

static QgsProcessingRecentAlgorithmLog *processingRecentAlgorithmLog();
@@ -296,6 +296,7 @@
%Include auto_generated/locator/qgslocatorwidget.sip
%Include auto_generated/numericformats/qgsnumericformatselectorwidget.sip
%Include auto_generated/numericformats/qgsnumericformatwidget.sip
%Include auto_generated/numericformats/qgsnumericformatguiregistry.sip
%Include auto_generated/processing/qgsprocessingalgorithmconfigurationwidget.sip
%Include auto_generated/processing/qgsprocessingalgorithmdialogbase.sip
%Include auto_generated/processing/qgsprocessinggui.sip
@@ -204,6 +204,7 @@ SET(QGIS_GUI_SRCS

numericformats/qgsnumericformatselectorwidget.cpp
numericformats/qgsnumericformatwidget.cpp
numericformats/qgsnumericformatguiregistry.cpp

ogr/qgsogrhelperfunctions.cpp
ogr/qgsnewogrconnection.cpp
@@ -796,6 +797,7 @@ SET(QGIS_GUI_HDRS

numericformats/qgsnumericformatselectorwidget.h
numericformats/qgsnumericformatwidget.h
numericformats/qgsnumericformatguiregistry.h

ogr/qgsnewogrconnection.h
ogr/qgsogrhelperfunctions.h
@@ -0,0 +1,52 @@
/***************************************************************************
qgsnumericformatguiregistry.cpp
-------------------------------
begin : January 2020
copyright : (C) 2020 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 "qgsnumericformatguiregistry.h"
#include "qgis.h"
#include "qgsnumericformatwidget.h"

QgsNumericFormatGuiRegistry::QgsNumericFormatGuiRegistry()
{
// addFormatConfigurationWidgetFactory( new QgsFilterAlgorithmConfigurationWidgetFactory() );
}

QgsNumericFormatGuiRegistry::~QgsNumericFormatGuiRegistry()
{
qDeleteAll( mFormatConfigurationWidgetFactories );
}

void QgsNumericFormatGuiRegistry::addFormatConfigurationWidgetFactory( const QString &id, QgsNumericFormatConfigurationWidgetFactory *factory )
{
mFormatConfigurationWidgetFactories.insert( id, factory );
}

void QgsNumericFormatGuiRegistry::removeFormatConfigurationWidgetFactory( const QString &id )
{
delete mFormatConfigurationWidgetFactories.value( id );
mFormatConfigurationWidgetFactories.remove( id );
}

QgsNumericFormatWidget *QgsNumericFormatGuiRegistry::formatConfigurationWidget( const QgsNumericFormat *format ) const
{
if ( !format )
return nullptr;

if ( !mFormatConfigurationWidgetFactories.contains( format->id() ) )
return nullptr;

return mFormatConfigurationWidgetFactories.value( format->id() )->create( format );
}
@@ -0,0 +1,90 @@
/***************************************************************************
qgsnumericformatguiregistry.h
-----------------------------
begin : January 2020
copyright : (C) 2020 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 QGSNUMERICFORMATGUIREGISTRY_H
#define QGSNUMERICFORMATGUIREGISTRY_H

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

class QgsNumericFormatWidget;
class QgsNumericFormat;

/**
* Interface base class for factories for numeric format configuration widgets.
*
* \ingroup gui
* \since QGIS 3.12
*/
class GUI_EXPORT QgsNumericFormatConfigurationWidgetFactory
{
public:
virtual ~QgsNumericFormatConfigurationWidgetFactory() = default;

/**
* Create a new configuration widget for a format.
*/
virtual QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const = 0 SIP_FACTORY;
};

/**
* The QgsNumericFormatGuiRegistry is a home for widgets for configuring QgsNumericFormat objects.
*
* QgsNumericFormatGuiRegistry is not usually directly created, but rather accessed through
* QgsGui::numericFormatGuiRegistry().
*
* \ingroup gui
* \since QGIS 3.12
*/
class GUI_EXPORT QgsNumericFormatGuiRegistry
{
public:

/**
* Constructor. Should never be called manually, is already
* created by QgsGui.
*/
QgsNumericFormatGuiRegistry();
~QgsNumericFormatGuiRegistry();

/**
* Add a new configuration widget factory for customizing a numeric format with the specified \a id.
*
* Ownership is taken by the reigstry.
*/
void addFormatConfigurationWidgetFactory( const QString &id, QgsNumericFormatConfigurationWidgetFactory *factory SIP_TRANSFER );

/**
* Removes the configuration widget factory for customizing numeric formats with the specified \a id.
*/
void removeFormatConfigurationWidgetFactory( const QString &id );

/**
* Returns a new configuration widget for an \a format.
*
* Returns NULLPTR if no configuration widgets are available for the specified \a format.
*/
QgsNumericFormatWidget *formatConfigurationWidget( const QgsNumericFormat *format ) const SIP_FACTORY;

private:

QMap< QString, QgsNumericFormatConfigurationWidgetFactory *> mFormatConfigurationWidgetFactories;
};

#endif // QGSNUMERICFORMATGUIREGISTRY_H
@@ -56,6 +56,7 @@
#include "qgsprojectstorageguiregistry.h"
#include "qgsmessagebar.h"
#include "qgsmessagebaritem.h"
#include "qgsnumericformatguiregistry.h"


QgsGui *QgsGui::instance()
@@ -104,6 +105,11 @@ QgsProcessingGuiRegistry *QgsGui::processingGuiRegistry()
return instance()->mProcessingGuiRegistry;
}

QgsNumericFormatGuiRegistry *QgsGui::numericFormatGuiRegistry()
{
return instance()->mNumericFormatGuiRegistry;
}

QgsProcessingRecentAlgorithmLog *QgsGui::processingRecentAlgorithmLog()
{
return instance()->mProcessingRecentAlgorithmLog;
@@ -168,6 +174,7 @@ QgsGui::~QgsGui()
delete mSourceSelectProviderRegistry;
delete mShortcutsManager;
delete mNative;
delete mNumericFormatGuiRegistry;
delete mWidgetStateHelper;
delete mProjectStorageGuiRegistry;
delete mProviderGuiRegistry;
@@ -221,6 +228,7 @@ QgsGui::QgsGui()
mProjectStorageGuiRegistry = new QgsProjectStorageGuiRegistry();
mDataItemGuiProviderRegistry = new QgsDataItemGuiProviderRegistry();
mSourceSelectProviderRegistry = new QgsSourceSelectProviderRegistry();
mNumericFormatGuiRegistry = new QgsNumericFormatGuiRegistry();

mProjectStorageGuiRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry );
mDataItemGuiProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry );
@@ -37,6 +37,7 @@ class QgsWindowManagerInterface;
class QgsDataItemGuiProviderRegistry;
class QgsProviderGuiRegistry;
class QgsProjectStorageGuiRegistry;
class QgsNumericFormatGuiRegistry;
class QgsMessageBar;

/**
@@ -115,6 +116,12 @@ class GUI_EXPORT QgsGui : public QObject
*/
static QgsProcessingGuiRegistry *processingGuiRegistry() SIP_KEEPREFERENCE;

/**
* Returns the global numeric format gui registry, used for registering the GUI widgets associated with QgsNumericFormats.
* \since QGIS 3.12
*/
static QgsNumericFormatGuiRegistry *numericFormatGuiRegistry() SIP_KEEPREFERENCE;

/**
* Returns the global processing recent algorithm log, used for tracking recently used processing algorithms.
* \since QGIS 3.4
@@ -219,6 +226,7 @@ class GUI_EXPORT QgsGui : public QObject
QgsLayoutItemGuiRegistry *mLayoutItemGuiRegistry = nullptr;
QgsProcessingGuiRegistry *mProcessingGuiRegistry = nullptr;
QgsProcessingRecentAlgorithmLog *mProcessingRecentAlgorithmLog = nullptr;
QgsNumericFormatGuiRegistry *mNumericFormatGuiRegistry = nullptr;
QgsDataItemGuiProviderRegistry *mDataItemGuiProviderRegistry = nullptr;
QgsProjectStorageGuiRegistry *mProjectStorageGuiRegistry = nullptr;
std::unique_ptr< QgsWindowManagerInterface > mWindowManager;

0 comments on commit ccf6898

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