QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsattributeeditorcontainer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsattributeeditorcontainer.h - QgsAttributeEditorElement
3 
4  ---------------------
5  begin : 12.01.2021
6  copyright : (C) 2021 by Denis Rouzaud
7  email : [email protected]
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 QGSATTRIBUTEEDITORCONTAINER_H
17 #define QGSATTRIBUTEEDITORCONTAINER_H
18 
19 #include "qgis_core.h"
21 
28 {
29  public:
30 
38  QgsAttributeEditorContainer( const QString &name, QgsAttributeEditorElement *parent, const QColor &backgroundColor = QColor() )
39  : QgsAttributeEditorElement( AeTypeContainer, name, parent )
40  , mIsGroupBox( true )
41  , mColumnCount( 1 )
42  , mBackgroundColor( backgroundColor )
43  {}
44 
45 
46  ~QgsAttributeEditorContainer() override;
47 
53  virtual void addChildElement( QgsAttributeEditorElement *element SIP_TRANSFER );
54 
60  virtual void setIsGroupBox( bool isGroupBox ) { mIsGroupBox = isGroupBox; }
61 
67  virtual bool isGroupBox() const { return mIsGroupBox; }
68 
77  bool collapsed() const { return mCollapsed; };
78 
86  void setCollapsed( bool collapsed ) { mCollapsed = collapsed; };
87 
93  QList<QgsAttributeEditorElement *> children() const { return mChildren; }
94 
102  virtual QList<QgsAttributeEditorElement *> findElements( AttributeEditorType type ) const;
103 
107  void clear();
108 
112  void setName( const QString &name );
113 
117  int columnCount() const;
118 
122  void setColumnCount( int columnCount );
123 
130 
138  QgsOptionalExpression visibilityExpression() const;
139 
147  void setVisibilityExpression( const QgsOptionalExpression &visibilityExpression );
148 
159  QgsOptionalExpression collapsedExpression() const SIP_SKIP;
160 
171  void setCollapsedExpression( const QgsOptionalExpression &collapsedExpression ) SIP_SKIP;
172 
178  QColor backgroundColor() const;
179 
183  void setBackgroundColor( const QColor &backgroundColor );
184 
185  private:
186  void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
187  void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
188  QString typeIdentifier() const override;
189 
190  bool mIsGroupBox;
191  QList<QgsAttributeEditorElement *> mChildren;
192  int mColumnCount;
193  QgsOptionalExpression mVisibilityExpression;
194  QColor mBackgroundColor;
195  bool mCollapsed = false;
196  QgsOptionalExpression mCollapsedExpression;
197 };
198 
199 
200 #endif // QGSATTRIBUTEEDITORCONTAINER_H
QgsAttributeEditorElement
This is an abstract base class for any elements of a drag and drop form.
Definition: qgsattributeeditorelement.h:37
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsAttributeEditorElement::QgsAttributeEditorElement
QgsAttributeEditorElement(AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent=nullptr)
Constructor.
Definition: qgsattributeeditorelement.h:135
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsOptionalExpression
An expression with an additional enabled flag.
Definition: qgsoptionalexpression.h:39
QgsAttributeEditorContainer
This is a container for attribute editors, used to group them visually in the attribute form if it is...
Definition: qgsattributeeditorcontainer.h:27
QgsAttributeEditorElement::clone
virtual QgsAttributeEditorElement * clone(QgsAttributeEditorElement *parent) const =0
Returns a clone of this element.
qgsattributeeditorelement.h
QgsAttributeEditorElement::AttributeEditorType
AttributeEditorType
Definition: qgsattributeeditorelement.h:117