QGIS API Documentation  3.2.0-Bonn (bc43194)
qgslayoutobject.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutobject.h
3  -------------------
4  begin : June 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
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 #ifndef QGSLAYOUTOBJECT_H
18 #define QGSLAYOUTOBJECT_H
19 
20 #include "qgis_core.h"
21 #include "qgis_sip.h"
22 #include "qgspropertycollection.h"
25 #include <QObject>
26 #include <QDomNode>
27 #include <QMap>
28 #include <QPointer>
29 
30 class QgsLayout;
31 class QPainter;
33 
39 class CORE_EXPORT QgsLayoutObject: public QObject, public QgsExpressionContextGenerator
40 {
41  Q_OBJECT
42  public:
43 
48  {
49  NoProperty = 0,
52  //composer page properties
58  //general composer item properties
71  //composer map
81  //composer picture
86  //html item
88  //legend item
91  //scalebar item
96  //table item
98  };
99 
106  {
107  EvaluatedValue = 0,
108  OriginalValue
109  };
110 
114  static const QgsPropertiesDefinition &propertyDefinitions();
115 
122  explicit QgsLayoutObject( QgsLayout *layout );
123 
127  SIP_SKIP const QgsLayout *layout() const;
128 
132  QgsLayout *layout();
133 
138  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
139 
144  const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
145 
151  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
152 
153 
162  void setCustomProperty( const QString &key, const QVariant &value );
163 
173  QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
174 
182  void removeCustomProperty( const QString &key );
183 
190  QStringList customProperties() const;
191 
197 
198  public slots:
199 
203  virtual void refresh() {}
204 
205  signals:
206 
210  void changed();
211 
212  protected:
213 
222  bool writeObjectPropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
223 
232  bool readObjectPropertiesFromElement( const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context );
233 
234  QPointer< QgsLayout > mLayout;
235 
237 
240 
241  private:
242 
244  static QgsPropertiesDefinition sPropertyDefinitions;
245 
246  static void initPropertyDefinitions();
247 
248  friend class TestQgsLayoutObject;
250 };
251 
252 #endif //QGSLAYOUTOBJECT_H
The class is used as a container of context for various read/write operations on other objects...
Paper width (deprecated)
Layer and style map theme.
QgsObjectCustomProperties mCustomProperties
Custom properties for object.
Exclude item from exports.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the object&#39;s property collection, used for data defined overrides.
Y position on page.
Item background color.
Map extent x minimum.
Dummy property with no effect on item.
Number of pages in composition (deprecated)
PropertyValueType
Specifies whether the value returned by a function should be the original, user set value...
Attribute table source layer.
X position on page.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Scalebar secondary fill color.
QgsPropertyCollection mDataDefinedProperties
Map extent x maximum.
Item transparency (deprecated)
#define SIP_SKIP
Definition: qgis_sip.h:119
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QPointer< QgsLayout > mLayout
Page number for item placement.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Abstract interface for generating an expression context.
Map extent y maximum.
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
Map extent y minimum.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the objects&#39;s property collection, used for data defined overrides.
Preset paper size for composition.
Paper height (deprecated)
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
A base class for objects which belong to a layout.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
virtual void refresh()
Refreshes the object, causing a recalculation of any property overrides.
DataDefinedProperty
Data defined properties for different item types.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the object&#39;s property collection, used for data defined overrides.
All properties for item.