mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			91 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/************************************************************************
 | 
						|
 * 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
 | 
						|
{
 | 
						|
%Docstring
 | 
						|
 | 
						|
The QgsDefaultValue class provides a container for managing client
 | 
						|
side default values for fields.
 | 
						|
 | 
						|
A 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
 | 
						|
 | 
						|
- `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
 | 
						|
 | 
						|
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.
 | 
						|
 | 
						|
.. versionadded:: 3.0
 | 
						|
%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;
 | 
						|
 | 
						|
    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.pl again   *
 | 
						|
 ************************************************************************/
 |