QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
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 <QObject>
23
#include <QString>
24
25
using namespace
Qt::StringLiterals;
26
47
class
CORE_EXPORT
QgsDefaultValue
48
{
49
// clang-format off
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
// clang-format on
57
62
explicit
QgsDefaultValue
( const QString &
expression
= QString(),
bool
applyOnUpdate
= false );
63
64
// TODO c++20 - replace with = default
65
bool
operator==( const
QgsDefaultValue
&other ) const;
66
67
#ifdef SIP_RUN
68
// clang-format off
69
SIP_PYOBJECT __repr__();
70
% MethodCode
71
const
QString str = sipCpp->isValid() ? u
"<QgsDefaultValue: %1>"
_s.arg(
72
sipCpp->expression().length() > 1000 ? sipCpp->expression().left( 1000 ) + u
"..."
_s
73
: sipCpp->expression() )
74
: u
"<QgsDefaultValue: invalid>"
_s;
75
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
76
% End
77
// clang-format on
78
#endif
79
84
QString
expression
()
const
;
85
90
void
setExpression
(
const
QString &
expression
);
91
96
bool
applyOnUpdate
()
const
;
97
102
void
setApplyOnUpdate
(
bool
applyOnUpdate
);
103
108
bool
isValid
()
const
;
109
114
explicit
operator
bool() const
SIP_PYTHON_SPECIAL_BOOL
(
isValid
);
115
116
private:
117
QString mExpression;
118
bool
mApplyOnUpdate = false;
119
};
120
121
Q_DECLARE_METATYPE
(
QgsDefaultValue
)
122
123
#endif
// QGSDEFAULTVALUE_H
QgsDefaultValue::QgsDefaultValue
QgsDefaultValue(const QString &expression=QString(), bool applyOnUpdate=false)
Create a new default value with the given expression and applyOnUpdate flag.
Definition
qgsdefaultvalue.cpp:20
QgsDefaultValue::expression
QString expression
Definition
qgsdefaultvalue.h:52
QgsDefaultValue::setApplyOnUpdate
void setApplyOnUpdate(bool applyOnUpdate)
The applyOnUpdate flag determines if this expression should also be applied when a feature is updated...
Definition
qgsdefaultvalue.cpp:45
QgsDefaultValue::isValid
bool isValid() const
Returns if this default value should be applied.
Definition
qgsdefaultvalue.cpp:50
QgsDefaultValue::applyOnUpdate
bool applyOnUpdate
Definition
qgsdefaultvalue.h:53
QgsDefaultValue::setExpression
void setExpression(const QString &expression)
The expression will be evaluated whenever a default value needs to be calculated for a field.
Definition
qgsdefaultvalue.cpp:35
qgis_sip.h
SIP_PYTHON_SPECIAL_BOOL
#define SIP_PYTHON_SPECIAL_BOOL(method_or_code)
Definition
qgis_sip.h:257
SIP_SKIP
#define SIP_SKIP
Definition
qgis_sip.h:138
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
Generated on
for QGIS API Documentation by
1.17.0