QGIS API Documentation 3.43.0-Master (b60ef06885e)
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 : matthias@opengis.ch
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
46class CORE_EXPORT QgsDefaultValue
47{
48 Q_GADGET SIP_SKIP
49
50 Q_PROPERTY( QString expression READ expression WRITE setExpression )
51 Q_PROPERTY( bool applyOnUpdate READ applyOnUpdate WRITE setApplyOnUpdate )
52
53 public:
54
59 explicit QgsDefaultValue( const QString &expression = QString(), bool applyOnUpdate = false );
60
61 // TODO c++20 - replace with = default
62 bool operator==( const QgsDefaultValue &other ) const;
63
64#ifdef SIP_RUN
65 SIP_PYOBJECT __repr__();
66 % MethodCode
67 const QString str = sipCpp->isValid() ? QStringLiteral( "<QgsDefaultValue: %1>" ).arg(
68 sipCpp->expression().length() > 1000 ? sipCpp->expression().left( 1000 ) + QStringLiteral( "..." )
69 : sipCpp->expression() )
70 : QStringLiteral( "<QgsDefaultValue: invalid>" );
71 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
72 % End
73#endif
74
79 QString expression() const;
80
85 void setExpression( const QString &expression );
86
91 bool applyOnUpdate() const;
92
97 void setApplyOnUpdate( bool applyOnUpdate );
98
103 bool isValid() const;
104
109 explicit operator bool() const SIP_PYTHON_SPECIAL_BOOL( isValid );
110
111 private:
112 QString mExpression;
113 bool mApplyOnUpdate = false;
114};
115
117
118#endif // QGSDEFAULTVALUE_H
Provides a container for managing client side default values for fields.
#define SIP_PYTHON_SPECIAL_BOOL(method_or_code)
Definition qgis_sip.h:258
#define SIP_SKIP
Definition qgis_sip.h:126
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)