QGIS API Documentation  3.6.0-Noosa (5873452)
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
7  email : [email protected]
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 
18 QgsDefaultValue::QgsDefaultValue( const QString &expression, bool applyOnUpdate )
19  : mExpression( expression )
20  , mApplyOnUpdate( applyOnUpdate )
21 {
22 
23 }
24 
25 bool QgsDefaultValue::operator==( const QgsDefaultValue &other ) const
26 {
27  return mExpression == other.mExpression
28  && mApplyOnUpdate == other.mApplyOnUpdate;
29 }
30 
31 QString QgsDefaultValue::expression() const
32 {
33  return mExpression;
34 }
35 
37 {
38  mExpression = expression;
39 }
40 
42 {
43  return mApplyOnUpdate;
44 }
45 
47 {
48  mApplyOnUpdate = applyOnUpdate;
49 }
50 
52 {
53  return !mExpression.isEmpty();
54 }
55 
56 QgsDefaultValue::operator bool() const
57 {
58  return !mExpression.isEmpty();
59 }
void setExpression(const QString &expression)
The expression will be evaluated whenever a default value needs to be calculated for a field...
bool isValid() const
Returns if this default value should be applied.
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.
bool operator==(const QgsDefaultValue &other) const
QString expression() const
The expression will be evaluated whenever a default value needs to be calculated for a field...
bool applyOnUpdate() const
The applyOnUpdate flag determines if this expression should also be applied when a feature is updated...
void setApplyOnUpdate(bool applyOnUpdate)
The applyOnUpdate flag determines if this expression should also be applied when a feature is updated...