QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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
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
47class CORE_EXPORT QgsDefaultValue
48{
49 Q_GADGET SIP_SKIP
50
51 Q_PROPERTY( QString expression READ expression WRITE setExpression )
52 Q_PROPERTY( bool applyOnUpdate READ applyOnUpdate WRITE setApplyOnUpdate )
53
54 public:
55
60 explicit QgsDefaultValue( const QString &expression = QString(), bool applyOnUpdate = false );
61
62 // TODO c++20 - replace with = default
63 bool operator==( const QgsDefaultValue &other ) const;
64
65#ifdef SIP_RUN
66 SIP_PYOBJECT __repr__();
67 % MethodCode
68 const QString str = sipCpp->isValid() ? QStringLiteral( "<QgsDefaultValue: %1>" ).arg(
69 sipCpp->expression().length() > 1000 ? sipCpp->expression().left( 1000 ) + QStringLiteral( "..." )
70 : sipCpp->expression() )
71 : QStringLiteral( "<QgsDefaultValue: invalid>" );
72 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
73 % End
74#endif
75
80 QString expression() const;
81
86 void setExpression( const QString &expression );
87
92 bool applyOnUpdate() const;
93
98 void setApplyOnUpdate( bool applyOnUpdate );
99
104 bool isValid() const;
105
110 explicit operator bool() const SIP_PYTHON_SPECIAL_BOOL( isValid );
111
112 private:
113 QString mExpression;
114 bool mApplyOnUpdate = false;
115};
116
118
119#endif // QGSDEFAULTVALUE_H
The QgsDefaultValue class 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)