QGIS API Documentation  2.14.0-Essen
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QgsComposerObject Class Reference

A base class for objects which belong to a map composition. More...

#include <qgscomposerobject.h>

Inheritance diagram for QgsComposerObject:
Inheritance graph
[legend]

Public Types

enum  DataDefinedProperty {
  NoProperty = 0, AllProperties, TestProperty, PresetPaperSize,
  PaperWidth, PaperHeight, NumPages, PaperOrientation,
  PageNumber, PositionX, PositionY, ItemWidth,
  ItemHeight, ItemRotation, Transparency, BlendMode,
  ExcludeFromExports, MapRotation, MapScale, MapXMin,
  MapYMin, MapXMax, MapYMax, MapAtlasMargin,
  MapLayers, MapStylePreset, PictureSource, SourceUrl
}
 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 refreshDataDefinedProperty (const DataDefinedProperty property=AllProperties, const QgsExpressionContext *context=nullptr)
 Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value. More...
 
virtual void repaint ()
 Triggers a redraw for the item. More...
 

Signals

void itemChanged ()
 Emitted when the item changes. More...
 

Public Member Functions

 QgsComposerObject (QgsComposition *composition)
 Constructor. More...
 
virtual ~QgsComposerObject ()
 
const QgsCompositioncomposition () const
 Returns the composition the item is attached to. More...
 
QgsCompositioncomposition ()
 
virtual QgsExpressionContextcreateExpressionContext () const
 Creates an expression context relating to the objects' current state. More...
 
QStringList customProperties () const
 Return 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...
 
QgsDataDefineddataDefinedProperty (const DataDefinedProperty property) const
 Returns a reference to the data defined settings for one of the item's data defined properties. More...
 
virtual bool readXML (const QDomElement &itemElem, const QDomDocument &doc)
 Sets item state from DOM element. 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 setDataDefinedProperty (const DataDefinedProperty property, const bool active, const bool useExpression, const QString &expression, const QString &field)
 Sets parameters for a data defined property for the item. More...
 
