26bool QgsSettingsEntryString::checkValue(
const QString &value )
const
28 if (
value.length() < mMinLength )
30 QgsDebugMsg( QObject::tr(
"Can't set value for settings. String length '%1' is shorter than minimum length '%2'." )
31 .arg(
value.length() )
37 &&
value.length() > mMaxLength )
39 QgsDebugMsg( QObject::tr(
"Can't set value for settings. String length '%1' is longer than maximum length '%2'." )
40 .arg(
value.length() )
48QString QgsSettingsEntryString::convertFromVariant(
const QVariant &value )
const
50 return value.toString();
68QStringList QgsSettingsEntryStringList::convertFromVariant(
const QVariant &value )
const
70 return value.toStringList();
79bool QgsSettingsEntryBool::convertFromVariant(
const QVariant &value )
const
81 return value.toBool();
91bool QgsSettingsEntryInteger::checkValue(
int value )
const
93 if (
value < mMinValue )
95 QgsDebugMsg( QObject::tr(
"Can't set value for setting. Value '%1' is less than minimum value '%2'." )
96 .arg( QString::number(
value ) )
97 .arg( QString::number( mMinValue ) ) );
101 if (
value > mMaxValue )
103 QgsDebugMsg( QObject::tr(
"Can't set value for setting. Value '%1' is greather than maximum value '%2'." )
104 .arg( QString::number(
value ) )
105 .arg( QString::number( mMaxValue ) ) );
112int QgsSettingsEntryInteger::convertFromVariant(
const QVariant &value )
const
114 return value.toLongLong();
132bool QgsSettingsEntryInteger64::checkValue( qlonglong value )
const
134 if (
value < mMinValue )
136 QgsDebugMsg( QObject::tr(
"Can't set value for setting. Value '%1' is less than minimum value '%2'." )
137 .arg( QString::number(
value ) )
138 .arg( QString::number( mMinValue ) ) );
142 if (
value > mMaxValue )
144 QgsDebugMsg( QObject::tr(
"Can't set value for setting. Value '%1' is greather than maximum value '%2'." )
145 .arg( QString::number(
value ) )
146 .arg( QString::number( mMaxValue ) ) );
153qlonglong QgsSettingsEntryInteger64::convertFromVariant(
const QVariant &value )
const
155 return value.toLongLong();
175bool QgsSettingsEntryDouble::checkValue(
double value )
const
177 if (
value < mMinValue )
179 QgsDebugMsg( QObject::tr(
"Can't set value for setting. Value '%1' is less than minimum value '%2'." )
180 .arg( QString::number(
value ), QString::number( mMinValue ) ) );
184 if (
value > mMaxValue )
186 QgsDebugMsg( QObject::tr(
"Can't set value for setting. Value '%1' is greather than maximum value '%2'." )
187 .arg( QString::number(
value ), QString::number( mMaxValue ) ) );
194double QgsSettingsEntryDouble::convertFromVariant(
const QVariant &value )
const
196 return value.toDouble();
221 return mDisplayHintDecimals;
225QColor QgsSettingsEntryColor::convertFromVariant(
const QVariant &value )
const
227 return value.value<QColor>();
235bool QgsSettingsEntryColor::checkValue(
const QColor &value )
const
237 if ( !mAllowAlpha &&
value.alpha() != 255 )
239 QgsDebugMsg( QObject::tr(
"Settings %1 doesn't allow transparency and the given color has transparency." ).arg(
definitionKey() ) );
249 if ( settings.
contains( redKey ) && settings.
contains( greenKey ) && settings.
contains( blueKey ) && ( alphaKey.isNull() || settings.
contains( alphaKey ) ) )
252 if ( alphaKey.isNull() )
253 oldValue = QColor( settings.
value( redKey ).toInt(), settings.
value( greenKey ).toInt(), settings.
value( blueKey ).toInt() );
255 oldValue = QColor( settings.
value( redKey ).toInt(), settings.
value( greenKey ).toInt(), settings.
value( blueKey ).toInt(), settings.
value( alphaKey ).toInt() );
257 if ( removeSettingAtKey )
259 settings.
remove( redKey );
260 settings.
remove( greenKey );
261 settings.
remove( blueKey );
262 settings.
remove( alphaKey );
274 const QColor color =
value();
275 settings.
setValue( redKey, color.red() );
276 settings.
setValue( greenKey, color.green() );
277 settings.
setValue( blueKey, color.blue() );
278 if ( !alphaKey.isNull() )
279 settings.
setValue( alphaKey, color.alpha() );
282QVariantMap QgsSettingsEntryVariantMap::convertFromVariant(
const QVariant &value )
const
284 return value.value<QVariantMap>();
SettingsType
Types of settings entries.
@ Variant
Generic variant.
@ StringList
List of strings.
@ VariantMap
Map of strings.
@ Double
Double precision number.
QString definitionKey() const
Returns settings entry defining key.
bool setVariantValuePrivate(const QVariant &value, const QStringList &dynamicKeyPartList=QStringList()) const
Sets the settings value with a variant value.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
QString value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
bool copyValueFromKeys(const QString &redKey, const QString &greenKey, const QString &blueKey, const QString &alphaKey=QString(), bool removeSettingAtKey=false) const
Copies the value from the given keys if they exist.
void copyValueToKeys(const QString &redKey, const QString &greenKey, const QString &blueKey, const QString &alphaKey=QString()) const
Copies the settings to the given keys.
void setDisplayHintDecimals(int displayHintDecimals)
Set the display hint decimals.
int displayHintDecimals() const
Returns how much decimals should be shown in the Gui.
double minValue() const
Returns the minimum value.
double maxValue() const
Returns the maximum value.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
qlonglong maxValue() const
Returns the maximum value.
qlonglong minValue() const
Returns the minimum value.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
int minValue() const
Returns the minimum value.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
int maxValue() const
Returns the maximum value.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
int maxLength() const
Returns the string maximum length.
int minLength() const
Returns the string minimum length.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.