QGIS API Documentation  3.0.2-Girona (307d082)
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  };
97 
104  {
105  EvaluatedValue = 0,
106  OriginalValue
107  };
108 
112  static const QgsPropertiesDefinition &propertyDefinitions();
113 
120  explicit QgsLayoutObject( QgsLayout *layout );
121 
125  SIP_SKIP const QgsLayout *layout() const;
126 
130  QgsLayout *layout();
131 
136  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
137 
142  const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
143 
149  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
150 
151 
160  void setCustomProperty( const QString &key, const QVariant &value );
161 
171  QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
172 
180  void removeCustomProperty( const QString &key );
181 
188  QStringList customProperties() const;
189 
195 
196  public slots:
197 
201  virtual void refresh() {}
202 
203  signals:
204 
208  void changed();
209 
210  protected:
211 
220  bool writeObjectPropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
221 
230  bool readObjectPropertiesFromElement( const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context );
231 
232  QPointer< QgsLayout > mLayout;
233 
235 
238 
239  private:
240 
242  static QgsPropertiesDefinition sPropertyDefinitions;
243 
244  static void initPropertyDefinitions();
245 
246  friend class TestQgsLayoutObject;
248 };
249 
250 #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...
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.