QGIS API Documentation  2.99.0-Master (19b062c)
qgscomposerobject.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerobject.h
3  -------------------
4  begin : July 2014
5  copyright : (C) 2014 by Nyall Dawson,Radim Blazek
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 QGSCOMPOSEROBJECT_H
18 #define QGSCOMPOSEROBJECT_H
19 
20 #include "qgis_core.h"
21 #include "qgis_sip.h"
24 #include "qgspropertycollection.h"
25 #include "qgsreadwritecontext.h"
26 
27 #include <QObject>
28 #include <QDomNode>
29 #include <QMap>
30 
31 class QgsComposition;
32 class QPainter;
33 
38 class CORE_EXPORT QgsComposerObject: public QObject, public QgsExpressionContextGenerator
39 {
40  Q_OBJECT
41  public:
42 
47  {
48  NoProperty = 0,
51  //composer page properties
57  //general composer item properties
70  //composer map
80  //composer picture
85  //html item
87  //legend item
90  //scalebar item
95  };
96 
103  {
104  EvaluatedValue = 0,
105  OriginalValue
106  };
107 
112  static const QgsPropertiesDefinition &propertyDefinitions();
113 
118  QgsComposerObject( QgsComposition *composition );
119  virtual ~QgsComposerObject() = default;
120 
125  const QgsComposition *composition() const { return mComposition; }
126 
128  QgsComposition *composition() { return mComposition; } SIP_SKIP
129 
135  virtual bool writeXml( QDomElement &elem, QDomDocument &doc ) const;
136 
142  virtual bool readXml( const QDomElement &itemElem, const QDomDocument &doc );
143 
149  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
150 
156  const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
157 
164  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
165 
175  void setCustomProperty( const QString &key, const QVariant &value );
176 
187  QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
188 
197  void removeCustomProperty( const QString &key );
198 
206  QStringList customProperties() const;
207 
214 
215  public slots:
216 
218  virtual void repaint();
219 
229  virtual void refreshDataDefinedProperty( const DataDefinedProperty property = AllProperties, const QgsExpressionContext *context = nullptr );
230 
231  protected:
232 
233  QgsComposition *mComposition = nullptr;
234 
237 
239 
240  signals:
241 
246  void itemChanged();
247 
248  private slots:
249 
253  void prepareProperties() const;
254 
255  private:
257  static QgsPropertiesDefinition sPropertyDefinitions;
258 
259  static void initPropertyDefinitions();
260 
261  friend class TestQgsComposerObject;
262 };
263 
264 #endif
A base class for objects which belong to a map composition.
QgsObjectCustomProperties mCustomProperties
Custom properties for object.
Layer and style map theme.
Scalebar secondary fill color.
Map extent x maximum.
Map extent x minimum.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the object&#39;s property collection, used for data defined overrides.
DataDefinedProperty
Data defined properties for different item types.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the object&#39;s property collection, used for data defined overrides.
#define SIP_SKIP
Definition: qgis_sip.h:119
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Map extent y minimum.
QgsComposition * composition()
QgsPropertyCollection mDataDefinedProperties
PropertyValueType
Specifies whether the value returned by a function should be the original, user set value...
Graphics scene for map printing.
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Abstract interface for generating an expression context.
Map extent y maximum.
const QgsComposition * composition() const
Returns the composition the item is attached to.
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Number of pages in composition.
Item transparency (deprecated)
Page number for item placement.
Dummy property with no effect on item.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the objects&#39;s property collection, used for data defined overrides.
Preset paper size for composition.
All properties for item.