37 QSet<QgsComposerItem*>::iterator itemIt = mItems.begin();
38 for ( ; itemIt != mItems.end(); ++itemIt )
45 ( *itemIt )->setIsGroupMember(
false );
57 if ( mItems.contains( item ) )
62 connect( item, SIGNAL( destroyed() ),
this, SLOT(
itemDestroyed() ) );
64 mItems.insert( item );
69 if ( mBoundingRectangle.isEmpty() )
71 mBoundingRectangle = QRectF( 0, 0, item->rect().width(), item->rect().height() );
85 mBoundingRectangle = mapRectToScene( mBoundingRectangle );
87 mBoundingRectangle = mBoundingRectangle.united( item->mapRectToScene( item->rect() ) );
94 mBoundingRectangle = mBoundingRectangle.united( mapRectFromItem( item, item->rect() ) );
95 QPointF newPos = mapToScene( mBoundingRectangle.topLeft().x(), mBoundingRectangle.topLeft().y() );
96 mBoundingRectangle = QRectF( 0, 0, mBoundingRectangle.width(), mBoundingRectangle.height() );
105 QSet<QgsComposerItem*>::iterator item_it = mItems.begin();
106 for ( ; item_it != mItems.end(); ++item_it )
108 ( *item_it )->setIsGroupMember(
false );
109 ( *item_it )->setSelected(
true );
116 mItems.remove( static_cast<QgsComposerItem*>( sender() ) );
134 QPointF newOrigin = mapFromScene( rectangle.topLeft() );
135 QRectF newRect = QRectF( newOrigin.x(), newOrigin.y(), rectangle.width(), rectangle.height() );
137 QSet<QgsComposerItem*>::iterator item_it = mItems.begin();
138 for ( ; item_it != mItems.end(); ++item_it )
141 QRectF itemRect = mapRectFromItem(( *item_it ), ( *item_it )->rect() );
144 QPointF newPos = mapToScene( itemRect.topLeft() );
145 ( *item_it )->setSceneRect( QRectF( newPos.x(), newPos.y(), itemRect.width(), itemRect.height() ) );
154 QSet<QgsComposerItem*>::iterator item_it = mItems.begin();
155 for ( ; item_it != mItems.end(); ++item_it )
157 ( *item_it )->setVisibility( visible );
172 QPen newPen( pen() );
173 newPen.setStyle( Qt::DashLine );
174 newPen.setColor( QColor( 128, 128, 128, 128 ) );
176 p->setRenderHint( QPainter::Antialiasing,
true );
177 p->drawRect( QRectF( 0, 0, rect().width(), rect().height() ) );
183 QDomElement group = doc.createElement(
"ComposerItemGroup" );
185 QSet<QgsComposerItem*>::const_iterator itemIt = mItems.begin();
186 for ( ; itemIt != mItems.end(); ++itemIt )
188 QDomElement item = doc.createElement(
"ComposerItemGroupElement" );
189 item.setAttribute(
"uuid", ( *itemIt )->uuid() );
190 group.appendChild( item );
193 elem.appendChild( group );
201 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
202 if ( composerItemList.size() > 0 )
204 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
210 QDomNodeList elementNodes = itemElem.elementsByTagName(
"ComposerItemGroupElement" );
211 for (
int i = 0; i < elementNodes.count(); ++i )
213 QDomNode elementNode = elementNodes.at( i );
214 if ( !elementNode.isElement() )
217 QString
uuid = elementNode.toElement().attribute(
"uuid" );
219 for ( QList<QGraphicsItem *>::iterator it = items.begin(); it != items.end(); ++it )
222 if ( item && ( item->mUuid == uuid || item->mTemplateUuid == uuid ) )
static void relativeResizeRect(QRectF &rectToResize, const QRectF &boundsBefore, const QRectF &boundsAfter)
Resizes a QRectF relative to a resized bounding rectangle.
QgsComposerModel * itemsModel()
Returns the items model attached to the composition.
void removeItems() override
Removes the items but does not delete them.
A item that forms part of a map composition.
void drawFrame(QPainter *p) override
Draw black frame around item.
virtual void setSelected(bool s)
Set selected, selected item should be highlighted.
double itemRotation(const QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue) const
Returns the current rotation for the composer item.
QSet< QgsComposerItem * > items()
bool _readXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads parameter that are not subclass specific in document.
QgsComposerItemGroup(QgsComposition *c)
QString uuid() const
Get item identification name.
virtual void setVisibility(const bool visible) override
Sets visibility for item.
virtual void drawSelectionBoxes(QPainter *p)
Draws additional graphics on selected items.
bool mFrame
True if item fram needs to be painted.
void addItem(QgsComposerItem *item) override
Adds an item to the group.
Graphics scene for map printing.
QgsComposition * mComposition
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
sets state from Dom document
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document.
virtual void setItemRotation(const double r, const bool adjustPosition=false)
Sets the item rotation.
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...
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...
bool writeXML(QDomElement &elem, QDomDocument &doc) const override
stores state in Dom node
void setIsGroupMember(const bool isGroupMember)
Sets whether this item is part of a group.
void setItemRemoved(QgsComposerItem *item)
Marks an item as removed from the composition.
QgsComposition::PlotStyle plotStyle() const
virtual void setVisibility(const bool visible)
Sets visibility for item.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) override
Draw outline and ev.