static inline settings

This commit is contained in:
Damiano 2021-03-30 17:08:50 +02:00
parent 2db776ec35
commit 21c19aba9c
15 changed files with 632 additions and 252 deletions

View File

@ -614,6 +614,14 @@ should be canceled.
.. versionadded:: 3.10
%End
struct Settings
{
static QgsSettingsEntryStringList searchPathForTemplates = QgsSettingsEntryStringList( QStringLiteral( "Layout/searchPathsForTemplates" ), QgsSettings::Core, QStringList(), "Search path for templates" );
};
public slots:
void refresh();

View File

@ -141,6 +141,11 @@ This list is updated when preparing the search
.. versionadded:: 3.16
%End
struct Settings
{
};
signals:
void foundResult( const QgsLocatorResult &result );

View File

@ -657,6 +657,13 @@ Returns the application's task manager, used for managing application
wide background task handling.
.. versionadded:: 3.0
%End
static QgsSettingsRegistryCore *settingsRegistryCore() /KeepReference/;
%Docstring
Returns the application's settings registry, used for managing application settings.
.. versionadded:: 3.20
%End
static QgsColorSchemeRegistry *colorSchemeRegistry() /KeepReference/;

View File

@ -0,0 +1,306 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/settings/qgssettingsentry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsSettingsEntry
{
%Docstring(signature="appended")
Represent settings entry and provides methods for reading and writing settings values.
Different subclasses are provided for different settings types with metainformations
to validate set values and provide more accurate settings description for the gui.
.. versionadded:: 3.20
%End
%TypeHeaderCode
#include "qgssettingsentry.h"
%End
%ConvertToSubClassCode
if ( dynamic_cast< QgsSettingsEntryString * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryString;
if ( dynamic_cast< QgsSettingsEntryStringList * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryStringList;
else if ( dynamic_cast< QgsSettingsEntryBool * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryBool;
// else if ( dynamic_cast< QgsSettingsEntryInteger * >( sipCpp ) )
// sipType = sipType_QgsSettingsEntryInteger;
// else if ( dynamic_cast< QgsSettingsEntryDouble * >( sipCpp ) )
// sipType = sipType_QgsSettingsEntryDouble;
else
sipType = NULL;
%End
public:
enum SettingsType
{
Variant,
String,
StringList,
Bool,
Integer,
Double,
Enum
};
QgsSettingsEntry( QString key,
QgsSettings::Section section,
QVariant defaultValue = QVariant(),
QString description = QString() );
%Docstring
Constructor for QgsSettingsEntry.
The ``key`` argument specifies the key of the settings.
The ``section`` argument specifies the section of the settings.
The ``default`` value argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
%End
virtual ~QgsSettingsEntry();
QString key( const QString &dynamicKeyPart = QString() ) const;
%Docstring
Get settings entry key.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
bool hasDynamicKey() const;
%Docstring
Returns true if a part of the settings key is built dynamically.
%End
bool exists( const QString &dynamicKeyPart = QString() ) const;
%Docstring
Returns true if the settings is contained in the underlying QSettings.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
void remove( const QString &dynamicKeyPart = QString() ) const;
%Docstring
Removes the settings from the underlying QSettings.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
QgsSettings::Section section() const;
%Docstring
Get settings section. The settings section of the parent group is returned if available.
%End
virtual bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() );
%Docstring
Set settings value.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
QVariant valueFromPython() const /PyName=value/;
%Docstring
Get settings value.
%End
QVariant defaultValueFromPython() const /PyName=defaultValue/;
%Docstring
Get settings default value.
%End
virtual SettingsType settingsType() const;
%Docstring
Get the settings entry type.
%End
QString description() const;
%Docstring
Get the settings entry description.
%End
};
class QgsSettingsEntryString : QgsSettingsEntry
{
%Docstring(signature="appended")
A string settings entry.
.. versionadded:: 3.20
%End
%TypeHeaderCode
#include "qgssettingsentry.h"
%End
public:
QgsSettingsEntryString( const QString &key,
QgsSettings::Section section,
const QString &defaultValue = QString(),
const QString &description = QString(),
int minLength = 0,
int maxLength = -1 );
%Docstring
Constructor for QgsSettingsEntryString.
The ``key`` argument specifies the final part of the settings key.
The ``parentGroup`` argument specifies a parent group which is used to rebuild
the entiere settings key and to determine the settings section.
The ``default`` value argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
The ``minLength`` argument specifies the minimal length of the string value.
The ``maxLength`` argument specifies the maximal length of the string value.
By -1 the there is no limit
%End
virtual bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() );
%Docstring
\copydoc :py:class:`QgsSettingsEntry`.setValue
%End
virtual SettingsType settingsType() const;
%Docstring
\copydoc :py:class:`QgsSettingsEntry`.settingsType
%End
int minLength();
%Docstring
Returns the string minimum length.
%End
int maxLength();
%Docstring
Returns the string maximum length. By -1 there is no limitation.
%End
};
class QgsSettingsEntryStringList : QgsSettingsEntry
{
%Docstring(signature="appended")
A string list settings entry.
.. versionadded:: 3.20
%End
%TypeHeaderCode
#include "qgssettingsentry.h"
%End
public:
QgsSettingsEntryStringList( const QString &key,
QgsSettings::Section section,
const QStringList &defaultValue = QStringList(),
const QString &description = QString() );
%Docstring
Constructor for QgsSettingsEntryStringList.
The ``key`` argument specifies the final part of the settings key.
The ``parentGroup`` argument specifies a parent group which is used to rebuild
the entiere settings key and to determine the settings section.
The ``default`` value argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
%End
virtual bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() );
%Docstring
\copydoc :py:class:`QgsSettingsEntry`.setValue
%End
virtual SettingsType settingsType() const;
%Docstring
\copydoc :py:class:`QgsSettingsEntry`.settingsType
%End
};
class QgsSettingsEntryBool : QgsSettingsEntry
{
%Docstring(signature="appended")
A boolean settings entry.
.. versionadded:: 3.20
%End
%TypeHeaderCode
#include "qgssettingsentry.h"
%End
public:
QgsSettingsEntryBool( const QString &key,
QgsSettings::Section section,
bool defaultValue = false,
const QString &description = QString() );
%Docstring
Constructor for QgsSettingsEntryBool.
The ``key`` argument specifies the final part of the settings key.
The ``parentGroup`` argument specifies a parent group which is used to rebuild
the entiere settings key and to determine the settings section.
The ``default`` value argument specifies the default value for the settings entry.
The ``description`` argument specifies a description for the settings entry.
%End
virtual bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() );
%Docstring
\copydoc :py:class:`QgsSettingsEntry`.setValue
%End
virtual SettingsType settingsType() const;
%Docstring
\copydoc :py:class:`QgsSettingsEntry`.settingsType
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/settings/qgssettingsentry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -0,0 +1,39 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/settings/qgssettingsregistrycore.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsSettingsRegistryCore
{
%Docstring(signature="appended")
.. versionadded:: 3.20
%End
%TypeHeaderCode
#include "qgssettingsregistrycore.h"
%End
public:
QgsSettingsRegistryCore();
~QgsSettingsRegistryCore();
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/settings/qgssettingsregistrycore.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -602,6 +602,8 @@
%Include auto_generated/textrenderer/qgstextrenderer.sip
%Include auto_generated/textrenderer/qgstextrendererutils.sip
%Include auto_generated/textrenderer/qgstextshadowsettings.sip
%Include auto_generated/settings/qgssettingsentry.sip
%Include auto_generated/settings/qgssettingsregistrycore.sip
%Include auto_generated/validity/qgsabstractvaliditycheck.sip
%Include auto_generated/validity/qgsvaliditycheckcontext.sip
%Include auto_generated/validity/qgsvaliditycheckregistry.sip

View File

@ -330,26 +330,30 @@ void QgsLocatorFiltersModel::commitChanges()
if ( !activePrefix.isEmpty() && activePrefix != filter->prefix() )
{
filter->setActivePrefix( activePrefix );
QgsLocator::Settings::LocatorFilterPrefix().setValue( activePrefix, filter->name() );
// QgsLocator::Settings::LocatorFilterPrefix().setValue( activePrefix, filter->name() );
// QgsLocator::Settings::locatorFilterPrefix.setValue( activePrefix, filter->name() );
}
else
{
filter->setActivePrefix( QString() );
QgsLocator::Settings::LocatorFilterPrefix().remove( filter->name() );
// QgsLocator::Settings::LocatorFilterPrefix().remove( filter->name() );
// QgsLocator::Settings::locatorFilterPrefix.remove( filter->name() );
}
}
QHash< QgsLocatorFilter *, bool >::const_iterator it = mEnabledChanges.constBegin();
for ( ; it != mEnabledChanges.constEnd(); ++it )
{
QgsLocatorFilter *filter = it.key();
QgsLocator::Settings::LocatorFilterEnabled().setValue( it.value(), filter->name() );
// QgsLocator::Settings::LocatorFilterEnabled().setValue( it.value(), filter->name() );
// QgsLocator::Settings::locatorFilterEnabled.setValue( it.value(), filter->name() );
filter->setEnabled( it.value() );
}
it = mDefaultChanges.constBegin();
for ( ; it != mDefaultChanges.constEnd(); ++it )
{
QgsLocatorFilter *filter = it.key();
QgsLocator::Settings::LocatorFilterDefault().setValue( it.value(), filter->name() );
// QgsLocator::Settings::LocatorFilterDefault().setValue( it.value(), filter->name() );
// QgsLocator::Settings::locatorFilterDefault.setValue( it.value(), filter->name() );
filter->setUseWithoutPrefix( it.value() );
}
}

