QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QgsLayoutObject Class Reference

A base class for objects which belong to a layout. More...

#include <qgslayoutobject.h>

Inheritance diagram for QgsLayoutObject:
Inheritance graph
[legend]

Public Types

enum  DataDefinedProperty {
  NoProperty = 0, AllProperties, TestProperty, PresetPaperSize,
  PaperWidth, PaperHeight, NumPages, PaperOrientation,
  PageNumber, PositionX, PositionY, ItemWidth,
  ItemHeight, ItemRotation, Transparency, Opacity,
  BlendMode, ExcludeFromExports, FrameColor, BackgroundColor,
  MapRotation, MapScale, MapXMin, MapYMin,
  MapXMax, MapYMax, MapAtlasMargin, MapLayers,
  MapStylePreset, PictureSource, PictureSvgBackgroundColor, PictureSvgStrokeColor,
  PictureSvgStrokeWidth, SourceUrl, LegendTitle, LegendColumnCount,
  ScalebarFillColor, ScalebarFillColor2, ScalebarLineColor, ScalebarLineWidth,
  AttributeTableSourceLayer
}
 Data defined properties for different item types. More...
 
enum  PropertyValueType { EvaluatedValue = 0, OriginalValue }
 Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property. More...
 

Public Slots

virtual void refresh ()
 Refreshes the object, causing a recalculation of any property overrides. More...
 

Signals

void changed ()
 Emitted when the object's properties change. More...
 

Public Member Functions

 QgsLayoutObject (QgsLayout *layout)
 Constructor for QgsLayoutObject, with the specified parent layout. More...
 
QgsExpressionContext createExpressionContext () const override
 Creates an expression context relating to the objects' current state. More...
 
QStringList customProperties () const
 Returns list of keys stored in custom properties for the object. More...
 
QVariant customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const
 Read a custom property from the object. More...
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the object's property collection, used for data defined overrides. More...
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the object's property collection, used for data defined overrides. More...
 
const QgsLayoutlayout () const
 Returns the layout the object is attached to. More...
 
QgsLayoutlayout ()
 Returns the layout the object is attached to. More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from the object. More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for the object. More...
 
void setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the objects's property collection, used for data defined overrides. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Static Public Member Functions

static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the layout object property definitions. More...
 

Protected Member Functions

bool readObjectPropertiesFromElement (const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context)
 Sets object properties from a DOM element. More...
 
