QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsdefaultvalue.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsdefaultvalue.cpp
3
4 ---------------------
5 begin : 19.9.2017
6 copyright : (C) 2017 by Matthias Kuhn
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#include "qgsdefaultvalue.h"
17#include "moc_qgsdefaultvalue.cpp"
18
19QgsDefaultValue::QgsDefaultValue( const QString &expression, bool applyOnUpdate )
20 : mExpression( expression )
21 , mApplyOnUpdate( applyOnUpdate )
22{
23
24}
25
27{
28 return mExpression == other.mExpression
29 && mApplyOnUpdate == other.mApplyOnUpdate;
30}
31
33{
34 return mExpression;
35}
36
37void QgsDefaultValue::setExpression( const QString &expression )
38{
39 mExpression = expression;
40}
41
43{
44 return mApplyOnUpdate;
45}
46
47void QgsDefaultValue::setApplyOnUpdate( bool applyOnUpdate )
48{
49 mApplyOnUpdate = applyOnUpdate;
50}
51
53{
54 return !mExpression.isEmpty();
55}
56
57QgsDefaultValue::operator bool() const
58{
59 return !mExpression.isEmpty();
60}
The QgsDefaultValue class provides a container for managing client side default values for fields.
QgsDefaultValue(const QString &expression=QString(), bool applyOnUpdate=false)
Create a new default value with the given expression and applyOnUpdate flag.
void setApplyOnUpdate(bool applyOnUpdate)
The applyOnUpdate flag determines if this expression should also be applied when a feature is updated...
bool isValid() const
Returns if this default value should be applied.
bool operator==(const QgsDefaultValue &other) const
void setExpression(const QString &expression)
The expression will be evaluated whenever a default value needs to be calculated for a field.