virtual bool writeXML (QDomElement &elem, QDomDocument &doc) const
 Stores item state in DOM element. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObjectchild (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObjectparent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThreadthread () const
 

Protected Member Functions

bool dataDefinedEvaluate (const QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue, const QgsExpressionContext &context=QgsExpressionContext()) const
 Evaluate a data defined property and return the calculated value. More...
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObjectsender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

QgsCompositionmComposition
 
QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QMap< QgsComposerObject::DataDefinedProperty, QStringmDataDefinedNames
 Map of data defined properties for the item to string name to use when exporting item to xml. More...
 

Friends

class TestQgsComposerObject
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

A base class for objects which belong to a map composition.

Definition at line 33 of file qgscomposerobject.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

PaperHeight 

paper height

NumPages 

number of pages in composition

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

BlendMode 

item blend mode

ExcludeFromExports 

exclude item from exports

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 visibility preset

PictureSource 

picture source url

SourceUrl 

html source url

Definition at line 40 of file qgscomposerobject.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 81 of file qgscomposerobject.h.

Constructor & Destructor Documentation

QgsComposerObject::QgsComposerObject ( QgsComposition composition)

Constructor.

Parameters
compositionparent composition

Definition at line 25 of file qgscomposerobject.cpp.

QgsComposerObject::~QgsComposerObject ( )
virtual

Definition at line 50 of file qgscomposerobject.cpp.

Member Function Documentation

const QgsComposition* QgsComposerObject::composition ( ) const
inline

Returns the composition the item is attached to.

Returns
QgsComposition for item.

Definition at line 96 of file qgscomposerobject.h.

QgsComposition* QgsComposerObject::composition ( )
inline
Note
not available in python bindings

Definition at line 99 of file qgscomposerobject.h.

QgsExpressionContext * QgsComposerObject::createExpressionContext ( ) const
virtual

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

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

Note
added in QGIS 2.12

Reimplemented in QgsComposerMapGrid, QgsComposerMap, QgsComposerItem, QgsComposerAttributeTableV2, and QgsComposerFrame.

Definition at line 190 of file qgscomposerobject.cpp.

QStringList QgsComposerObject::customProperties ( ) const

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

See also
setCustomProperty()
customProperty()
removeCustomProperty()
Note
added in QGIS 2.12

Definition at line 185 of file qgscomposerobject.cpp.

QVariant QgsComposerObject::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()
Note
added in QGIS 2.12

Definition at line 175 of file qgscomposerobject.cpp.

bool QgsComposerObject::dataDefinedEvaluate ( const QgsComposerObject::DataDefinedProperty  property,
QVariant expressionValue,
const QgsExpressionContext context = QgsExpressionContext() 
) const
protected

Evaluate a data defined property and return the calculated value.

Returns
true if data defined property could be successfully evaluated
Parameters
propertydata defined property to evaluate
expressionValueQVariant for storing the evaluated value
contextexpression context for evaluating expressions. Must have feature and fields set to current atlas feature and coverage layer fields prior to calling this method.
Note
this method was added in version 2.5

Definition at line 149 of file qgscomposerobject.cpp.

QgsDataDefined * QgsComposerObject::dataDefinedProperty ( const DataDefinedProperty  property) const

Returns a reference to the data defined settings for one of the item's data defined properties.

Parameters
propertydata defined property to return
Note
this method was added in version 2.5

Definition at line 88 of file qgscomposerobject.cpp.

void QgsComposerObject::itemChanged ( )
signal

Emitted when the item changes.

Signifies that the item widgets must update the gui elements.

bool QgsComposerObject::readXML ( const QDomElement itemElem,
const QDomDocument doc 
)
virtual
void QgsComposerObject::refreshDataDefinedProperty ( const DataDefinedProperty  property = AllProperties,
const QgsExpressionContext context = nullptr 
)
virtualslot

Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value.

Parameters
propertydata defined property to refresh. If property is set to QgsComposerItem::AllProperties then all data defined properties for the item will be refreshed.
contextexpression context for evaluating data defined expressions
Note
this method was added in version 2.5

Definition at line 141 of file qgscomposerobject.cpp.

void QgsComposerObject::removeCustomProperty ( const QString key)

Remove a custom property from the object.

Parameters
keyproperty key
See also
setCustomProperty()
customProperty()
customProperties()
Note
added in QGIS 2.12

Definition at line 180 of file qgscomposerobject.cpp.

void QgsComposerObject::repaint ( )
virtualslot

Triggers a redraw for the item.

Definition at line 136 of file qgscomposerobject.cpp.

void QgsComposerObject::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()
Note
added in QGIS 2.12

Definition at line 170 of file qgscomposerobject.cpp.

void QgsComposerObject::setDataDefinedProperty ( const DataDefinedProperty  property,
const bool  active,
const bool  useExpression,
const QString expression,
const QString field 
)

Sets parameters for a data defined property for the item.

Parameters
propertydata defined property to set
activetrue if data defined property is active, false if it is disabled
useExpressiontrue if the expression should be used
expressionexpression for data defined property
fieldfield name if the data defined property should take its value from a field
Note
this method was added in version 2.5

Definition at line 107 of file qgscomposerobject.cpp.

bool QgsComposerObject::writeXML ( QDomElement elem,
QDomDocument doc 
) const
virtual

Friends And Related Function Documentation

friend class TestQgsComposerObject
friend

Definition at line 226 of file qgscomposerobject.h.

Member Data Documentation

QgsComposition* QgsComposerObject::mComposition
protected

Definition at line 190 of file qgscomposerobject.h.

QgsObjectCustomProperties QgsComposerObject::mCustomProperties
protected

Custom properties for object.

Definition at line 196 of file qgscomposerobject.h.

QMap< QgsComposerObject::DataDefinedProperty, QString > QgsComposerObject::mDataDefinedNames
protected

Map of data defined properties for the item to string name to use when exporting item to xml.

Definition at line 193 of file qgscomposerobject.h.


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