Skip to content
Permalink
Browse files

Add configuration widgets for all numeric format types

  • Loading branch information
nyalldawson committed Jan 7, 2020
1 parent 1d6bc57 commit f5e965aa8617ee9a6610cf0af339f9a6948181cf
@@ -20,7 +20,7 @@ Base class for widgets which allow control over the properties of QgsNumericForm
%End
public:

QgsNumericFormatWidget( QWidget *parent /TransferThis/ );
QgsNumericFormatWidget( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsNumericFormatWidget.
%End
@@ -51,6 +51,116 @@ Emitted whenever the configuration of the numeric format is changed.
};




class QgsBasicNumericFormatWidget : QgsNumericFormatWidget
{

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

QgsBasicNumericFormatWidget( const QgsNumericFormat *format, QWidget *parent /TransferThis/ = 0 );
~QgsBasicNumericFormatWidget();

virtual void setFormat( QgsNumericFormat *format );


virtual QgsNumericFormat *format() /Factory/;


};



class QgsBearingNumericFormatWidget : QgsNumericFormatWidget
{

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

QgsBearingNumericFormatWidget( const QgsNumericFormat *format, QWidget *parent /TransferThis/ = 0 );
~QgsBearingNumericFormatWidget();

virtual void setFormat( QgsNumericFormat *format );


virtual QgsNumericFormat *format() /Factory/;


};




class QgsCurrencyNumericFormatWidget : QgsNumericFormatWidget
{

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

QgsCurrencyNumericFormatWidget( const QgsNumericFormat *format, QWidget *parent /TransferThis/ = 0 );
~QgsCurrencyNumericFormatWidget();

virtual void setFormat( QgsNumericFormat *format );


virtual QgsNumericFormat *format() /Factory/;


};




class QgsPercentageNumericFormatWidget : QgsNumericFormatWidget
{

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

QgsPercentageNumericFormatWidget( const QgsNumericFormat *format, QWidget *parent /TransferThis/ = 0 );
~QgsPercentageNumericFormatWidget();

virtual void setFormat( QgsNumericFormat *format );


virtual QgsNumericFormat *format() /Factory/;


};





class QgsScientificNumericFormatWidget : QgsNumericFormatWidget
{

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

QgsScientificNumericFormatWidget( const QgsNumericFormat *format, QWidget *parent /TransferThis/ = 0 );
~QgsScientificNumericFormatWidget();

virtual void setFormat( QgsNumericFormat *format );


virtual QgsNumericFormat *format() /Factory/;


};


/************************************************************************
* This file has been generated automatically from *
* *
@@ -21,6 +21,7 @@
QgsCurrencyNumericFormat::QgsCurrencyNumericFormat()
: mPrefix( QStringLiteral( "$" ) )
{
setNumberDecimalPlaces( 2 );
}

QString QgsCurrencyNumericFormat::id() const
@@ -58,6 +59,10 @@ QgsNumericFormat *QgsCurrencyNumericFormat::create( const QVariantMap &configura
res->setConfiguration( configuration, context );
res->mPrefix = configuration.value( QStringLiteral( "prefix" ), QStringLiteral( "$" ) ).toString();
res->mSuffix = configuration.value( QStringLiteral( "suffix" ), QString() ).toString();

// override base class default for number of decimal places -- we want to default to 2
res->setNumberDecimalPlaces( configuration.value( QStringLiteral( "decimals" ), 2 ).toInt() );

return res.release();
}

@@ -19,9 +19,65 @@
#include "qgis.h"
#include "qgsnumericformatwidget.h"


class QgsBasicNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
{
public:

QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
{
return new QgsBasicNumericFormatWidget( format );
}
};

class QgsBearingNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
{
public:

QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
{
return new QgsBearingNumericFormatWidget( format );
}
};

class QgsCurrencyNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
{
public:

QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
{
return new QgsCurrencyNumericFormatWidget( format );
}
};

class QgsPercentageNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
{
public:

QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
{
return new QgsPercentageNumericFormatWidget( format );
}
};

class QgsScientificNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
{
public:

QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
{
return new QgsScientificNumericFormatWidget( format );
}
};


QgsNumericFormatGuiRegistry::QgsNumericFormatGuiRegistry()
{
// addFormatConfigurationWidgetFactory( new QgsFilterAlgorithmConfigurationWidgetFactory() );
addFormatConfigurationWidgetFactory( QStringLiteral( "basic" ), new QgsBasicNumericFormatConfigurationWidgetFactory() );
addFormatConfigurationWidgetFactory( QStringLiteral( "bearing" ), new QgsBearingNumericFormatConfigurationWidgetFactory() );
addFormatConfigurationWidgetFactory( QStringLiteral( "currency" ), new QgsCurrencyNumericFormatConfigurationWidgetFactory() );
addFormatConfigurationWidgetFactory( QStringLiteral( "percentage" ), new QgsPercentageNumericFormatConfigurationWidgetFactory() );
addFormatConfigurationWidgetFactory( QStringLiteral( "scientific" ), new QgsScientificNumericFormatConfigurationWidgetFactory() );
}

QgsNumericFormatGuiRegistry::~QgsNumericFormatGuiRegistry()

0 comments on commit f5e965a

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