QGIS API Documentation  3.24.2-Tisler (13c1a02865)
qgsdefaultvalue.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdefaultvalue.h
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 #ifndef QGSDEFAULTVALUE_H
17 #define QGSDEFAULTVALUE_H
18 
19 #include "qgis_core.h"
20 #include "qgis_sip.h"
21 
22 #include <QString>
23 #include <QObject>
24 
25 
48 class CORE_EXPORT QgsDefaultValue
49 {
50  Q_GADGET SIP_SKIP
51 
52  Q_PROPERTY( QString expression READ expression WRITE setExpression )
53  Q_PROPERTY( bool applyOnUpdate READ applyOnUpdate WRITE setApplyOnUpdate )
54 
55  public:
56 
61  explicit QgsDefaultValue( const QString &expression = QString(), bool applyOnUpdate = false );
62 
63  // TODO c++20 - replace with = default
64  bool operator==( const QgsDefaultValue &other ) const;
65 
66 #ifdef SIP_RUN
67  SIP_PYOBJECT __repr__();
68  % MethodCode
69  const QString str = sipCpp->isValid() ? QStringLiteral( "<QgsDefaultValue: %1>" ).arg(
70  sipCpp->expression().length() > 1000 ? sipCpp->expression().left( 1000 ) + QStringLiteral( "..." )
71  : sipCpp->expression() )
72  : QStringLiteral( "<QgsDefaultValue: invalid>" );
73  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
74  % End
75 #endif
76 
81  QString expression() const;
82 
87  void setExpression( const QString &expression );
88 
93  bool applyOnUpdate() const;
94 
99  void setApplyOnUpdate( bool applyOnUpdate );
100 
105  bool isValid() const;
106 
111  operator bool() const SIP_PYTHON_SPECIAL_BOOL( isValid );
112 
113  private:
114  QString mExpression;
115  bool mApplyOnUpdate = false;
116 };
117 
119 
120 #endif // QGSDEFAULTVALUE_H
The QgsDefaultValue class provides a container for managing client side default values for fields.
#define str(x)
Definition: qgis.cpp:37
#define SIP_PYTHON_SPECIAL_BOOL(method_or_code)
Definition: qgis_sip.h:244
#define SIP_SKIP
Definition: qgis_sip.h:126
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Q_DECLARE_METATYPE(QgsMeshTimeSettings)