QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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
QgsDefaultValue
The QgsDefaultValue class provides a container for managing client side default values for fields.
Definition: qgsdefaultvalue.h:48
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
SIP_PYTHON_SPECIAL_BOOL
#define SIP_PYTHON_SPECIAL_BOOL(method_or_code)
Definition: qgis_sip.h:253
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgis_sip.h
str
#define str(x)
Definition: qgis.cpp:37
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)