QGIS API Documentation  2.99.0-Master (cb63e82)
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"
23 #include "qgspropertycollection.h"
24 #include <QObject>
25 #include <QDomNode>
26 #include <QMap>
27 
28 class QgsComposition;
29 class QPainter;
30 
34 class CORE_EXPORT QgsComposerObject: public QObject, public QgsExpressionContextGenerator
35 {
36  Q_OBJECT
37  public:
38 
42  {
43  NoProperty = 0,
46  //composer page properties
52  //general composer item properties
64  //composer map
74  //composer picture
79  //html item
81  //legend item
84  //scalebar item
89  };
90 
96  {
97  EvaluatedValue = 0,
98  OriginalValue
99  };
100 
105  static const QgsPropertiesDefinition &propertyDefinitions();
106 
110  QgsComposerObject( QgsComposition *composition );
111  virtual ~QgsComposerObject() = default;
112 
116  const QgsComposition *composition() const { return mComposition; }
117 
119  QgsComposition *composition() { return mComposition; }
120 
125  virtual bool writeXml( QDomElement &elem, QDomDocument &doc ) const;
126 
131  virtual bool readXml( const QDomElement &itemElem, const QDomDocument &doc );
132 
137  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
138 
143  const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; }
144 
150  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
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 
199  virtual void repaint();
200 
209  virtual void refreshDataDefinedProperty( const DataDefinedProperty property = AllProperties, const QgsExpressionContext *context = nullptr );
210 
211  protected:
212 
213  QgsComposition *mComposition = nullptr;
214 
217 
219 
220  signals:
221 
225  void itemChanged();
226 
227  private slots:
228 
232  void prepareProperties() const;
233 
234  private:
236  static QgsPropertiesDefinition sPropertyDefinitions;
237 
238  static void initPropertyDefinitions();
239 
240  friend class TestQgsComposerObject;
241 };
242 
243 #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.
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.
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.