Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix dox
  • Loading branch information
3nids committed Apr 27, 2023
1 parent de1363d commit 7498d09
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 32 deletions.
6 changes: 2 additions & 4 deletions python/core/auto_generated/settings/qgssettingsentry.sip.in
Expand Up @@ -347,13 +347,11 @@ class QgsSettingsEntryBaseTemplate : QgsSettingsEntryBase
{
%Docstring(signature="appended")

Base abstract class for settings entry which are passed by reference
Base abstract class for settings entries with typed get and set methods

.. seealso:: :py:class:`QgsSettingsEntryBase`

.. seealso:: :py:class:`QgsSettingsEntryByValue`

.. versionadded:: 3.26
.. versionadded:: 3.32
%End

%TypeHeaderCode
Expand Down
Expand Up @@ -85,8 +85,14 @@ The wrapper must be configured before calling this medthod

protected:
virtual QWidget *createEditorPrivate( QWidget *parent = 0 ) const = 0;
%Docstring
Creates the widgets
%End

virtual bool configureEditorPrivate( QWidget *editor, const QgsSettingsEntryBase *setting ) = 0;
%Docstring
Configures an existing widget
%End

};

Expand Down
Expand Up @@ -27,6 +27,9 @@ This class is a base factory of editor for settings
%End
public:
QgsSettingsEditorWidgetWrapperTemplate( QObject *parent = 0 );
%Docstring
Constructor
%End
virtual QString id() const = 0;

virtual bool setWidgetFromSetting() const;
Expand All @@ -36,10 +39,16 @@ This class is a base factory of editor for settings
virtual void setWidgetFromVariant( const QVariant &value ) const;

virtual bool setWidgetValue( const U &value ) const = 0;
%Docstring
Sets the widget value
%End

virtual QVariant variantValueFromWidget() const;

virtual U valueFromWidget() const = 0;
%Docstring
Returns the widget value
%End

V *editor() const;
%Docstring
Expand Down Expand Up @@ -83,6 +92,9 @@ typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString,QLineEdit,
%End
public:
QgsSettingsStringEditorWidgetWrapper( QObject *parent = 0 );
%Docstring
Constructor
%End

virtual QgsSettingsEditorWidgetWrapper *createWrapper( QObject *parent = 0 ) const;

Expand Down Expand Up @@ -116,6 +128,9 @@ typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryBool,QCheckBox,bo
%End
public:
QgsSettingsBoolEditorWidgetWrapper( QObject *parent = 0 );
%Docstring
Constructor
%End

virtual QgsSettingsEditorWidgetWrapper *createWrapper( QObject *parent = 0 ) const;

Expand Down Expand Up @@ -149,6 +164,9 @@ typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryInteger,QSpinBox,
%End
public:
QgsSettingsIntegerEditorWidgetWrapper( QObject *parent = 0 );
%Docstring
Constructor
%End

virtual QgsSettingsEditorWidgetWrapper *createWrapper( QObject *parent = 0 ) const;

Expand Down Expand Up @@ -183,6 +201,9 @@ typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryDouble,QDoubleSpi
%End
public:
QgsSettingsDoubleEditorWidgetWrapper( QObject *parent = 0 );
%Docstring
Constructor
%End

virtual QgsSettingsEditorWidgetWrapper *createWrapper( QObject *parent = 0 ) const;

Expand Down Expand Up @@ -217,6 +238,9 @@ typedef QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryColor,QgsColorBut
%End
public:
QgsSettingsColorEditorWidgetWrapper( QObject *parent = 0 );
%Docstring
Constructor
%End

virtual QgsSettingsEditorWidgetWrapper *createWrapper( QObject *parent = 0 ) const;

Expand Down
Expand Up @@ -41,6 +41,9 @@ Constructor
~QgsSettingsTreeModel();

void applyChanges();
%Docstring
Apply pending changes in the model to the corresponding settings
%End



Expand Down
Expand Up @@ -30,6 +30,9 @@ Constructor


void applyChanges() const;
%Docstring
Apply changes to settings value
%End

};

