File: qgsdefaultvalue.sip.in

package info (click to toggle)
qgis 3.40.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,183,800 kB
  • sloc: cpp: 1,595,841; python: 372,637; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 154
file content (100 lines) | stat: -rw-r--r-- 3,541 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgsdefaultvalue.h                                           *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/




class QgsDefaultValue
{
%Docstring(signature="appended")
The :py:class:`QgsDefaultValue` class provides a container for managing
client side default values for fields.

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.

Usual values for such an expression are

- :py:func:`~now` for a timestamp for a record
- `@some_variable` to insert a project or application level variable
  like the username of the one digitizing a feature
- `$length` to insert a derived attribute of a geometry

:py:class:`QgsDefaultValue` also has a `applyOnUpdate` flag which will
indicate that a 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.
%End

%TypeHeaderCode
#include "qgsdefaultvalue.h"
%End
  public:

    explicit QgsDefaultValue( const QString &expression = QString(), bool applyOnUpdate = false );
%Docstring
Create a new default value with the given ``expression`` and
``applyOnUpdate`` flag.

.. seealso:: :py:func:`QgsVectorLayer.setDefaultValueDefinition`
%End

    bool operator==( const QgsDefaultValue &other ) const;

    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

    QString expression() const;
%Docstring
The expression will be evaluated whenever a default value needs to be
calculated for a field.
%End

    void setExpression( const QString &expression );
%Docstring
The expression will be evaluated whenever a default value needs to be
calculated for a field.
%End

    bool applyOnUpdate() const;
%Docstring
The applyOnUpdate flag determines if this expression should also be
applied when a feature is updated or only when it's created.
%End

    void setApplyOnUpdate( bool applyOnUpdate );
%Docstring
The applyOnUpdate flag determines if this expression should also be
applied when a feature is updated or only when it's created.
%End

    bool isValid() const;
%Docstring
Returns if this default value should be applied.

:return: ``False`` if the expression is a null string.
%End


};


/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgsdefaultvalue.h                                           *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/