Skip to content

Commit

Permalink
settings entries are meant to be const, options cannot be adjusted
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jan 17, 2023
1 parent 7fa484d commit 7efec3e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 156 deletions.
75 changes: 16 additions & 59 deletions python/core/auto_generated/settings/qgssettingsentryimpl.sip.in
Expand Up @@ -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;
Expand Down Expand Up @@ -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")

Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -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.
Expand All @@ -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;

};

Expand Down Expand Up @@ -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;
Expand Down
43 changes: 5 additions & 38 deletions src/core/settings/qgssettingsentryimpl.cpp
Expand Up @@ -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();
Expand All @@ -100,7 +88,7 @@ Qgis::SettingsType QgsSettingsEntryBool::settingsType() const
}


bool QgsSettingsEntryInteger::checkValue( qlonglong value ) const
bool QgsSettingsEntryInteger::checkValue( int value ) const
{
if ( value < mMinValue )
{
Expand All @@ -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();
}
Expand All @@ -131,29 +119,18 @@ Qgis::SettingsType QgsSettingsEntryInteger::settingsType() const
return Qgis::SettingsType::Integer;
}

void QgsSettingsEntryInteger::setMinValue( qlonglong minValue )
{
mMinValue = minValue;
}

qlonglong QgsSettingsEntryInteger::minValue() const
int QgsSettingsEntryInteger::maxValue() const
{
return mMinValue;
}

void QgsSettingsEntryInteger::setMaxValue( qlonglong maxValue )
{
mMaxValue = maxValue;
return mMaxValue;
}

qlonglong QgsSettingsEntryInteger::maxValue() const
int QgsSettingsEntryInteger::minValue() const
{
return mMaxValue;
}




bool QgsSettingsEntryDouble::checkValue( double value ) const
{
if ( value < mMinValue )
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7efec3e

Please sign in to comment.