View File

@ -1481,7 +1481,8 @@ void QgsOptions::saveOptions()
{
pathsList << mListComposerTemplatePaths->item( i )->text();
}
QgsLayout::Settings::SearchPathForTemplates().setValue( pathsList );
// QgsLayout::Settings::searchPathForTemplates.setValue( pathsList );
// QgsLayout::Settings::SearchPathForTemplates().setValue( pathsList );
pathsList.clear();
for ( int r = 0; r < mLocalizedDataPathListWidget->count(); r++ )

View File

@ -658,9 +658,19 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
*/
bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
struct Settings
{
QGS_SETTING_ENTRY_STRINGLIST( SearchPathForTemplates, QStringLiteral( "Layout/searchPathsForTemplates" ), QgsSettings::Core, QStringList(), tr( "Search path for templates" ) )
static inline QgsSettingsEntryStringList searchPathForTemplates = QgsSettingsEntryStringList( QStringLiteral( "Layout/searchPathsForTemplates" ), QgsSettings::Core, QStringList(), "Search path for templates" );
// QGS_SETTING_ENTRY_STRINGLIST( SearchPathForTemplates, QStringLiteral( "Layout/searchPathsForTemplates" ), QgsSettings::Core, QStringList(), tr( "Search path for templates" ) )
// struct SearchPathForTemplates : public QgsSettingsEntryStringList
// {
// SearchPathForTemplates()
// : QgsSettingsEntryStringList( QStringLiteral( "Layout/searchPathsForTemplates" ), QgsSettings::Core, QStringList(), tr( "Search path for templates" ) )
// {}
// };
};
public slots:

