QGIS/python/core/auto_generated/qgsdefaultvalue.sip.in

101 lines
3.5 KiB
Plaintext
Raw Normal View History

2017-09-19 17:36:19 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsdefaultvalue.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsDefaultValue
{
2021-03-22 21:13:52 +01:00
%Docstring(signature="appended")
2017-09-19 17:36:19 +02:00
The :py:class:`QgsDefaultValue` class provides a container for managing client
2017-12-15 10:36:55 -04:00
side default values for fields.
2017-09-19 17:36:19 +02:00
A :py:class:`QgsDefaultValue` consists of an expression string that will be evaluated
on the client when a default field value needs to be generated.
2017-09-19 17:36:19 +02:00
2017-12-15 10:36:55 -04:00
Usual values for such an expression are
2017-09-19 17:36:19 +02:00
- :py:func:`~now` for a timestamp for a record
2017-12-15 10:36:55 -04:00
- `@some_variable` to insert a project or application level variable like
2020-06-11 10:52:50 +10:00
the username of the one digitizing a feature
2017-12-15 10:36:55 -04:00
- `$length` to insert a derived attribute of a geometry
2017-09-19 17:36:19 +02:00
:py:class:`QgsDefaultValue` also has a `applyOnUpdate` flag which will indicate that a
2017-12-15 10:36:55 -04:00
default value should also be applied when a feature is updated. If this is
not set, the default value will only be used when a feature is created.
2017-09-19 17:36:19 +02:00
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgsdefaultvalue.h"
%End
public:
explicit QgsDefaultValue( const QString &expression = QString(), bool applyOnUpdate = false );
2017-09-19 17:36:19 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Create a new default value with the given ``expression`` and ``applyOnUpdate`` flag.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`QgsVectorLayer.setDefaultValueDefinition`
2017-09-19 17:36:19 +02:00
%End
2017-09-19 17:36:19 +02:00
bool operator==( const QgsDefaultValue &other ) const;
2021-08-11 14:31:04 +10:00
SIP_PYOBJECT __repr__();
%MethodCode
const QString str = sipCpp->isValid() ? QStringLiteral( "<QgsDefaultValue: %1>" ).arg(
sipCpp->expression().length() > 1000 ? sipCpp->expression().left( 1000 ) + QStringLiteral( "..." )
: sipCpp->expression() )
: QStringLiteral( "<QgsDefaultValue: invalid>" );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End
2017-09-19 17:36:19 +02:00
QString expression() const;
%Docstring
2017-12-15 10:36:55 -04:00
The expression will be evaluated whenever a default value needs
to be calculated for a field.
2017-09-19 17:36:19 +02:00
%End
void setExpression( const QString &expression );
%Docstring
2017-12-15 10:36:55 -04:00
The expression will be evaluated whenever a default value needs
to be calculated for a field.
2017-09-19 17:36:19 +02:00
%End
bool applyOnUpdate() const;
%Docstring
2017-12-15 10:36:55 -04:00
The applyOnUpdate flag determines if this expression should also be
applied when a feature is updated or only when it's created.
2017-09-19 17:36:19 +02:00
%End
void setApplyOnUpdate( bool applyOnUpdate );
%Docstring
2017-12-15 10:36:55 -04:00
The applyOnUpdate flag determines if this expression should also be
applied when a feature is updated or only when it's created.
2017-09-19 17:36:19 +02:00
%End
bool isValid() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns if this default value should be applied.
2019-02-26 19:54:09 +10:00
:return: ``False`` if the expression is a null string.
%End
2017-09-26 13:35:05 +02:00
2017-09-19 17:36:19 +02:00
};
2017-09-19 17:36:19 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsdefaultvalue.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/