QGIS API Documentation  2.99.0-Master (a411669)
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 
36 class CORE_EXPORT QgsComposerObject: public QObject, public QgsExpressionContextGenerator
37 {
38  Q_OBJECT
39  public:
40 
45  {
46  NoProperty = 0,
49  //composer page properties
55  //general composer item properties
68  //composer map
78  //composer picture
83  //html item
85  //legend item
88  //scalebar item
93  };
94 
101  {
102  EvaluatedValue = 0,
103  OriginalValue
104  };
105 
110  static const QgsPropertiesDefinition &propertyDefinitions();
111 
116  QgsComposerObject( QgsComposition *composition );
117  virtual ~QgsComposerObject() = default;
118 
123  const QgsComposition *composition() const { return mComposition; }
124 
126  QgsComposition *composition() { return mComposition; } SIP_SKIP
127 
133  virtual bool writeXml( QDomElement &elem, QDomDocument &doc ) const;
134 
140  virtual bool readXml( const QDomElement &itemElem, const QDomDocument &doc );
141 
147  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
148 
154  const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
155 
162  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
163 
173  void setCustomProperty( const QString &key, const QVariant &value );
174 
185  QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
186 
195  void removeCustomProperty( const QString &key );
196 
204  QStringList customProperties() const;
205 
212 
213  public slots:
214 
216  virtual void repaint();
217 
227  virtual void refreshDataDefinedProperty( const DataDefinedProperty property = AllProperties, const QgsExpressionContext *context = nullptr );
228 
229  protected:
230 
231  QgsComposition *mComposition = nullptr;
232 
235 
237 
238  signals:
239 
244  void itemChanged();
245 
246  private slots:
247 
251  void prepareProperties() const;
252 
253  private:
255  static QgsPropertiesDefinition sPropertyDefinitions;
256 
257  static void initPropertyDefinitions();
258 
259  friend class TestQgsComposerObject;
260 };
261 
262 #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.