Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start on registry for numeric format configuration widgets
- Loading branch information
1 parent
552913c
commit ccf6898
Showing
8 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
python/gui/auto_generated/numericformats/qgsnumericformatguiregistry.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters