QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsstoredexpressionmanager.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsstoredexpressionmanager.h
3 -------------------
4 begin : August 2019
5 copyright : (C) 2019 David Signer
6 email : david at opengis dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSSTOREDEXPRESSIONMANAGER_H
19#define QGSSTOREDEXPRESSIONMANAGER_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23
24#include <QObject>
25#include <QString>
26#include <QUuid>
27
28#ifdef SIP_RUN
29% ModuleHeaderCode
31% End
32#endif
33
34class QDomNode;
35class QDomDocument;
36
42class CORE_EXPORT QgsStoredExpression
43{
44 public:
45
57
58#ifndef SIP_RUN
59
61
70 : id( QUuid::createUuid().toString() )
71 , name( name )
73 , tag( tag )
74 {}
75#endif
76
78 QString id;
80 QString name;
82 QString expression;
85};
86
92class CORE_EXPORT QgsStoredExpressionManager : public QObject
93{
94 Q_OBJECT
95
96 public:
97
99
108 QString addStoredExpression( const QString &name, const QString &expression, const QgsStoredExpression::Category &tag = QgsStoredExpression::Category::FilterExpression );
109
115 void removeStoredExpression( const QString &id );
116
125 void updateStoredExpression( const QString &id, const QString &name, const QString &expression, const QgsStoredExpression::Category &tag );
126
132 void addStoredExpressions( const QList< QgsStoredExpression > &storedExpressions );
133
140
141
147 QgsStoredExpression storedExpression( const QString &id ) const;
148
156
159
161 bool writeXml( QDomNode &layerNode ) const;
162
164 bool readXml( const QDomNode &layerNode );
165
166 signals:
167
168 public slots:
169
170 private:
171 QList< QgsStoredExpression > mStoredExpressions;
172};
173
174#endif // QGSSTOREDEXPRESSIONMANAGER_H
void removeStoredExpression(const QString &id)
Removes an expression to the list.
QgsStoredExpression storedExpression(const QString &id) const
Returns an expression according to the id.
bool writeXml(QDomNode &layerNode) const
Writes the stored expressions out in XML format.
void clearStoredExpressions()
Clears list of stored expressions.
QgsStoredExpression findStoredExpressionByExpression(const QString &expression, const QgsStoredExpression::Category &tag=QgsStoredExpression::Category::All) const
Returns an expression according to the expression text.
QList< QgsStoredExpression > storedExpressions(const QgsStoredExpression::Category &tag=QgsStoredExpression::Category::All)
Returns the list of named expressions.
void addStoredExpressions(const QList< QgsStoredExpression > &storedExpressions)
Appends a list of expressions to the existing list.
QgsStoredExpressionManager()=default
void updateStoredExpression(const QString &id, const QString &name, const QString &expression, const QgsStoredExpression::Category &tag)
Updates an expression by id.
bool readXml(const QDomNode &layerNode)
Reads the stored expressions in in XML format.
QString addStoredExpression(const QString &name, const QString &expression, const QgsStoredExpression::Category &tag=QgsStoredExpression::Category::FilterExpression)
Adds an expression to the list.
Stored expression containing name, content (expression text) and a category tag.
QgsStoredExpression()=default
QString expression
expression text
Category
Categories of use cases FilterExpression for stored expressions to filter attribute table DefaultValu...
@ DefaultValueExpression
Expressions to determine default values (not yet used).
@ FilterExpression
Expressions to filter features.
QString id
generated uuid used for identification
QgsStoredExpression(const QString &name, const QString &expression, Category tag=Category::FilterExpression)
Create a new QgsStoredExpression with a generated uuid as id.
QString name
descriptive name of the expression
QgsStoredExpression::Category tag
category of the expression use case
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:275