QGIS API Documentation  2.99.0-Master (b698612)
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 <QObject>
26 #include <QDomNode>
27 #include <QMap>
28 
29 class QgsComposition;
30 class QPainter;
31 
35 class CORE_EXPORT QgsComposerObject: public QObject, public QgsExpressionContextGenerator
36 {
37  Q_OBJECT
38  public:
39 
43  {
44  NoProperty = 0,
47  //composer page properties
53  //general composer item properties
66  //composer map
76  //composer picture
81  //html item
83  //legend item
86  //scalebar item
91  };
92 
98  {
99  EvaluatedValue = 0,
100  OriginalValue
101  };
102 
107  static const QgsPropertiesDefinition &propertyDefinitions();
108 
112  QgsComposerObject( QgsComposition *composition );
113  virtual ~QgsComposerObject() = default;
114 
118  const QgsComposition *composition() const { return mComposition; }
119 
121  QgsComposition *composition() { return mComposition; } SIP_SKIP
122 
127  virtual bool writeXml( QDomElement &elem, QDomDocument &doc ) const;
128 
133  virtual bool readXml( const QDomElement &itemElem, const QDomDocument &doc );
134 
139  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
140 
145  const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
146 
152  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
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 
201  virtual void repaint();
202 
211  virtual void refreshDataDefinedProperty( const DataDefinedProperty property = AllProperties, const QgsExpressionContext *context = nullptr );
212 
213  protected:
214 
215  QgsComposition *mComposition = nullptr;
216 
219 
221 
222  signals:
223 
227  void itemChanged();
228 
229  private slots:
230 
234  void prepareProperties() const;
235 
236  private:
238  static QgsPropertiesDefinition sPropertyDefinitions;
239 
240  static void initPropertyDefinitions();
241 
242  friend class TestQgsComposerObject;
243 };
244 
245 #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:107
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.