QGIS API Documentation
3.8.0-Zanzibar (11aff65)
|
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. More... | |
virtual void | recalculateFrameSizes () |
Recalculates the portion of the multiframe item which is shown in each of its component frames. More... | |
void | refresh () override |
Refreshes the multiframe, causing a recalculation of any property overrides. More... | |
virtual void | refreshDataDefinedProperty (QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties) |
Refreshes a data defined property for the multi frame by reevaluating the property's value and redrawing the item with this new value. More... | |
void | update () |
Forces a redraw of all child frames. More... | |
Public Slots inherited from QgsLayoutObject | |
virtual void | refresh () |
Refreshes the object, causing a recalculation of any property overrides. More... | |
Signals | |
void | contentsChanged () |
Emitted when the contents of the multi frame have changed and the frames must be redrawn. More... | |
Signals inherited from QgsLayoutObject | |
void | changed () |
Emitted when the object's properties change. More... | |
Public Member Functions | |
QgsLayoutMultiFrame (QgsLayout *layout) | |
Construct a new multiframe item, attached to the specified layout. More... | |
~QgsLayoutMultiFrame () override | |
virtual void | addFrame (QgsLayoutFrame *frame, bool recalcFrameSizes=true) |
Adds a frame to the multiframe. More... | |
void | beginCommand (const QString &commandText, UndoCommand command=UndoNone) |
Starts new undo command for this item. More... | |
void | cancelCommand () |
Cancels the current item command and discards it. More... | |
QgsAbstractLayoutUndoCommand * | createCommand (const QString &text, int id, QUndoCommand *parent=nullptr) override |
Creates a new layout undo command with the specified text and parent. More... | |
QgsLayoutFrame * | createNewFrame (QgsLayoutFrame *currentFrame, QPointF pos, QSizeF size) |
Creates a new frame and adds it to the multi frame and layout. More... | |
void | deleteFrames () |
Removes and deletes all child frames. More... | |
virtual QString | displayName () const |
Returns the multiframe display name. More... | |
void | endCommand () |
Completes the current item command and push it onto the layout's undo stack. More... | |
virtual void | finalizeRestoreFromXml () |
Called after all pending items have been restored from XML. More... | |
virtual double | findNearbyPageBreak (double yPos) |
Finds the optimal position to break a frame at. More... | |
virtual QSizeF | fixedFrameSize (int frameIndex=-1) const |
Returns the fixed size for a frame, if desired. More... | |
QgsLayoutFrame * | frame (int index) const |
Returns the child frame at a specified index from the multiframe. More... | |
int | frameCount () const |
Returns the number of frames associated with this multiframe. More... | |
int | frameIndex (QgsLayoutFrame *frame) const |
Returns the index of a frame within the multiframe. More... | |
QList< QgsLayoutFrame * > | frames () const |
Returns a list of all child frames for this multiframe. More... | |
virtual QIcon | icon () const |
Returns the item's icon. More... | |
virtual QSizeF | minFrameSize (int frameIndex=-1) const |
Returns the minimum size for a frames, if desired. More... | |
bool | readXml (const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context, bool includeFrames=false) |
Sets the item state from a DOM element. More... | |
void | removeFrame (int index, bool removeEmptyPages=false) |
Removes a frame by index from the multiframe. More... | |
virtual void | render (QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex)=0 |
Renders a portion of the multiframe's content into a render context. More... | |
ResizeMode | resizeMode () const |
Returns the resize mode for the multiframe. More... | |
void | setResizeMode (ResizeMode mode) |
Sets the resize mode for the multiframe, and recalculates frame sizes to match. More... | |
virtual QSizeF | totalSize () const =0 |
Returns the total size of the multiframe's content, in layout units. More... | |
virtual int | type () const =0 |
Returns unique multiframe type id. More... | |
QString | uuid () const |
Returns the multiframe identification string. More... | |
bool | writeXml (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context, bool includeFrames=false) const |
Stores the multiframe state in a DOM element. More... | |
Public Member Functions inherited from QgsLayoutObject | |
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... | |
QgsPropertyCollection & | dataDefinedProperties () |
Returns a reference to the object's property collection, used for data defined overrides. More... | |
const QgsPropertyCollection & | dataDefinedProperties () const |
Returns a reference to the object's property collection, used for data defined overrides. More... | |
const QgsLayout * | layout () const |
Returns the layout the object is attached to. More... | |
QgsLayout * | layout () |
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 |
Public Member Functions inherited from QgsLayoutUndoObjectInterface | |
virtual | ~QgsLayoutUndoObjectInterface ()=default |
Destructor for QgsLayoutUndoObjectInterface. More... | |
Protected Member Functions | |
virtual bool | readPropertiesFromElement (const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context) |
Sets multiframe state from a DOM element. More... | |
virtual bool | writePropertiesToElement (QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const |
Stores multiframe state within an XML DOM element. More... | |
Protected Member Functions inherited from QgsLayoutObject | |
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 | |
QList< QgsLayoutFrame * > | mFrameItems |
ResizeMode | mResizeMode = UseExistingFrames |
Protected Attributes inherited from QgsLayoutObject | |
QgsObjectCustomProperties | mCustomProperties |
Custom properties for object. More... | |
QgsPropertyCollection | mDataDefinedProperties |
QPointer< QgsLayout > | mLayout |
Friends | |
class | QgsLayout |
class | QgsLayoutFrame |
Additional Inherited Members | |
Static Public Member Functions inherited from QgsLayoutObject | |
static const QgsPropertiesDefinition & | propertyDefinitions () |
Returns the layout object property definitions. More... | |
Abstract base class for layout items with the ability to distribute the content to several frames (QgsLayoutFrame items).
Definition at line 48 of file qgslayoutmultiframe.h.
Specifies the behavior for creating new frames to fit the multiframe's content.
Definition at line 96 of file qgslayoutmultiframe.h.
Multiframe item undo commands, used for collapsing undo commands.
Definition at line 106 of file qgslayoutmultiframe.h.
QgsLayoutMultiFrame::QgsLayoutMultiFrame | ( | QgsLayout * | layout | ) |
Construct a new multiframe item, attached to the specified layout.
Definition at line 24 of file qgslayoutmultiframe.cpp.
|
override |
Definition at line 33 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 55 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 282 of file qgslayoutmultiframe.cpp.
void QgsLayoutMultiFrame::cancelCommand | ( | ) |
Cancels the current item command and discards it.
Definition at line 296 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 277 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 246 of file qgslayoutmultiframe.cpp.
void QgsLayoutMultiFrame::deleteFrames | ( | ) |
Removes and deletes all child frames.
Definition at line 445 of file qgslayoutmultiframe.cpp.
|
virtual |
Returns the multiframe display name.
Reimplemented in QgsLayoutItemHtml, QgsLayoutItemAttributeTable, and QgsLayoutItemTextTable.
Definition at line 272 of file qgslayoutmultiframe.cpp.
void QgsLayoutMultiFrame::endCommand | ( | ) |
Completes the current item command and push it onto the layout's undo stack.
Definition at line 290 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 302 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 50 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 38 of file qgslayoutmultiframe.cpp.
QgsLayoutFrame * QgsLayoutMultiFrame::frame | ( | int | index | ) | const |
Returns the child frame at a specified index from the multiframe.
Definition at line 461 of file qgslayoutmultiframe.cpp.
|
inline |
Returns the number of frames associated with this multiframe.
Definition at line 260 of file qgslayoutmultiframe.h.
int QgsLayoutMultiFrame::frameIndex | ( | QgsLayoutFrame * | frame | ) | const |
Returns the index of a frame within the multiframe.
Definition at line 470 of file qgslayoutmultiframe.cpp.
QList< QgsLayoutFrame * > QgsLayoutMultiFrame::frames | ( | ) | const |
Returns a list of all child frames for this multiframe.
Definition at line 90 of file qgslayoutmultiframe.cpp.
|
inlinevirtual |
Returns the item's icon.
Reimplemented in QgsLayoutItemHtml, and QgsLayoutItemAttributeTable.
Definition at line 149 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 44 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 QgsLayoutTable, QgsLayoutItemAttributeTable, and QgsLayoutItemHtml.
Definition at line 564 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 506 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 226 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 95 of file qgslayoutmultiframe.cpp.
|
overrideslot |
Refreshes the multiframe, causing a recalculation of any property overrides.
Definition at line 330 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 241 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 411 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 QgsLayoutTable, and QgsLayoutItemHtml.
|
inline |
Returns the resize mode for the multiframe.
Definition at line 228 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 78 of file qgslayoutmultiframe.cpp.
|
pure virtual |
Returns the total size of the multiframe's content, in layout units.
Implemented in QgsLayoutTable, and QgsLayoutItemHtml.
|
pure virtual |
Returns unique multiframe type id.
Implemented in QgsLayoutItemHtml, QgsLayoutItemAttributeTable, and QgsLayoutItemTextTable.
|
slot |
Forces a redraw of all child frames.
Definition at line 437 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 134 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 QgsLayoutTable, QgsLayoutItemAttributeTable, and QgsLayoutItemHtml.
Definition at line 559 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 475 of file qgslayoutmultiframe.cpp.
|
friend |
Definition at line 434 of file qgslayoutmultiframe.h.
|
friend |
Definition at line 433 of file qgslayoutmultiframe.h.
|
protected |
Definition at line 401 of file qgslayoutmultiframe.h.
|
protected |
Definition at line 403 of file qgslayoutmultiframe.h.