View File

@ -95,14 +95,20 @@ void QgsLocator::registerFilter( QgsLocatorFilter *filter )
// restore settings
bool enabled = true;
if ( QgsLocator::Settings::LocatorFilterEnabled().exists( filter->name() ) )
enabled = QgsLocator::Settings::LocatorFilterEnabled().value<bool>( filter->name() );
// if ( QgsLocator::Settings::LocatorFilterEnabled().exists( filter->name() ) )
// enabled = QgsLocator::Settings::LocatorFilterEnabled().value<bool>( filter->name() );
// if ( QgsLocator::Settings::locatorFilterEnabled.exists( filter->name() ) )
// enabled = QgsLocator::Settings::locatorFilterEnabled.value<bool>( filter->name() );
bool byDefault = filter->useWithoutPrefix();
if ( QgsLocator::Settings::LocatorFilterDefault().exists( filter->name() ) )
byDefault = QgsLocator::Settings::LocatorFilterDefault().value<bool>( filter->name() );
// if ( QgsLocator::Settings::LocatorFilterDefault().exists( filter->name() ) )
// byDefault = QgsLocator::Settings::LocatorFilterDefault().value<bool>( filter->name() );
// if ( QgsLocator::Settings::locatorFilterDefault.exists( filter->name() ) )
// byDefault = QgsLocator::Settings::locatorFilterDefault.value<bool>( filter->name() );
QString prefix = filter->prefix();
if ( QgsLocator::Settings::LocatorFilterPrefix().exists( filter->name() ) )
prefix = QgsLocator::Settings::LocatorFilterPrefix().value<QString>( filter->name() );
// if ( QgsLocator::Settings::LocatorFilterPrefix().exists( filter->name() ) )
// prefix = QgsLocator::Settings::LocatorFilterPrefix().value<QString>( filter->name() );
// if ( QgsLocator::Settings::locatorFilterPrefix.exists( filter->name() ) )
// prefix = QgsLocator::Settings::locatorFilterPrefix.value<QString>( filter->name() );
if ( prefix.isEmpty() )
{
prefix = filter->prefix();

View File

@ -155,9 +155,13 @@ class CORE_EXPORT QgsLocator : public QObject
struct Settings
{
QGS_SETTING_ENTRY_BOOL( LocatorFilterEnabled, QStringLiteral( "locator_filters/enabled_%" ), QgsSettings::Gui, true, tr( "Enabled" ) )
QGS_SETTING_ENTRY_BOOL( LocatorFilterDefault, QStringLiteral( "locator_filters/default_%" ), QgsSettings::Gui, false, tr( "Default value" ) )
QGS_SETTING_ENTRY_STRING( LocatorFilterPrefix, QStringLiteral( "locator_filters/prefix_%" ), QgsSettings::Gui, QString(), tr( "Locator filter prefix" ) )
// static inline QgsSettingsEntryBool locatorFilterEnabled = QgsSettingsEntryBool( QStringLiteral( "locator_filters/enabled_%" ), QgsSettings::Gui, true, "Enabled" );
// static inline QgsSettingsEntryBool locatorFilterDefault = QgsSettingsEntryBool( QStringLiteral( "locator_filters/default_%" ), QgsSettings::Gui, false, "Default value" );
// static inline QgsSettingsEntryString locatorFilterPrefix = QgsSettingsEntryString( QStringLiteral( "locator_filters/prefix_%" ), QgsSettings::Gui, QString(), "Locator filter prefix" );
// QGS_SETTING_ENTRY_BOOL( LocatorFilterEnabled, QStringLiteral( "locator_filters/enabled_%" ), QgsSettings::Gui, true, tr( "Enabled" ) )
// QGS_SETTING_ENTRY_BOOL( LocatorFilterDefault, QStringLiteral( "locator_filters/default_%" ), QgsSettings::Gui, false, tr( "Default value" ) )
// QGS_SETTING_ENTRY_STRING( LocatorFilterPrefix, QStringLiteral( "locator_filters/prefix_%" ), QgsSettings::Gui, QString(), tr( "Locator filter prefix" ) )
};
signals:

View File

@ -1107,7 +1107,8 @@ QStringList QgsApplication::layoutTemplatePaths()
{
//local directories to search when looking for an template with a given basename
//defined by user in options dialog
return QgsLayout::Settings::SearchPathForTemplates().value<QStringList>();
return QgsLayout::Settings::searchPathForTemplates.value<QStringList>();
// return QgsLayout::Settings::SearchPathForTemplates().value<QStringList>();
}
QMap<QString, QString> QgsApplication::systemEnvVars()

View File

@ -229,140 +229,140 @@ QgsSettingsEntry::SettingsType QgsSettingsEntryBool::settingsType() const
return QgsSettingsEntry::Bool;
}
QgsSettingsEntryInteger::QgsSettingsEntryInteger( const QString &key,
QgsSettings::Section section,
qlonglong defaultValue,
const QString &description,
qlonglong minValue,
qlonglong maxValue )
: QgsSettingsEntry( key,
section,
defaultValue,
description )
, mMinValue( minValue )
, mMaxValue( maxValue )
{
//QgsSettingsEntryInteger::QgsSettingsEntryInteger( const QString &key,
// QgsSettings::Section section,
// qlonglong defaultValue,
// const QString &description,
// qlonglong minValue,
// qlonglong maxValue )
// : QgsSettingsEntry( key,
// section,
// defaultValue,
// description )
// , mMinValue( minValue )
// , mMaxValue( maxValue )
//{
}
//}
bool QgsSettingsEntryInteger::setValue( const QVariant &value, const QString &dynamicKeyPart )
{
if ( value.canConvert<qlonglong>() == false )
{
QgsDebugMsg( QObject::tr( "Can't convert value '%1' to qlonglong for settings with key '%2'" )
.arg( value.toString() )
.arg( QgsSettingsEntry::key() ) );
return false;
}
//bool QgsSettingsEntryInteger::setValue( const QVariant &value, const QString &dynamicKeyPart )
//{
// if ( value.canConvert<qlonglong>() == false )
// {
// QgsDebugMsg( QObject::tr( "Can't convert value '%1' to qlonglong for settings with key '%2'" )
// .arg( value.toString() )
// .arg( QgsSettingsEntry::key() ) );
// return false;
// }
qlonglong valueLongLong = value.toLongLong();
if ( valueLongLong < mMinValue )
{
QgsDebugMsg( QObject::tr( "Can't set value for settings with key '%1'. Value '%2' is less than minimum value '%3'." )
.arg( QgsSettingsEntry::key() )
.arg( valueLongLong )
.arg( mMinValue ) );
return false;
}
// qlonglong valueLongLong = value.toLongLong();
// if ( valueLongLong < mMinValue )
// {
// QgsDebugMsg( QObject::tr( "Can't set value for settings with key '%1'. Value '%2' is less than minimum value '%3'." )
// .arg( QgsSettingsEntry::key() )
// .arg( valueLongLong )
// .arg( mMinValue ) );
// return false;
// }
if ( valueLongLong > mMaxValue )
{
QgsDebugMsg( QObject::tr( "Can't set value for settings with key '%1'. Value '%2' is greather than maximum value '%3'." )
.arg( QgsSettingsEntry::key() )
.arg( valueLongLong )
.arg( mMinValue ) );
return false;
}
// if ( valueLongLong > mMaxValue )
// {
// QgsDebugMsg( QObject::tr( "Can't set value for settings with key '%1'. Value '%2' is greather than maximum value '%3'." )
// .arg( QgsSettingsEntry::key() )
// .arg( valueLongLong )
// .arg( mMinValue ) );
// return false;
// }
QgsSettingsEntry::setValue( value, dynamicKeyPart );
return true;
}
// QgsSettingsEntry::setValue( value, dynamicKeyPart );
// return true;
//}
QgsSettingsEntry::SettingsType QgsSettingsEntryInteger::settingsType() const
{
return QgsSettingsEntry::Integer;
}
//QgsSettingsEntry::SettingsType QgsSettingsEntryInteger::settingsType() const
//{
// return QgsSettingsEntry::Integer;
//}
qlonglong QgsSettingsEntryInteger::minValue()
{
return mMinValue;
}
//qlonglong QgsSettingsEntryInteger::minValue()
//{
// return mMinValue;
//}
qlonglong QgsSettingsEntryInteger::maxValue()
{
return mMaxValue;
}
//qlonglong QgsSettingsEntryInteger::maxValue()
//{
// return mMaxValue;
//}
QgsSettingsEntryDouble::QgsSettingsEntryDouble( const QString &key,
QgsSettings::Section section,
double defaultValue,
const QString &description,
double minValue,
double maxValue,
double displayDecimals )
: QgsSettingsEntry( key,
section,
defaultValue,
description )
, mMinValue( minValue )
, mMaxValue( maxValue )
, mDisplayHintDecimals( displayDecimals )
{
//QgsSettingsEntryDouble::QgsSettingsEntryDouble( const QString &key,
// QgsSettings::Section section,
// double defaultValue,
// const QString &description,
// double minValue,
// double maxValue,
// double displayDecimals )
// : QgsSettingsEntry( key,
// section,
// defaultValue,
// description )
// , mMinValue( minValue )
// , mMaxValue( maxValue )
// , mDisplayHintDecimals( displayDecimals )
//{
}
//}
bool QgsSettingsEntryDouble::setValue( const QVariant &value, const QString &dynamicKeyPart )
{
if ( value.canConvert<double>() == false )
{
QgsDebugMsg( QObject::tr( "Can't convert value '%1' to double for settings with key '%2'" )
.arg( value.toString() )
.arg( QgsSettingsEntry::key() ) );
return false;
}
//bool QgsSettingsEntryDouble::setValue( const QVariant &value, const QString &dynamicKeyPart )
//{
// if ( value.canConvert<double>() == false )
// {
// QgsDebugMsg( QObject::tr( "Can't convert value '%1' to double for settings with key '%2'" )
// .arg( value.toString() )
// .arg( QgsSettingsEntry::key() ) );
// return false;
// }
double valueDouble = value.toDouble();
if ( valueDouble < mMinValue )
{
QgsDebugMsg( QObject::tr( "Can't set value for settings with key '%1'. Value '%2' is less than minimum value '%3'." )
.arg( QgsSettingsEntry::key() )
.arg( valueDouble )
.arg( mMinValue ) );
return false;
}
// double valueDouble = value.toDouble();
// if ( valueDouble < mMinValue )
// {
// QgsDebugMsg( QObject::tr( "Can't set value for settings with key '%1'. Value '%2' is less than minimum value '%3'." )
// .arg( QgsSettingsEntry::key() )
// .arg( valueDouble )
// .arg( mMinValue ) );
// return false;
// }
if ( valueDouble > mMaxValue )
{
QgsDebugMsg( QObject::tr( "Can't set value for settings with key '%1'. Value '%2' is greather than maximum value '%3'." )
.arg( QgsSettingsEntry::key() )
.arg( valueDouble )
.arg( mMinValue ) );
return false;
}
// if ( valueDouble > mMaxValue )
// {
// QgsDebugMsg( QObject::tr( "Can't set value for settings with key '%1'. Value '%2' is greather than maximum value '%3'." )
// .arg( QgsSettingsEntry::key() )
// .arg( valueDouble )
// .arg( mMinValue ) );
// return false;
// }
QgsSettingsEntry::setValue( value, dynamicKeyPart );
return true;
}
// QgsSettingsEntry::setValue( value, dynamicKeyPart );
// return true;
//}
QgsSettingsEntry::SettingsType QgsSettingsEntryDouble::settingsType() const
{
return QgsSettingsEntry::Double;
}
//QgsSettingsEntry::SettingsType QgsSettingsEntryDouble::settingsType() const
//{
// return QgsSettingsEntry::Double;
//}
double QgsSettingsEntryDouble::minValue() const
{
return mMinValue;
}
//double QgsSettingsEntryDouble::minValue() const
//{
// return mMinValue;
//}
double QgsSettingsEntryDouble::maxValue() const
{
return mMaxValue;
}
//double QgsSettingsEntryDouble::maxValue() const
//{
// return mMaxValue;
//}
int QgsSettingsEntryDouble::displayHintDecimals() const
{
return mDisplayHintDecimals;
}
//int QgsSettingsEntryDouble::displayHintDecimals() const
//{
// return mDisplayHintDecimals;
//}
bool QgsSettingsEntryEnum::setValue( const QVariant &value, const QString &dynamicKeyPart )
{

View File

@ -23,9 +23,7 @@
#include "qgis_sip.h"
#include "qgssettings.h"
#define QGS_SETTING_ENTRY_VARIANT(name, path, section, defaultValue, ...) \
struct name : public QgsSettingsEntry\
{ name() : QgsSettingsEntry( path, section, defaultValue, ##__VA_ARGS__ ) {} };
#define QGS_SETTING_ENTRY_VARIANT(name, path, section, defaultValue, ...) struct name : public QgsSettingsEntry { name() : QgsSettingsEntry( path, section, defaultValue, ##__VA_ARGS__ ) {} };
/**
* \ingroup core
@ -48,10 +46,10 @@ class CORE_EXPORT QgsSettingsEntry
sipType = sipType_QgsSettingsEntryStringList;
else if ( dynamic_cast< QgsSettingsEntryBool * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryBool;
else if ( dynamic_cast< QgsSettingsEntryInteger * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryInteger;
else if ( dynamic_cast< QgsSettingsEntryDouble * >( sipCpp ) )
sipType = sipType_QgsSettingsEntryDouble;
// else if ( dynamic_cast< QgsSettingsEntryInteger * >( sipCpp ) )
// sipType = sipType_QgsSettingsEntryInteger;
// else if ( dynamic_cast< QgsSettingsEntryDouble * >( sipCpp ) )
// sipType = sipType_QgsSettingsEntryDouble;
else
sipType = NULL;
SIP_END
@ -185,9 +183,7 @@ class CORE_EXPORT QgsSettingsEntry
};
#define QGS_SETTING_ENTRY_STRING(name, path, section, defaultValue, ...) \
struct name : public QgsSettingsEntryString \
{ name() : QgsSettingsEntryString( path, section, defaultValue, ##__VA_ARGS__ ) {} };
#define QGS_SETTING_ENTRY_STRING(name, path, section, defaultValue, ...) struct name : public QgsSettingsEntryString { name() : QgsSettingsEntryString( path, section, defaultValue, ##__VA_ARGS__ ) {} };
/**
* \class QgsSettingsEntryString
@ -242,9 +238,7 @@ class CORE_EXPORT QgsSettingsEntryString : public QgsSettingsEntry
};
# define QGS_SETTING_ENTRY_STRINGLIST(name, path, section, defaultValue, ...) \
struct name : public QgsSettingsEntryStringList \
{ name() : QgsSettingsEntryStringList( path, section, defaultValue, ##__VA_ARGS__ ) {} };
#define QGS_SETTING_ENTRY_STRINGLIST(name, path, section, defaultValue, ...) struct name : public QgsSettingsEntryStringList { name() : QgsSettingsEntryStringList( path, section, defaultValue, ##__VA_ARGS__ ) {} };
/**
* \class QgsSettingsEntryStringList
@ -279,9 +273,7 @@ class CORE_EXPORT QgsSettingsEntryStringList : public QgsSettingsEntry
};
# define QGS_SETTING_ENTRY_BOOL(name, path, section, defaultValue, ...) \
struct name : public QgsSettingsEntryBool \
{ name() : QgsSettingsEntryBool( path, section, defaultValue, ##__VA_ARGS__ ) {} };
#define QGS_SETTING_ENTRY_BOOL(name, path, section, defaultValue, ...) struct name : public QgsSettingsEntryBool { name() : QgsSettingsEntryBool( path, section, defaultValue, ##__VA_ARGS__ ) {} };
/**
* \class QgsSettingsEntryBool
@ -316,131 +308,125 @@ class CORE_EXPORT QgsSettingsEntryBool : public QgsSettingsEntry
};
# define QGS_SETTING_ENTRY_INTEGER(name, path, section, defaultValue, ...) \
struct name : public QgsSettingsEntryInteger \
{ name() : QgsSettingsEntryInteger( path, section, defaultValue, ##__VA_ARGS__ ) {} };
//#define QGS_SETTING_ENTRY_INTEGER(name, path, section, defaultValue, ...) struct name : public QgsSettingsEntryInteger { name() : QgsSettingsEntryInteger( path, section, defaultValue, ##__VA_ARGS__ ) {} };
/**
* \class QgsSettingsEntryInteger
* \ingroup core
* An integer settings entry.
* \since QGIS 3.20
*/
class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntry
{
public:
///**
// * \class QgsSettingsEntryInteger
// * \ingroup core
// * An integer settings entry.
// * \since QGIS 3.20
// */
//class CORE_EXPORT QgsSettingsEntryInteger : public QgsSettingsEntry
//{
// public:
/**
* Constructor for QgsSettingsEntryInteger.
*
* The \a key argument specifies the final part of the settings key.
* The \a parentGroup argument specifies a parent group which is used to rebuild
* the entiere settings key and to determine the settings section.
* The \a default value argument specifies the default value for the settings entry.
* The \a description argument specifies a description for the settings entry.
* The \a minValue argument specifies the minimal value.
* The \a maxValue argument specifies the maximal value.
*/
QgsSettingsEntryInteger( const QString &key,
QgsSettings::Section section,
qlonglong defaultValue = 0,
const QString &description = QString(),
qlonglong minValue = std::numeric_limits<qlonglong>::min(),
qlonglong maxValue = std::numeric_limits<qlonglong>::max() );
// /**
// * Constructor for QgsSettingsEntryInteger.
// *
// * The \a key argument specifies the final part of the settings key.
// * The \a parentGroup argument specifies a parent group which is used to rebuild
// * the entiere settings key and to determine the settings section.
// * The \a default value argument specifies the default value for the settings entry.
// * The \a description argument specifies a description for the settings entry.
// * The \a minValue argument specifies the minimal value.
// * The \a maxValue argument specifies the maximal value.
// */
// QgsSettingsEntryInteger( const QString &key,
// QgsSettings::Section section,
// qlonglong defaultValue = 0,
// const QString &description = QString(),
// qlonglong minValue = std::numeric_limits<qlonglong>::min(),
// qlonglong maxValue = std::numeric_limits<qlonglong>::max() );
//! \copydoc QgsSettingsEntry::setValue
bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() ) override;
// //! \copydoc QgsSettingsEntry::setValue
// bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() ) override;
//! \copydoc QgsSettingsEntry::settingsType
virtual SettingsType settingsType() const override;
// //! \copydoc QgsSettingsEntry::settingsType
// virtual SettingsType settingsType() const override;
/**
* Returns the minimum value.
*/
qlonglong minValue();
// /**
// * Returns the minimum value.
// */
// qlonglong minValue();
/**
* Returns the maximum value.
*/
qlonglong maxValue();
// /**
// * Returns the maximum value.
// */
// qlonglong maxValue();
private:
// private:
qlonglong mMinValue;
qlonglong mMaxValue;
// qlonglong mMinValue;
// qlonglong mMaxValue;
};
//};
# define QGS_SETTING_ENTRY_DOUBLE(name, path, section, defaultValue, ...) \
struct name : public QgsSettingsEntryDouble \
{ name() : QgsSettingsEntryDouble( path, section, defaultValue, ##__VA_ARGS__ ) {} };
//#define QGS_SETTING_ENTRY_DOUBLE(name, path, section, defaultValue, ...) struct name : public QgsSettingsEntryDouble { name() : QgsSettingsEntryDouble( path, section, defaultValue, ##__VA_ARGS__ ) {} };
/**
* \class QgsSettingsEntryDouble
* \ingroup core
* A double settings entry.
* \since QGIS 3.20
*/
class CORE_EXPORT QgsSettingsEntryDouble : public QgsSettingsEntry
{
public:
///**
// * \class QgsSettingsEntryDouble
// * \ingroup core
// * A double settings entry.
// * \since QGIS 3.20
// */
//class CORE_EXPORT QgsSettingsEntryDouble : public QgsSettingsEntry
//{
// public:
/**
* Constructor for QgsSettingsEntryDouble.
*
* The \a key argument specifies the final part of the settings key.
* The \a parentGroup argument specifies a parent group which is used to rebuild
* the entiere settings key and to determine the settings section.
* The \a default value argument specifies the default value for the settings entry.
* The \a description argument specifies a description for the settings entry.
* The \a minValue argument specifies the minimal value.
* The \a maxValue argument specifies the maximal value.
*/
QgsSettingsEntryDouble( const QString &key,
QgsSettings::Section section,
double defaultValue = 0.0,
const QString &description = QString(),
double minValue = std::numeric_limits<double>::min(),
double maxValue = std::numeric_limits<double>::max(),
double displayDecimals = 1 );
// /**
// * Constructor for QgsSettingsEntryDouble.
// *
// * The \a key argument specifies the final part of the settings key.
// * The \a parentGroup argument specifies a parent group which is used to rebuild
// * the entiere settings key and to determine the settings section.
// * The \a default value argument specifies the default value for the settings entry.
// * The \a description argument specifies a description for the settings entry.
// * The \a minValue argument specifies the minimal value.
// * The \a maxValue argument specifies the maximal value.
// */
// QgsSettingsEntryDouble( const QString &key,
// QgsSettings::Section section,
// double defaultValue = 0.0,
// const QString &description = QString(),
// double minValue = std::numeric_limits<double>::min(),
// double maxValue = std::numeric_limits<double>::max(),
// double displayDecimals = 1 );
//! \copydoc QgsSettingsEntry::setValue
bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() ) override;
// //! \copydoc QgsSettingsEntry::setValue
// bool setValue( const QVariant &value, const QString &dynamicKeyPart = QString() ) override;
//! \copydoc QgsSettingsEntry::settingsType
virtual SettingsType settingsType() const override;
// //! \copydoc QgsSettingsEntry::settingsType
// virtual SettingsType settingsType() const override;
/**
* Returns the minimum value.
*/
double minValue() const;
// /**
// * Returns the minimum value.
// */
// double minValue() const;
/**
* Returns the maximum value.
*/
double maxValue() const;
// /**
// * Returns the maximum value.
// */
// double maxValue() const;
/**
* Returns how much decimals should be shown in the Gui.
*/
int displayHintDecimals() const;
// /**
// * Returns how much decimals should be shown in the Gui.
// */
// int displayHintDecimals() const;
private:
// private:
double mMinValue;
double mMaxValue;
// double mMinValue;
// double mMaxValue;
int mDisplayHintDecimals;
// int mDisplayHintDecimals;
};
//};
#ifndef SIP_RUN
# define QGS_SETTING_ENTRY_ENUM(name, path, section, defaultValue, ...) \
struct name : public QgsSettingsEntryEnum \
{ name() : QgsSettingsEntryEnum( path, section, defaultValue, ##__VA_ARGS__ ) {} };
#define QGS_SETTING_ENTRY_ENUM(name, path, section, defaultValue, ...) struct name : public QgsSettingsEntryEnum { name() : QgsSettingsEntryEnum( path, section, defaultValue, ##__VA_ARGS__ ) {} };
/**
* \class QgsSettingsEntryEnum

View File

@ -21,16 +21,17 @@
QgsSettingsRegistryCore::QgsSettingsRegistryCore()
: mSettingsEntries()
{
mSettingsEntries.append( new QgsLayout::Settings::SearchPathForTemplates() );
mSettingsEntries.append( &QgsLayout::Settings::searchPathForTemplates );
// mSettingsEntries.append( new QgsLayout::Settings::SearchPathForTemplates() );
mSettingsEntries.append( new QgsLocator::Settings::LocatorFilterEnabled() );
mSettingsEntries.append( new QgsLocator::Settings::LocatorFilterDefault() );
mSettingsEntries.append( new QgsLocator::Settings::LocatorFilterPrefix() );
// mSettingsEntries.append( &QgsLocator::Settings::locatorFilterEnabled );
// mSettingsEntries.append( &QgsLocator::Settings::locatorFilterDefault );
// mSettingsEntries.append( &QgsLocator::Settings::locatorFilterPrefix );
}
QgsSettingsRegistryCore::~QgsSettingsRegistryCore()
{
qDeleteAll( mSettingsEntries );
// qDeleteAll( mSettingsEntries );
}