bool writeObjectPropertiesToElement (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const
 Stores object properties within an XML DOM element. More...
 

Protected Attributes

QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QgsPropertyCollection mDataDefinedProperties
 
QPointer< QgsLayoutmLayout
 

Friends

class QgsCompositionConverter
 
class TestQgsLayoutObject
 

Detailed Description

A base class for objects which belong to a layout.

Since
QGIS 3.0

Definition at line 39 of file qgslayoutobject.h.

Member Enumeration Documentation

Data defined properties for different item types.

Enumerator
NoProperty 

No property.

AllProperties 

All properties for item.

TestProperty 

Dummy property with no effect on item.

PresetPaperSize 

Preset paper size for composition.

PaperWidth 

Paper width (deprecated)

PaperHeight 

Paper height (deprecated)

NumPages 

Number of pages in composition (deprecated)

PaperOrientation 

Paper orientation.

PageNumber 

Page number for item placement.

PositionX 

X position on page.

PositionY 

Y position on page.

ItemWidth 

Width of item.

ItemHeight 

Height of item.

ItemRotation 

Rotation of item.

Transparency 

Item transparency (deprecated)

Opacity 

Item opacity.

BlendMode 

Item blend mode.

ExcludeFromExports 

Exclude item from exports.

FrameColor 

Item frame color.

BackgroundColor 

Item background color.

MapRotation 

Map rotation.

MapScale 

Map scale.

MapXMin 

Map extent x minimum.

MapYMin 

Map extent y minimum.

MapXMax 

Map extent x maximum.

MapYMax 

Map extent y maximum.

MapAtlasMargin 

Map atlas margin.

MapLayers 

Map layer set.

MapStylePreset 

Layer and style map theme.

PictureSource 

Picture source url.

PictureSvgBackgroundColor 

SVG background color.

PictureSvgStrokeColor 

SVG stroke color.

PictureSvgStrokeWidth 

SVG stroke width.

SourceUrl 

Html source url.

LegendTitle 

Legend title.

LegendColumnCount 

Legend column count.

ScalebarFillColor 

Scalebar fill color.

ScalebarFillColor2 

Scalebar secondary fill color.

ScalebarLineColor 

Scalebar line color.

ScalebarLineWidth 

Scalebar line width,.

AttributeTableSourceLayer 

Attribute table source layer.

Definition at line 132 of file qgslayoutobject.h.

Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property.

This may differ if a property has a data defined expression active.

Enumerator
EvaluatedValue 

Return the current evaluated value for the property.

OriginalValue 

Return the original, user set value.

Definition at line 190 of file qgslayoutobject.h.

Constructor & Destructor Documentation

QgsLayoutObject::QgsLayoutObject ( QgsLayout layout)
explicit

Constructor for QgsLayoutObject, with the specified parent layout.

Note
While ownership of a QgsLayoutObject is not passed to the layout, classes which are derived from QgsLayoutObject (such as QgsLayoutItem) may transfer their ownership to a layout upon construction.

Definition at line 90 of file qgslayoutobject.cpp.

Member Function Documentation

void QgsLayoutObject::changed ( )
signal

Emitted when the object's properties change.

QgsExpressionContext QgsLayoutObject::createExpressionContext ( ) const
overridevirtual

Creates an expression context relating to the objects' current state.

The context includes scopes for global, project and layout properties.

Implements QgsExpressionContextGenerator.

Definition at line 133 of file qgslayoutobject.cpp.

QStringList QgsLayoutObject::customProperties ( ) const

Returns list of keys stored in custom properties for the object.

See also
setCustomProperty()
customProperty()
removeCustomProperty()

Definition at line 128 of file qgslayoutobject.cpp.

QVariant QgsLayoutObject::customProperty ( const QString &  key,
const QVariant &  defaultValue = QVariant() 
) const

Read a custom property from the object.

Parameters
keyproperty key
defaultValuedefault value to return if property with matching key does not exist
Returns
value of matching property
See also
setCustomProperty()
removeCustomProperty()
customProperties()

Definition at line 118 of file qgslayoutobject.cpp.

QgsPropertyCollection& QgsLayoutObject::dataDefinedProperties ( )
inline

Returns a reference to the object's property collection, used for data defined overrides.

See also
setDataDefinedProperties()

Definition at line 223 of file qgslayoutobject.h.

const QgsPropertyCollection& QgsLayoutObject::dataDefinedProperties ( ) const
inline

Returns a reference to the object's property collection, used for data defined overrides.

See also
setDataDefinedProperties()
DataDefinedProperty

Definition at line 230 of file qgslayoutobject.h.

const QgsLayout * QgsLayoutObject::layout ( ) const

Returns the layout the object is attached to.

Definition at line 103 of file qgslayoutobject.cpp.

QgsLayout * QgsLayoutObject::layout ( )

Returns the layout the object is attached to.

Definition at line 108 of file qgslayoutobject.cpp.

const QgsPropertiesDefinition & QgsLayoutObject::propertyDefinitions ( )
static

Returns the layout object property definitions.

Definition at line 84 of file qgslayoutobject.cpp.

bool QgsLayoutObject::readObjectPropertiesFromElement ( const QDomElement &  parentElement,
const QDomDocument &  document,
const QgsReadWriteContext context 
)
protected

Sets object properties from a DOM element.

Parameters
parentElementis the parent DOM element for the object
documentDOM document
contextread write context
Returns
true if read was successful
See also
writeObjectPropertiesToElement()

Definition at line 166 of file qgslayoutobject.cpp.

virtual void QgsLayoutObject::refresh ( )
inlinevirtualslot

Refreshes the object, causing a recalculation of any property overrides.

Definition at line 290 of file qgslayoutobject.h.

void QgsLayoutObject::removeCustomProperty ( const QString &  key)

Remove a custom property from the object.

Parameters
keyproperty key
See also
setCustomProperty()
customProperty()
customProperties()

Definition at line 123 of file qgslayoutobject.cpp.

void QgsLayoutObject::setCustomProperty ( const QString &  key,
const QVariant &  value 
)

Set a custom property for the object.

Parameters
keyproperty key. If a property with the same key already exists it will be overwritten.
valueproperty value
See also
customProperty()
removeCustomProperty()
customProperties()

Definition at line 113 of file qgslayoutobject.cpp.

void QgsLayoutObject::setDataDefinedProperties ( const QgsPropertyCollection collection)
inline

Sets the objects's property collection, used for data defined overrides.

Parameters
collectionproperty collection. Existing properties will be replaced.
See also
dataDefinedProperties()
DataDefinedProperty

Definition at line 238 of file qgslayoutobject.h.

bool QgsLayoutObject::writeObjectPropertiesToElement ( QDomElement &  parentElement,
QDomDocument &  document,
const QgsReadWriteContext context 
) const
protected

Stores object properties within an XML DOM element.

Parameters
parentElementis the parent DOM element to store the object's properties in
documentDOM document
contextread write context
Returns
true if write was successful
See also
readObjectPropertiesFromElement()

Definition at line 145 of file qgslayoutobject.cpp.

Friends And Related Function Documentation

friend class QgsCompositionConverter
friend

Definition at line 336 of file qgslayoutobject.h.

friend class TestQgsLayoutObject
friend

Definition at line 335 of file qgslayoutobject.h.

Member Data Documentation

QgsObjectCustomProperties QgsLayoutObject::mCustomProperties
protected

Custom properties for object.

Definition at line 326 of file qgslayoutobject.h.

QgsPropertyCollection QgsLayoutObject::mDataDefinedProperties
protected

Definition at line 323 of file qgslayoutobject.h.

QPointer< QgsLayout > QgsLayoutObject::mLayout
protected

Definition at line 321 of file qgslayoutobject.h.


The documentation for this class was generated from the following files: