settings entries are meant to be const, options cannot be adjusted

This commit is contained in:
Denis Rouzaud 2023-01-17 11:47:30 +01:00
parent 7fa484dbf6
commit 7efec3e8f3
3 changed files with 39 additions and 158 deletions

View File

@ -193,23 +193,9 @@ This constructor is intended to be used from plugins.
virtual Qgis::SettingsType settingsType() const;
void setMinLength( int minLength );
%Docstring
Set the string minimum length.
minLength The string minimum length.
%End
int minLength() const;
%Docstring
Returns the string minimum length.
%End
void setMaxLength( int maxLength );
%Docstring
Set the string maximum length.
maxLength The string maximum length.
%End
int maxLength() const;
@ -384,9 +370,9 @@ This constructor is intended to be used from plugins.
typedef QgsSettingsEntryByValue<qlonglong> QgsSettingsEntryByValueqlonglongBase;
typedef QgsSettingsEntryByValue<int> QgsSettingsEntryByValueintBase;
class QgsSettingsEntryInteger : QgsSettingsEntryByValueqlonglongBase
class QgsSettingsEntryInteger : QgsSettingsEntryByValueintBase
{
%Docstring(signature="appended")
@ -398,17 +384,17 @@ An integer settings entry.
%TypeHeaderCode
#include "qgssettingsentryimpl.h"
#include "qgssettingsentry.h"
typedef QgsSettingsEntryByValue<qlonglong> QgsSettingsEntryByValueqlonglongBase;
typedef QgsSettingsEntryByValue<int> QgsSettingsEntryByValueintBase;
%End
public:
QgsSettingsEntryInteger( const QString &key,
QgsSettingsTreeNode *parent,
qlonglong defaultValue = 0,
int defaultValue = 0,
const QString &description = QString(),
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
qlonglong minValue = LLONG_MIN,
qlonglong maxValue = LLONG_MAX ) throw( QgsSettingsException ) /Transfer/;
int minValue = INT_MIN,
int maxValue = INT_MAX ) throw( QgsSettingsException ) /Transfer/;
%Docstring
Constructor for QgsSettingsEntryInteger.
@ -424,11 +410,11 @@ Constructor for QgsSettingsEntryInteger.
private:
QgsSettingsEntryInteger( const QString &key,
const QString &section,
qlonglong defaultValue = 0,
int defaultValue = 0,
const QString &description = QString(),
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
qlonglong minValue = LLONG_MIN,
qlonglong maxValue = LLONG_MAX ) throw( QgsSettingsException ) /Transfer/;
int minValue = INT_MIN,
int maxValue = INT_MAX ) throw( QgsSettingsException ) /Transfer/;
%Docstring
Constructor for QgsSettingsEntryInteger.
@ -444,11 +430,11 @@ Constructor for QgsSettingsEntryInteger.
QgsSettingsEntryInteger( const QString &key,
const QString &pluginName,
qlonglong defaultValue = 0,
int defaultValue = 0,
const QString &description = QString(),
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
qlonglong minValue = LLONG_MIN,
qlonglong maxValue = LLONG_MAX ) throw( QgsSettingsException ) /Transfer/;
int minValue = INT_MIN,
int maxValue = INT_MAX ) throw( QgsSettingsException ) /Transfer/;
%Docstring
Constructor for QgsSettingsEntryInteger.
This constructor is intended to be used from plugins.
@ -467,35 +453,20 @@ This constructor is intended to be used from plugins.
virtual Qgis::SettingsType settingsType() const;
void setMinValue( qlonglong minValue );
%Docstring
Set the minimum value.
minValue The minimum value.
%End
qlonglong minValue() const;
int minValue() const;
%Docstring
Returns the minimum value.
%End
void setMaxValue( qlonglong maxValue );
%Docstring
Set the maximum value.
maxValue The maximum value.
%End
qlonglong maxValue() const;
int maxValue() const;
%Docstring
Returns the maximum value.
%End
private:
virtual bool checkValue( qlonglong value ) const;
virtual bool checkValue( int value ) const;
virtual qlonglong convertFromVariant( const QVariant &value ) const;
virtual int convertFromVariant( const QVariant &value ) const;
};
@ -593,23 +564,9 @@ This constructor is intended to be used from plugins.
virtual Qgis::SettingsType settingsType() const;
void setMinValue( double minValue );
%Docstring
Set the minimum value.
minValue The minimum value.
%End
double minValue() const;
%Docstring
Returns the minimum value.
%End
void setMaxValue( double maxValue );
%Docstring
Set the maximum value.
maxValue The maximum value.
%End
double maxValue() const;

