QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
24 , mMultiFrame( multiFrame )
25 , mMultiFrameUuid( multiFrame ? multiFrame->uuid() : QString() )
84 return mMultiFrame->
icon();
112 double multiFrameHeight = mMultiFrame->
totalSize().height();
113 if ( multiFrameHeight <= mSection.top() )
154 return tr(
"<Frame>" );
160 mMultiFrame->handleFrameRemoval(
this );
170 int frameIndex = mMultiFrame->
frameIndex(
this );
171 Q_ASSERT_X( frameIndex >= 0,
"QgsLayoutFrame::draw",
"Invalid frame index for frame" );
172 mMultiFrame->
render( context, mSection, frameIndex );
178 if ( !
isEmpty() || !mHideBackgroundIfEmpty )
186 if ( !
isEmpty() || !mHideBackgroundIfEmpty )
194 parentElement.setAttribute( QStringLiteral(
"multiFrame" ), mMultiFrameUuid );
195 parentElement.setAttribute( QStringLiteral(
"multiFrameTemplateUuid" ), mMultiFrameUuid );
196 parentElement.setAttribute( QStringLiteral(
"sectionX" ), QString::number( mSection.x() ) );
197 parentElement.setAttribute( QStringLiteral(
"sectionY" ), QString::number( mSection.y() ) );
198 parentElement.setAttribute( QStringLiteral(
"sectionWidth" ), QString::number( mSection.width() ) );
199 parentElement.setAttribute( QStringLiteral(
"sectionHeight" ), QString::number( mSection.height() ) );
200 parentElement.setAttribute( QStringLiteral(
"hidePageIfEmpty" ), mHidePageIfEmpty );
201 parentElement.setAttribute( QStringLiteral(
"hideBackgroundIfEmpty" ), mHideBackgroundIfEmpty );
207 double x = itemElem.attribute( QStringLiteral(
"sectionX" ) ).toDouble();
208 double y = itemElem.attribute( QStringLiteral(
"sectionY" ) ).toDouble();
209 double width = itemElem.attribute( QStringLiteral(
"sectionWidth" ) ).toDouble();
210 double height = itemElem.attribute( QStringLiteral(
"sectionHeight" ) ).toDouble();
211 mSection = QRectF( x, y, width, height );
212 mHidePageIfEmpty = itemElem.attribute( QStringLiteral(
"hidePageIfEmpty" ), QStringLiteral(
"0" ) ).toInt();
213 mHideBackgroundIfEmpty = itemElem.attribute( QStringLiteral(
"hideBackgroundIfEmpty" ), QStringLiteral(
"0" ) ).toInt();
215 mMultiFrameUuid = itemElem.attribute( QStringLiteral(
"multiFrame" ) );
216 if ( mMultiFrameUuid.isEmpty( ) )
218 mMultiFrameUuid = itemElem.attribute( QStringLiteral(
"multiFrameTemplateUuid" ) );
220 mMultiFrame =
mLayout->multiFrameByUuid( mMultiFrameUuid );
virtual void cleanup()
Called just before a batch of items are deleted, allowing them to run cleanup tasks.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QString id() const
Returns the item's ID name.
const QgsLayout * layout() const
Returns the layout the object is attached to.
virtual QSizeF totalSize() const =0
Returns the total size of the multiframe's content, in layout units.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void refreshItemSize()
Refreshes an item's size by rechecking it against any possible item fixed or minimum sizes.
void setHideBackgroundIfEmpty(bool hideBackgroundIfEmpty)
Sets whether the background and frame stroke should be hidden if this frame is empty.
bool hidePageIfEmpty() const
Returns whether the page should be hidden (ie, not included in layout exports) if this frame is empty...
QgsLayoutFrame(QgsLayout *layout, QgsLayoutMultiFrame *multiFrame)
Constructor for QgsLayoutFrame, with the specified parent layout and belonging to a multiFrame.
bool writePropertiesToElement(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const override
Stores item state within an XML DOM element.
QgsLayoutSize fixedSize() const override
Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized.
static QgsExpressionContextScope * layoutItemScope(const QgsLayoutItem *item)
Creates a new scope which contains variables and functions relating to a QgsLayoutItem.
virtual void drawFrame(QgsRenderContext &context)
Draws the frame around the item.
bool hideBackgroundIfEmpty() const
Returns whether the background and frame stroke should be hidden if this frame is empty.
bool isEmpty() const
Returns whether the frame is empty.
virtual QIcon icon() const
Returns the item's icon.
virtual void drawBackground(QgsRenderContext &context)
Draws the background for the item.
void draw(QgsLayoutItemRenderContext &context) override
Draws the item's contents using the specified item render context.
ExportLayerBehavior
Behavior of item when exporting to layered outputs.
void setHidePageIfEmpty(bool hidePageIfEmpty)
Sets whether the page should be hidden (ie, not included in layout exports) if this frame is empty.
int type() const override
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void setBackgroundEnabled(bool drawBackground)
Sets whether this item has a background drawn under it or not.
static QgsLayoutFrame * create(QgsLayout *layout)
Creates a new QgsLayoutFrame belonging to the specified layout.
virtual QSizeF minFrameSize(int frameIndex=-1) const
Returns the minimum size for a frames, if desired.
void cleanup() override
Called just before a batch of items are deleted, allowing them to run cleanup tasks.
Base class for graphical items within a QgsLayout.
void contentsChanged()
Emitted when the contents of the multi frame have changed and the frames must be redrawn.
virtual void render(QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex)=0
Renders a portion of the multiframe's content into a render context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void drawFrame(QgsRenderContext &context) override
Draws the frame around the item.
QString displayName() const override
Gets item display name.
QPointer< QgsLayout > mLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
QgsLayoutSize minimumSize() const override
Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely r...
void drawBackground(QgsRenderContext &context) override
Draws the background for the item.
virtual QSizeF fixedFrameSize(int frameIndex=-1) const
Returns the fixed size for a frame, if desired.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
bool readPropertiesFromElement(const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context) override
Sets item state from a DOM element.
@ LayoutMillimeters
Millimeters.
@ LayoutFrame
Frame item, part of a QgsLayoutMultiFrame object.
int frameIndex(QgsLayoutFrame *frame) const
Returns the index of a frame within the multiframe.
@ CanGroupWithItemsOfSameType
Item can only be placed on layers with other items of the same type, but multiple items of this type ...
virtual QString displayName() const
Returns the multiframe display name.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
ExportLayerBehavior exportLayerBehavior() const override
Returns the behavior of this item during exporting to layered exports (e.g.
QgsLayoutMultiFrame * multiFrame() const
Returns the parent multiframe for the frame.
QIcon icon() const override
Returns the item's icon.