QGIS API Documentation  3.2.0-Bonn (bc43194)
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

◆ DataDefinedProperty

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 47 of file qgslayoutobject.h.

◆ PropertyValueType

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 105 of file qgslayoutobject.h.

Constructor & Destructor Documentation

◆ QgsLayoutObject()

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 89 of file qgslayoutobject.cpp.

Member Function Documentation

◆ changed

void QgsLayoutObject::changed ( )
signal

Emitted when the object's properties change.

◆ createExpressionContext()

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 132 of file qgslayoutobject.cpp.

◆ customProperties()

QStringList QgsLayoutObject::customProperties ( ) const

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

See also
setCustomProperty()
customProperty()
removeCustomProperty()

Definition at line 127 of file qgslayoutobject.cpp.

◆ customProperty()

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 117 of file qgslayoutobject.cpp.

◆ dataDefinedProperties() [1/2]

QgsPropertyCollection& QgsLayoutObject::dataDefinedProperties ( )
inline

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

See also
setDataDefinedProperties()

Definition at line 138 of file qgslayoutobject.h.

◆ dataDefinedProperties() [2/2]

const QgsPropertyCollection& QgsLayoutObject::dataDefinedProperties ( ) const
inline

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

See also
setDataDefinedProperties()

Definition at line 144 of file qgslayoutobject.h.

◆ layout() [1/2]

const QgsLayout * QgsLayoutObject::layout ( ) const

Returns the layout the object is attached to.

Definition at line 102 of file qgslayoutobject.cpp.

◆ layout() [2/2]

QgsLayout * QgsLayoutObject::layout ( )

Returns the layout the object is attached to.

Definition at line 107 of file qgslayoutobject.cpp.

◆ propertyDefinitions()

const QgsPropertiesDefinition & QgsLayoutObject::propertyDefinitions ( )
static

Returns the layout object property definitions.

Definition at line 83 of file qgslayoutobject.cpp.

◆ readObjectPropertiesFromElement()

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 165 of file qgslayoutobject.cpp.

◆ refresh

virtual void QgsLayoutObject::refresh ( )
inlinevirtualslot

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

Definition at line 203 of file qgslayoutobject.h.

◆ removeCustomProperty()

void QgsLayoutObject::removeCustomProperty ( const QString &  key)

Remove a custom property from the object.

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

Definition at line 122 of file qgslayoutobject.cpp.

◆ setCustomProperty()

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 112 of file qgslayoutobject.cpp.

◆ setDataDefinedProperties()

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()

Definition at line 151 of file qgslayoutobject.h.

◆ writeObjectPropertiesToElement()

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 144 of file qgslayoutobject.cpp.

Friends And Related Function Documentation

◆ QgsCompositionConverter

friend class QgsCompositionConverter
friend

Definition at line 249 of file qgslayoutobject.h.

◆ TestQgsLayoutObject

friend class TestQgsLayoutObject
friend

Definition at line 248 of file qgslayoutobject.h.

Member Data Documentation

◆ mCustomProperties

QgsObjectCustomProperties QgsLayoutObject::mCustomProperties
protected

Custom properties for object.

Definition at line 239 of file qgslayoutobject.h.

◆ mDataDefinedProperties

QgsPropertyCollection QgsLayoutObject::mDataDefinedProperties
protected

Definition at line 236 of file qgslayoutobject.h.

◆ mLayout

QPointer< QgsLayout > QgsLayoutObject::mLayout
protected

Definition at line 234 of file qgslayoutobject.h.


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