Expand Down
4 changes: 2 additions & 2 deletions src/app/options/qgsadvancedoptions.cpp
Expand Up @@ -57,8 +57,8 @@ QgsAdvancedSettingsWidget::~QgsAdvancedSettingsWidget()

void QgsAdvancedSettingsWidget::apply()
{
// mAdvancedSettingsEditor applies changes immediately
// new settings tree is performing changes on appy
// the old settings editor applies changes immediately
// new settings tree is performing changes on apply
if ( mTreeWidget )
mTreeWidget->applyChanges();

Expand Down
7 changes: 3 additions & 4 deletions src/core/settings/qgssettingsentry.h
Expand Up @@ -353,13 +353,12 @@ class CORE_EXPORT QgsSettingsEntryBase

/**
* \ingroup core
* \class QgsSettingsEntryByReference
* \class QgsSettingsEntryBaseTemplate
*
* \brief Base abstract class for settings entry which are passed by reference
* \brief Base abstract class for settings entries with typed get and set methods
* \see QgsSettingsEntryBase
* \see QgsSettingsEntryByValue
*
* \since QGIS 3.26
* \since QGIS 3.32
*/
template<class T>
class QgsSettingsEntryBaseTemplate : public QgsSettingsEntryBase
Expand Down
6 changes: 1 addition & 5 deletions src/gui/settings/qgssettingseditorwidgetregistry.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
qgssettingsfactoryfactoryregistry.cpp
qgssettingseditorwidgetregistry.cpp
---------------------
begin : April 2023
copyright : (C) 2023 by Denis Rouzaud
Expand Down Expand Up @@ -66,7 +66,3 @@ QWidget *QgsSettingsEditorWidgetRegistry::createEditor( const QgsSettingsEntryBa
else
return nullptr;
}




10 changes: 5 additions & 5 deletions src/gui/settings/qgssettingseditorwidgetregistry.h
Expand Up @@ -28,7 +28,7 @@ class QgsSettingsEditorWidgetWrapper;

/**
* \ingroup gui
* \brief This class manages editors for settings
* \brief This class manages editor widgets for settings
*
* \since QGIS 3.32
*/
Expand All @@ -40,15 +40,15 @@ class GUI_EXPORT QgsSettingsEditorWidgetRegistry
~QgsSettingsEditorWidgetRegistry();

/**
* Adds a editor to the registry
* Returns FALSE if a editor with same id already exists.
* Adds an editor widget \a wrapper to the registry
* Returns FALSE if an editor widget with same id already exists.
*/
bool addWrapper( QgsSettingsEditorWidgetWrapper *wrapper SIP_TRANSFER );

//! Returns a new instance of the editor for the given id
//! Returns a new instance of the editor widget for the given \a id
QgsSettingsEditorWidgetWrapper *createWrapper( const QString &id, QObject *parent ) const;

//! Creates the editor for the given settings using the corresponding registered wrapper
//! Creates an editor widget for the given \a setting using the corresponding registered wrapper
QWidget *createEditor( const QgsSettingsEntryBase *setting, const QStringList &dynamicKeyPartList, QWidget *parent = nullptr ) const SIP_FACTORY;

//! Returns a map <name, id> of all registered editors.
Expand Down
2 changes: 1 addition & 1 deletion src/gui/settings/qgssettingseditorwidgetwrapper.cpp
Expand Up @@ -44,7 +44,7 @@ QWidget *QgsSettingsEditorWidgetWrapper::createEditor( const QgsSettingsEntryBas
if ( configureEditor( editor, setting, dynamicKeyPartList ) )
return editor;
else
QgsDebugMsg( QStringLiteral( "editor could not be confiugured" ) );
QgsDebugMsg( QStringLiteral( "editor could not be configured" ) );
return nullptr;
}

Expand Down
10 changes: 6 additions & 4 deletions src/gui/settings/qgssettingseditorwidgetwrapper.h
Expand Up @@ -33,7 +33,7 @@ class GUI_EXPORT QgsSettingsEditorWidgetWrapper : public QObject
{
Q_OBJECT
public:
//! Creates a wrapper from the definition stored in a widget created by createEditor()
//! Creates a wrapper from the definition stored in a \a widget created by createEditor()
static QgsSettingsEditorWidgetWrapper *fromWidget( const QWidget *widget ) SIP_FACTORY;

//! Constructor
Expand All @@ -50,7 +50,7 @@ class GUI_EXPORT QgsSettingsEditorWidgetWrapper : public QObject
//! Creates a new instance of the editor wrapper so it can be configured for a widget and a setting
virtual QgsSettingsEditorWidgetWrapper *createWrapper( QObject *parent = nullptr ) const = 0;

//! Creates the editor for the given widget
//! Creates the editor widget for the given \a setting
QWidget *createEditor( const QgsSettingsEntryBase *setting, const QStringList &dynamicKeyPartList = QStringList(), QWidget *parent = nullptr );

//! Configures the \a editor according the setting
Expand All @@ -63,7 +63,7 @@ class GUI_EXPORT QgsSettingsEditorWidgetWrapper : public QObject
virtual bool setWidgetFromSetting() const = 0;

/**
* SDets the setting value from the widget value
* Sets the setting value from the widget value
* The wrapper must be configured before calling this medthod
*/
virtual bool setSettingFromWidget() const = 0;
Expand All @@ -75,15 +75,17 @@ class GUI_EXPORT QgsSettingsEditorWidgetWrapper : public QObject
virtual QVariant variantValueFromWidget() const = 0;

/**
* Sets the value of the widget
* Sets the \a value of the widget
* The wrapper must be configured before calling this medthod
*/
virtual void setWidgetFromVariant( const QVariant &value ) const = 0;


protected:
//! Creates the widgets
virtual QWidget *createEditorPrivate( QWidget *parent = nullptr ) const = 0;

//! Configures an existing \a editor widget
virtual bool configureEditorPrivate( QWidget *editor, const QgsSettingsEntryBase *setting ) = 0;

QStringList mDynamicKeyPartList;
Expand Down
8 changes: 8 additions & 0 deletions src/gui/settings/qgssettingseditorwidgetwrapperimpl.h
Expand Up @@ -45,6 +45,7 @@ template<class T, class V, class U>
class GUI_EXPORT QgsSettingsEditorWidgetWrapperTemplate : public QgsSettingsEditorWidgetWrapper
{
public:
//! Constructor
QgsSettingsEditorWidgetWrapperTemplate( QObject *parent = nullptr )
: QgsSettingsEditorWidgetWrapper( parent ) {}

Expand All @@ -66,13 +67,15 @@ class GUI_EXPORT QgsSettingsEditorWidgetWrapperTemplate : public QgsSettingsEdit
setWidgetValue( mSetting->convertFromVariant( value ) );
}

//! Sets the widget value
virtual bool setWidgetValue( const U &value ) const = 0;

QVariant variantValueFromWidget() const override
{
return valueFromWidget();
};

//! Returns the widget value
virtual U valueFromWidget() const = 0;

//! Returns the editor
Expand Down Expand Up @@ -120,6 +123,7 @@ class GUI_EXPORT QgsSettingsEditorWidgetWrapperTemplate : public QgsSettingsEdit
class GUI_EXPORT QgsSettingsStringEditorWidgetWrapper : public QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString, QLineEdit, QString>
{
public:
//! Constructor
QgsSettingsStringEditorWidgetWrapper( QObject *parent = nullptr )
: QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryString, QLineEdit, QString>( parent ) {}

Expand All @@ -143,6 +147,7 @@ class GUI_EXPORT QgsSettingsStringEditorWidgetWrapper : public QgsSettingsEditor
class GUI_EXPORT QgsSettingsBoolEditorWidgetWrapper : public QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryBool, QCheckBox, bool>
{
public:
//! Constructor
QgsSettingsBoolEditorWidgetWrapper( QObject *parent = nullptr )
: QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryBool, QCheckBox, bool>( parent ) {}

Expand All @@ -166,6 +171,7 @@ class GUI_EXPORT QgsSettingsBoolEditorWidgetWrapper : public QgsSettingsEditorWi
class GUI_EXPORT QgsSettingsIntegerEditorWidgetWrapper : public QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryInteger, QSpinBox, int>
{
public:
//! Constructor
QgsSettingsIntegerEditorWidgetWrapper( QObject *parent = nullptr )
: QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryInteger, QSpinBox, int>( parent ) {}

Expand All @@ -190,6 +196,7 @@ class GUI_EXPORT QgsSettingsIntegerEditorWidgetWrapper : public QgsSettingsEdito
class GUI_EXPORT QgsSettingsDoubleEditorWidgetWrapper : public QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryDouble, QDoubleSpinBox, double>
{
public:
//! Constructor
QgsSettingsDoubleEditorWidgetWrapper( QObject *parent = nullptr )
: QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryDouble, QDoubleSpinBox, double>( parent ) {}

Expand All @@ -214,6 +221,7 @@ class GUI_EXPORT QgsSettingsDoubleEditorWidgetWrapper : public QgsSettingsEditor
class GUI_EXPORT QgsSettingsColorEditorWidgetWrapper : public QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryColor, QgsColorButton, QColor>
{
public:
//! Constructor
QgsSettingsColorEditorWidgetWrapper( QObject *parent = nullptr )
: QgsSettingsEditorWidgetWrapperTemplate<QgsSettingsEntryColor, QgsColorButton, QColor>( parent ) {}

Expand Down
13 changes: 7 additions & 6 deletions src/gui/settings/qgssettingstreemodel.h
Expand Up @@ -63,10 +63,10 @@ class GUI_EXPORT QgsSettingsTreeModelNodeData : public QObject
void applyChanges();

//! Returns if the node is the root node
bool isRoot() const {return mParent == nullptr;}
bool isRoot() const { return mParent == nullptr; }

//! Returns the dynamic key parts of the named list parent tree nodes
QStringList namedParentNodes() const {return mNamedParentNodes;}
QStringList namedParentNodes() const { return mNamedParentNodes; }

//! Returns the children nodes of the node (setting or tree node)
QList<QgsSettingsTreeModelNodeData *> children() const {return mChildren;}
Expand All @@ -86,7 +86,7 @@ class GUI_EXPORT QgsSettingsTreeModelNodeData : public QObject
//! Returns the value of the node (setting or tree node)
QVariant originalValue() const {return mOriginalValue;}

//! Sets the value of the setting node
//! Sets the \a value of the setting node
bool setValue( const QVariant &value );

//! Returns if the setting exists (value is set)
Expand All @@ -96,8 +96,8 @@ class GUI_EXPORT QgsSettingsTreeModelNodeData : public QObject
bool isEdited() const {return mIsEdited;}

/**
* Returns the setting of the node
* It returns a nullptr if the setting does not exist
* Returns a pointer to the setting of the node or NULLPTR if the
* setting does not exist.
*/
const QgsSettingsEntryBase *setting() const {return mSetting;}

Expand Down Expand Up @@ -179,10 +179,11 @@ class GUI_EXPORT QgsSettingsTreeModel : public QAbstractItemModel

~QgsSettingsTreeModel();

//! Apply pending changes in the model to the corresponding settings
void applyChanges();

/**
* Returns settings tree node for given index. Returns root node for invalid index.
* Returns settings tree node for given \a index or the root node if the index is invalid.
*/
QgsSettingsTreeModelNodeData *index2node( const QModelIndex &index ) const SIP_SKIP;

Expand Down
2 changes: 1 addition & 1 deletion src/gui/settings/qgssettingstreewidget.h
Expand Up @@ -39,7 +39,7 @@ class GUI_EXPORT QgsSettingsTreeWidget : public QWidget
explicit QgsSettingsTreeWidget( QWidget *parent = nullptr );


// Apply changes to settings value
//! Apply changes to settings value
void applyChanges() const;

private:
Expand Down

0 comments on commit 7498d09

Please sign in to comment.