QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Abstract base class for layout items with the ability to distribute the content to several frames (QgsLayoutFrame items). More...
#include <qgslayoutmultiframe.h>
Public Slots | |
void | recalculateFrameRects () |
Forces a recalculation of all the associated frame's scene rectangles. | |
virtual void | recalculateFrameSizes () |
Recalculates the portion of the multiframe item which is shown in each of its component frames. | |
void | refresh () override |
Refreshes the multiframe, causing a recalculation of any property overrides. | |
virtual void | refreshDataDefinedProperty (QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::DataDefinedProperty::AllProperties) |
Refreshes a data defined property for the multi frame by reevaluating the property's value and redrawing the item with this new value. | |
void | update () |
Forces a redraw of all child frames. | |
Public Slots inherited from QgsLayoutObject | |
virtual void | refresh () |
Refreshes the object, causing a recalculation of any property overrides. | |
Signals | |
void | contentsChanged () |
Emitted when the contents of the multi frame have changed and the frames must be redrawn. | |
Signals inherited from QgsLayoutObject | |
void | changed () |
Emitted when the object's properties change. | |
Public Member Functions | |
QgsLayoutMultiFrame (QgsLayout *layout) | |
Construct a new multiframe item, attached to the specified layout. | |
~QgsLayoutMultiFrame () override | |
virtual void | addFrame (QgsLayoutFrame *frame, bool recalcFrameSizes=true) |
Adds a frame to the multiframe. | |
void | beginCommand (const QString &commandText, UndoCommand command=UndoNone) |
Starts new undo command for this item. | |
void | cancelCommand () |
Cancels the current item command and discards it. | |
QgsAbstractLayoutUndoCommand * | createCommand (const QString &text, int id, QUndoCommand *parent=nullptr) override |
Creates a new layout undo command with the specified text and parent. | |
QgsExpressionContext | createExpressionContext () const override |
This method needs to be reimplemented in all classes which implement this interface and return an expression context. | |
QgsLayoutFrame * | createNewFrame (QgsLayoutFrame *currentFrame, QPointF pos, QSizeF size) |
Creates a new frame and adds it to the multi frame and layout. | |
void | deleteFrames () |
Removes and deletes all child frames. | |
virtual QString | displayName () const |
Returns the multiframe display name. | |
void | endCommand () |
Completes the current item command and push it onto the layout's undo stack. | |
virtual void | finalizeRestoreFromXml () |
Called after all pending items have been restored from XML. | |
virtual double | findNearbyPageBreak (double yPos) |
Finds the optimal position to break a frame at. | |
virtual QSizeF | fixedFrameSize (int frameIndex=-1) const |
Returns the fixed size for a frame, if desired. | |
QgsLayoutFrame * | frame (int index) const |
Returns the child frame at a specified index from the multiframe. | |
int | frameCount () const |
Returns the number of frames associated with this multiframe. | |
int | frameIndex (QgsLayoutFrame *frame) const |
Returns the index of a frame within the multiframe. | |
QList< QgsLayoutFrame * > | frames () const |
Returns a list of all child frames for this multiframe. | |
virtual QIcon | icon () const |
Returns the item's icon. | |
virtual QSizeF | minFrameSize (int frameIndex=-1) const |
Returns the minimum size for a frames, if desired. | |
bool | readXml (const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context, bool includeFrames=false) |
Sets the item state from a DOM element. | |
void | removeFrame (int index, bool removeEmptyPages=false) |
Removes a frame by index from the multiframe. | |
virtual void | render (QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex)=0 |
Renders a portion of the multiframe's content into a render context. | |
ResizeMode | resizeMode () const |
Returns the resize mode for the multiframe. | |
void | setResizeMode (ResizeMode mode) |
Sets the resize mode for the multiframe, and recalculates frame sizes to match. | |
virtual QSizeF | totalSize () const =0 |
Returns the total size of the multiframe's content, in layout units. | |
virtual int | type () const =0 |
Returns unique multiframe type id. | |
QString | uuid () const |
Returns the multiframe identification string. | |
bool | writeXml (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context, bool includeFrames=false) const |
Stores the multiframe state in a DOM element. | |
Public Member Functions inherited from QgsLayoutObject | |
QgsLayoutObject (QgsLayout *layout) | |
Constructor for QgsLayoutObject, with the specified parent layout. | |
QgsExpressionContext | createExpressionContext () const override |
Creates an expression context relating to the objects' current state. | |
QStringList | customProperties () const |
Returns list of keys stored in custom properties for the object. | |
QVariant | customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const |
Read a custom property from the object. | |
QgsPropertyCollection & | dataDefinedProperties () |
Returns a reference to the object's property collection, used for data defined overrides. | |
const QgsPropertyCollection & | dataDefinedProperties () const |
Returns a reference to the object's property collection, used for data defined overrides. | |
QgsLayout * | layout () |
Returns the layout the object is attached to. | |
const QgsLayout * | layout () const |
Returns the layout the object is attached to. | |
void | removeCustomProperty (const QString &key) |
Remove a custom property from the object. | |
void | setCustomProperty (const QString &key, const QVariant &value) |
Set a custom property for the object. | |
void | setDataDefinedProperties (const QgsPropertyCollection &collection) |
Sets the objects's property collection, used for data defined overrides. | |
Public Member Functions inherited from QgsExpressionContextGenerator | |
virtual | ~QgsExpressionContextGenerator ()=default |
Public Member Functions inherited from QgsLayoutUndoObjectInterface | |
virtual | ~QgsLayoutUndoObjectInterface ()=default |
Protected Member Functions | |
virtual bool | readPropertiesFromElement (const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context) |
Sets multiframe state from a DOM element. | |
virtual bool | writePropertiesToElement (QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const |
Stores multiframe state within an XML DOM element. | |
Protected Member Functions inherited from QgsLayoutObject | |
bool | readObjectPropertiesFromElement (const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context) |
Sets object properties from a DOM element. | |
bool | writeObjectPropertiesToElement (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const |
Stores object properties within an XML DOM element. | |
Protected Attributes | |
QList< QgsLayoutFrame * > | mFrameItems |
ResizeMode | mResizeMode = UseExistingFrames |
Protected Attributes inherited from QgsLayoutObject | |
QgsObjectCustomProperties | mCustomProperties |
Custom properties for object. | |
QgsPropertyCollection | mDataDefinedProperties |
QPointer< QgsLayout > | mLayout |
Friends | |
class | QgsLayout |
class | QgsLayoutFrame |
Additional Inherited Members | |
Static Public Member Functions inherited from QgsLayoutObject | |
static bool | propertyAssociatesWithParentMultiframe (DataDefinedProperty property) |
Returns true if the specified property key is normally associated with the parent QgsLayoutMultiFrame object instead of a child QgsLayoutFrame object. | |
static const QgsPropertiesDefinition & | propertyDefinitions () |
Returns the layout object property definitions. | |
Abstract base class for layout items with the ability to distribute the content to several frames (QgsLayoutFrame items).
Definition at line 47 of file qgslayoutmultiframe.h.
Specifies the behavior for creating new frames to fit the multiframe's content.
Definition at line 100 of file qgslayoutmultiframe.h.
Multiframe item undo commands, used for collapsing undo commands.
Definition at line 110 of file qgslayoutmultiframe.h.
QgsLayoutMultiFrame::QgsLayoutMultiFrame | ( | QgsLayout * | layout | ) |
Construct a new multiframe item, attached to the specified layout.
Definition at line 26 of file qgslayoutmultiframe.cpp.
|
override |
Definition at line 35 of file qgslayoutmultiframe.cpp.
|
virtual |
Adds a frame to the multiframe.
If recalcFrameSizes is set to true
, then a recalculation of all existing frame sizes will be forced.
Definition at line 57 of file qgslayoutmultiframe.cpp.
void QgsLayoutMultiFrame::beginCommand | ( | const QString & | commandText, |
QgsLayoutMultiFrame::UndoCommand | command = UndoNone |
||
) |
Starts new undo command for this item.
The commandText should be a capitalized, imperative tense description (e.g. "Add Map Item"). If specified, multiple consecutive commands for this item with the same command will be collapsed into a single undo command in the layout history.
Definition at line 291 of file qgslayoutmultiframe.cpp.
void QgsLayoutMultiFrame::cancelCommand | ( | ) |
Cancels the current item command and discards it.
Definition at line 305 of file qgslayoutmultiframe.cpp.
|
signal |
Emitted when the contents of the multi frame have changed and the frames must be redrawn.
|
overridevirtual |
Creates a new layout undo command with the specified text and parent.
The id argument can be used to specify an id number for the source event - this is used to determine whether QUndoCommand command compression can apply to the command.
Implements QgsLayoutUndoObjectInterface.
Definition at line 279 of file qgslayoutmultiframe.cpp.
|
overridevirtual |
This method needs to be reimplemented in all classes which implement this interface and return an expression context.
Implements QgsExpressionContextGenerator.
Definition at line 284 of file qgslayoutmultiframe.cpp.
QgsLayoutFrame * QgsLayoutMultiFrame::createNewFrame | ( | QgsLayoutFrame * | currentFrame, |
QPointF | pos, | ||
QSizeF | size | ||
) |
Creates a new frame and adds it to the multi frame and layout.
currentFrame | an existing QgsLayoutFrame from which to copy the size and general frame properties (e.g., frame style, background, rendering settings). |
pos | position of top-left corner of the new frame, in layout units |
size | size of the new frame, in layout units |
Definition at line 248 of file qgslayoutmultiframe.cpp.
void QgsLayoutMultiFrame::deleteFrames | ( | ) |
Removes and deletes all child frames.
Definition at line 460 of file qgslayoutmultiframe.cpp.
|
virtual |
Returns the multiframe display name.
Reimplemented in QgsLayoutItemAttributeTable, QgsLayoutItemHtml, QgsLayoutItemManualTable, and QgsLayoutItemTextTable.
Definition at line 274 of file qgslayoutmultiframe.cpp.
void QgsLayoutMultiFrame::endCommand | ( | ) |
Completes the current item command and push it onto the layout's undo stack.
Definition at line 299 of file qgslayoutmultiframe.cpp.
|
virtual |
Called after all pending items have been restored from XML.
Multiframes can use this method to run steps which must take place after all items have been restored to the layout, such as connecting to signals emitted by other items, which may not have existed in the layout at the time readXml() was called. E.g. a scalebar can use this to connect to its linked map item after restoration from XML.
Reimplemented in QgsLayoutItemAttributeTable.
Definition at line 311 of file qgslayoutmultiframe.cpp.
|
virtual |
Finds the optimal position to break a frame at.
yPos | maximum vertical position for break, in layout units. |
Reimplemented in QgsLayoutItemHtml.
Definition at line 52 of file qgslayoutmultiframe.cpp.
|
virtual |
Returns the fixed size for a frame, if desired.
If the fixed frame size changes, the sizes of all frames can be recalculated by calling recalculateFrameRects().
frameIndex | frame number |
Reimplemented in QgsLayoutTable.
Definition at line 40 of file qgslayoutmultiframe.cpp.
QgsLayoutFrame * QgsLayoutMultiFrame::frame | ( | int | index | ) | const |
Returns the child frame at a specified index from the multiframe.
Definition at line 476 of file qgslayoutmultiframe.cpp.
|
inline |
Returns the number of frames associated with this multiframe.
Definition at line 264 of file qgslayoutmultiframe.h.
int QgsLayoutMultiFrame::frameIndex | ( | QgsLayoutFrame * | frame | ) | const |
Returns the index of a frame within the multiframe.
Definition at line 485 of file qgslayoutmultiframe.cpp.
QList< QgsLayoutFrame * > QgsLayoutMultiFrame::frames | ( | ) | const |
Returns a list of all child frames for this multiframe.
Definition at line 92 of file qgslayoutmultiframe.cpp.
|
inlinevirtual |
Returns the item's icon.
Reimplemented in QgsLayoutItemAttributeTable, QgsLayoutItemHtml, and QgsLayoutItemManualTable.
Definition at line 153 of file qgslayoutmultiframe.h.
|
virtual |
Returns the minimum size for a frames, if desired.
If the minimum size changes, the sizes of all frames can be recalculated by calling recalculateFrameRects().
frameIndex | frame number |
Reimplemented in QgsLayoutTable.
Definition at line 46 of file qgslayoutmultiframe.cpp.
|
protectedvirtual |
Sets multiframe state from a DOM element.
element | is the DOM element for the multiframe |
document | DOM document |
context | read write context |
Note that item subclasses should not rely on all other items being present in the layout at the time this method is called. Instead, any connections and links to other items must be made in the finalizeRestoreFromXml() method. E.g. when restoring a scalebar, the connection to the linked map's signals should be implemented in finalizeRestoreFromXml(), not readPropertiesFromElement().
Reimplemented in QgsLayoutItemAttributeTable, QgsLayoutItemHtml, QgsLayoutItemManualTable, and QgsLayoutTable.
Definition at line 579 of file qgslayoutmultiframe.cpp.
bool QgsLayoutMultiFrame::readXml | ( | const QDomElement & | itemElement, |
const QDomDocument & | document, | ||
const QgsReadWriteContext & | context, | ||
bool | includeFrames = false |
||
) |
Sets the item state from a DOM element.
itemElement | is the DOM node corresponding to item (e.g. 'LayoutItem' element) |
document | DOM document |
context | read write context |
includeFrames | set to true to read state information about child frames from DOM |
Definition at line 521 of file qgslayoutmultiframe.cpp.
|
slot |
Forces a recalculation of all the associated frame's scene rectangles.
This method is useful for multiframes which implement a minFrameSize() or fixedFrameSize() method.
Definition at line 228 of file qgslayoutmultiframe.cpp.
|
virtualslot |
Recalculates the portion of the multiframe item which is shown in each of its component frames.
If the resize mode is set to anything but UseExistingFrames then this may cause new frames to be added or frames to be removed, in order to fit the current size of the multiframe's content.
Definition at line 97 of file qgslayoutmultiframe.cpp.
|
overrideslot |
Refreshes the multiframe, causing a recalculation of any property overrides.
Definition at line 339 of file qgslayoutmultiframe.cpp.
|
virtualslot |
Refreshes a data defined property for the multi frame by reevaluating the property's value and redrawing the item with this new value.
If property is set to QgsLayoutObject::AllProperties then all data defined properties for the item will be refreshed.
Reimplemented in QgsLayoutItemAttributeTable.
Definition at line 243 of file qgslayoutmultiframe.cpp.
void QgsLayoutMultiFrame::removeFrame | ( | int | index, |
bool | removeEmptyPages = false |
||
) |
Removes a frame by index from the multiframe.
This method automatically removes the frame from the layout too.
If removeEmptyPages is set to true
, then pages which are empty after the frame is removed will also be removed from the layout.
Definition at line 420 of file qgslayoutmultiframe.cpp.
|
pure virtual |
Renders a portion of the multiframe's content into a render context.
context | destination render painter |
renderExtent | visible extent of content to render into the painter. |
frameIndex | frame number for content |
Implemented in QgsLayoutItemHtml, and QgsLayoutTable.
|
inline |
Returns the resize mode for the multiframe.
Definition at line 232 of file qgslayoutmultiframe.h.
void QgsLayoutMultiFrame::setResizeMode | ( | ResizeMode | mode | ) |
Sets the resize mode for the multiframe, and recalculates frame sizes to match.
Definition at line 80 of file qgslayoutmultiframe.cpp.
|
pure virtual |
Returns the total size of the multiframe's content, in layout units.
Implemented in QgsLayoutItemHtml, and QgsLayoutTable.
|
pure virtual |
Returns unique multiframe type id.
Implemented in QgsLayoutItemAttributeTable, QgsLayoutItemHtml, QgsLayoutItemManualTable, and QgsLayoutItemTextTable.
|
slot |
Forces a redraw of all child frames.
Definition at line 452 of file qgslayoutmultiframe.cpp.
|
inline |
Returns the multiframe identification string.
This is a unique random string set for the multiframe upon creation.
Definition at line 138 of file qgslayoutmultiframe.h.
|
protectedvirtual |
Stores multiframe state within an XML DOM element.
element | is the DOM element to store the multiframe's properties in |
document | DOM document |
context | read write context |
Reimplemented in QgsLayoutItemAttributeTable, QgsLayoutItemHtml, QgsLayoutItemManualTable, and QgsLayoutTable.
Definition at line 574 of file qgslayoutmultiframe.cpp.
bool QgsLayoutMultiFrame::writeXml | ( | QDomElement & | parentElement, |
QDomDocument & | document, | ||
const QgsReadWriteContext & | context, | ||
bool | includeFrames = false |
||
) | const |
Stores the multiframe state in a DOM element.
parentElement | parent DOM element (e.g. 'Layout' element) |
document | DOM document |
context | read write context |
includeFrames | set to true to write state information about child frames into DOM |
Definition at line 490 of file qgslayoutmultiframe.cpp.
|
friend |
Definition at line 440 of file qgslayoutmultiframe.h.
|
friend |
Definition at line 439 of file qgslayoutmultiframe.h.
|
protected |
Definition at line 407 of file qgslayoutmultiframe.h.
|
protected |
Definition at line 409 of file qgslayoutmultiframe.h.