QGIS API Documentation 4.1.0-Master (60fea48833c)
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// clang-format off
30% ModuleHeaderCode
32% End
33// clang-format on
34#endif
35
36 class QDomNode;
37class QDomDocument;
38
44class CORE_EXPORT QgsStoredExpression
45{
46 public:
58
59#ifndef SIP_RUN
60
62
71 : id( QUuid::createUuid().toString() )
72 , name( name )
74 , tag( tag )
75 {}
76#endif
77
79 QString id;
81 QString name;
83 QString expression;
86};
87
93class CORE_EXPORT QgsStoredExpressionManager : public QObject
94{
95 Q_OBJECT
96
97 public:
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:274