View File

@ -55,28 +55,16 @@ Qgis::SettingsType QgsSettingsEntryString::settingsType() const
return Qgis::SettingsType::String;
}
void QgsSettingsEntryString::setMinLength( int minLength )
{
mMinLength = minLength;
}
int QgsSettingsEntryString::minLength() const
{
return mMinLength;
}
void QgsSettingsEntryString::setMaxLength( int maxLength )
{
mMaxLength = maxLength;
}
int QgsSettingsEntryString::maxLength() const
{
return mMaxLength;
}
QStringList QgsSettingsEntryStringList::convertFromVariant( const QVariant &value ) const
{
return value.toStringList();
@ -100,7 +88,7 @@ Qgis::SettingsType QgsSettingsEntryBool::settingsType() const
}
bool QgsSettingsEntryInteger::checkValue( qlonglong value ) const
bool QgsSettingsEntryInteger::checkValue( int value ) const
{
if ( value < mMinValue )
{
@ -121,7 +109,7 @@ bool QgsSettingsEntryInteger::checkValue( qlonglong value ) const
return true;
}
qlonglong QgsSettingsEntryInteger::convertFromVariant( const QVariant &value ) const
int QgsSettingsEntryInteger::convertFromVariant( const QVariant &value ) const
{
return value.toLongLong();
}
@ -131,26 +119,15 @@ Qgis::SettingsType QgsSettingsEntryInteger::settingsType() const
return Qgis::SettingsType::Integer;
}
void QgsSettingsEntryInteger::setMinValue( qlonglong minValue )
{
mMinValue = minValue;
}
qlonglong QgsSettingsEntryInteger::minValue() const
{
return mMinValue;
}
void QgsSettingsEntryInteger::setMaxValue( qlonglong maxValue )
{
mMaxValue = maxValue;
}
qlonglong QgsSettingsEntryInteger::maxValue() const
int QgsSettingsEntryInteger::maxValue() const
{
return mMaxValue;
}
int QgsSettingsEntryInteger::minValue() const
{
return mMaxValue;
}
@ -183,21 +160,11 @@ Qgis::SettingsType QgsSettingsEntryDouble::settingsType() const
return Qgis::SettingsType::Double;
}
void QgsSettingsEntryDouble::setMinValue( double minValue )
{
mMinValue = minValue;
}
double QgsSettingsEntryDouble::minValue() const
{
return mMinValue;
}
void QgsSettingsEntryDouble::setMaxValue( double maxValue )
{
mMaxValue = maxValue;
}
double QgsSettingsEntryDouble::maxValue() const
{
return mMaxValue;

View File

@ -201,25 +201,11 @@ class CORE_EXPORT QgsSettingsEntryString : public QgsSettingsEntryByReference<QS
virtual Qgis::SettingsType settingsType() const override;
/**
* Set the string minimum length.
*
* minLength The string minimum length.
*/
void setMinLength( int minLength );
/**
* Returns the string minimum length.
*/
int minLength() const;
/**
* Set the string maximum length.
*
* maxLength The string maximum length.
*/
void setMaxLength( int maxLength );
/**
* Returns the string maximum length. By -1 there is no limitation.
*/
@ -393,7 +379,7 @@ class CORE_EXPORT QgsSettingsEntryBool : public QgsSettingsEntryByValue<bool>
* \brief An integer settings entry.
* \since QGIS 3.20
*/
class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue<qlonglong>
class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue<int>
{
public:
@ -410,11 +396,11 @@ class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue<qlong
*/
QgsSettingsEntryInteger( const QString &key,
QgsSettingsTreeNode *parent,
qlonglong defaultValue = 0,
int defaultValue = 0,
const QString &description = QString(),
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
qlonglong minValue = std::numeric_limits<qlonglong>::min(),
qlonglong maxValue = std::numeric_limits<qlonglong>::max() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER
int minValue = std::numeric_limits<int>::min(),
int maxValue = std::numeric_limits<int>::max() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER
: QgsSettingsEntryByValue( key, parent, defaultValue, description, options )
, mMinValue( minValue )
, mMaxValue( maxValue )
@ -433,11 +419,11 @@ class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue<qlong
*/
QgsSettingsEntryInteger( const QString &key,
const QString &section,
qlonglong defaultValue = 0,
int defaultValue = 0,
const QString &description = QString(),
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
qlonglong minValue = std::numeric_limits<qlonglong>::min(),
qlonglong maxValue = std::numeric_limits<qlonglong>::max() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER SIP_MAKE_PRIVATE
int minValue = std::numeric_limits<int>::min(),
int maxValue = std::numeric_limits<int>::max() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER SIP_MAKE_PRIVATE
: QgsSettingsEntryByValue( key, section, defaultValue, description, options )
, mMinValue( minValue )
, mMaxValue( maxValue )
@ -459,11 +445,11 @@ class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue<qlong
*/
QgsSettingsEntryInteger( const QString &key,
const QString &pluginName,
qlonglong defaultValue = 0,
int defaultValue = 0,
const QString &description = QString(),
Qgis::SettingsOptions options = Qgis::SettingsOptions(),
qlonglong minValue = std::numeric_limits<qlonglong>::min(),
qlonglong maxValue = std::numeric_limits<qlonglong>::max() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
int minValue = std::numeric_limits<int>::min(),
int maxValue = std::numeric_limits<int>::max() ) SIP_THROW( QgsSettingsException ) SIP_TRANSFER;
% MethodCode
sipCpp = new sipQgsSettingsEntryInteger( QgsSettingsEntryInteger( *a0, QgsSettings::createPluginTreeElement( *a1 ), a2, *a3, *a4, a5, a6 ) );
% End
@ -471,36 +457,21 @@ class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntryByValue<qlong
virtual Qgis::SettingsType settingsType() const override;
/**
* Set the minimum value.
*
* minValue The minimum value.
*/
void setMinValue( qlonglong minValue );
/**
* Returns the minimum value.
*/
qlonglong minValue() const;
/**
* Set the maximum value.
*
* maxValue The maximum value.
*/
void setMaxValue( qlonglong maxValue );
int minValue() const;
/**
* Returns the maximum value.
*/
qlonglong maxValue() const;
int maxValue() const;
private:
bool checkValue( qlonglong value ) const override SIP_FORCE;
qlonglong convertFromVariant( const QVariant &value ) const override SIP_FORCE;
qlonglong mMinValue;
qlonglong mMaxValue;
bool checkValue( int value ) const override SIP_FORCE;
int convertFromVariant( const QVariant &value ) const override SIP_FORCE;
int mMinValue;
int mMaxValue;
};
@ -600,25 +571,11 @@ class CORE_EXPORT QgsSettingsEntryDouble : public QgsSettingsEntryByValue<double
virtual Qgis::SettingsType settingsType() const override;
/**
* Set the minimum value.
*
* minValue The minimum value.
*/
void setMinValue( double minValue );
/**
* Returns the minimum value.
*/
double minValue() const;
/**
* Set the maximum value.
*
* maxValue The maximum value.
*/
void setMaxValue( double maxValue );
/**
* Returns the maximum value.
*/