23 , mHidePageIfEmpty( false )
24 , mHideBackgroundIfEmpty( false )
31 connect( mf, SIGNAL( contentsChanged() ),
this, SLOT(
repaint() ) );
35 setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
42 , mHidePageIfEmpty(
false )
43 , mHideBackgroundIfEmpty(
false )
55 QDomElement frameElem = doc.createElement(
"ComposerFrame" );
56 frameElem.setAttribute(
"sectionX", QString::number( mSection.x() ) );
57 frameElem.setAttribute(
"sectionY", QString::number( mSection.y() ) );
58 frameElem.setAttribute(
"sectionWidth", QString::number( mSection.width() ) );
59 frameElem.setAttribute(
"sectionHeight", QString::number( mSection.height() ) );
60 frameElem.setAttribute(
"hidePageIfEmpty", mHidePageIfEmpty );
61 frameElem.setAttribute(
"hideBackgroundIfEmpty", mHideBackgroundIfEmpty );
62 elem.appendChild( frameElem );
69 double x = itemElem.attribute(
"sectionX" ).toDouble();
70 double y = itemElem.attribute(
"sectionY" ).toDouble();
71 double width = itemElem.attribute(
"sectionWidth" ).toDouble();
72 double height = itemElem.attribute(
"sectionHeight" ).toDouble();
73 mSection = QRectF( x, y, width, height );
74 mHidePageIfEmpty = itemElem.attribute(
"hidePageIfEmpty",
"0" ).toInt();
75 mHideBackgroundIfEmpty = itemElem.attribute(
"hideBackgroundIfEmpty",
"0" ).toInt();
76 QDomElement composerItem = itemElem.firstChildElement(
"ComposerItem" );
77 if ( composerItem.isNull() )
81 return _readXML( composerItem, doc );
91 if ( hideBackgroundIfEmpty == mHideBackgroundIfEmpty )
107 double multiFrameHeight = mMultiFrame->
totalSize().height();
108 if ( multiFrameHeight <= mSection.top() )
130 return tr(
"<frame>" );
135 QRectF fixedRect = rectangle;
140 int frameIndex = mMultiFrame->
frameIndex(
this );
143 if ( fixedSize.width() > 0 )
145 fixedRect.setWidth( fixedSize.width() );
147 if ( fixedSize.height() > 0 )
149 fixedRect.setHeight( fixedSize.height() );
153 QSizeF minSize = mMultiFrame->
minFrameSize( frameIndex );
154 fixedRect.setWidth( qMax( minSize.width(), fixedRect.width() ) );
155 fixedRect.setHeight( qMax( minSize.height(), fixedRect.height() ) );
163 Q_UNUSED( itemStyle );
177 if ( !empty || !mHideBackgroundIfEmpty )
184 int frameIndex = mMultiFrame->
frameIndex(
this );
185 mMultiFrame->
render( painter, mSection, frameIndex );
188 if ( !empty || !mHideBackgroundIfEmpty )
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
void setHideBackgroundIfEmpty(const bool hideBackgroundIfEmpty)
Sets whether the background and frame border should be hidden if this frame is empty.
virtual QString displayName() const override
Get item display name.
virtual QString displayName() const
Get multiframe display name.
A item that forms part of a map composition.
virtual void drawFrame(QPainter *p)
Draw black frame around item.
virtual QSizeF totalSize() const =0
Returns the total size of the multiframe's content.
void endMultiFrameCommand()
bool _readXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads parameter that are not subclass specific in document.
virtual void drawSelectionBoxes(QPainter *p)
Draws additional graphics on selected items.
void endItemCommand() override
Abstract base class for composer items with the ability to distribute the content to several frames (...
void setSceneRect(const QRectF &rectangle) override
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
bool hideBackgroundIfEmpty() const
Returns whether the background and frame border should be hidden if this frame is empty...
bool shouldDrawItem() const
Returns whether the item should be drawn in the current context.
void setBackgroundEnabled(const bool drawBackground)
Set whether this item has a Background drawn around it or not.
Graphics scene for map printing.
void beginItemCommand(const QString &text) override
virtual QSizeF minFrameSize(const int frameIndex=-1) const
Returns the minimum size for a frames, if desired.
bool isEmpty() const
Returns whether the frame is empty.
void setHidePageIfEmpty(const bool hidePageIfEmpty)
Sets whether the page should be hidden (ie, not included in composer exports) if this frame is empty...
QgsComposition * mComposition
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document.
virtual void drawBackground(QPainter *p)
Draw background.
bool writeXML(QDomElement &elem, QDomDocument &doc) const override
Stores item state in DOM element.
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
QgsComposerFrame(QgsComposition *c, QgsComposerMultiFrame *mf, qreal x, qreal y, qreal width, qreal height)
virtual Q_DECL_DEPRECATED void render(QPainter *p, const QRectF &renderExtent)
Renders a portion of the multiframe's content into a painter.
virtual QSizeF fixedFrameSize(const int frameIndex=-1) const
Returns the fixed size for a frame, if desired.
bool hidePageIfEmpty() const
Returns whether the page should be hidden (ie, not included in composer exports) if this frame is emp...
int frameIndex(QgsComposerFrame *frame) const
Returns the index of a frame within the multiframe.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
Sets item state from DOM element.
QgsComposerItem(QgsComposition *composition, bool manageZValue=true)
Constructor.
QgsComposerMultiFrame * multiFrame() const
Returns the parent multiframe for the frame.
void beginMultiFrameCommand(QgsComposerMultiFrame *multiFrame, const QString &text, const QgsComposerMultiFrameMergeCommand::Context c=QgsComposerMultiFrameMergeCommand::Unknown)
QString id() const
Get item's id (which is not necessarly unique)