Skip to content
Permalink
Browse files

Save html multiframe

  • Loading branch information
mhugent committed Jul 30, 2012
1 parent d57ecae commit 0e5e3679391bf33f14e3622cc403ac030a270002
@@ -1136,15 +1136,6 @@ void QgsComposer::writeXML( QDomNode& parentNode, QDomDocument& doc )
}
parentNode.appendChild( composerElem );

//store composer items:
QMap<QgsComposerItem*, QWidget*>::const_iterator itemIt = mItemWidgetMap.constBegin();
for ( ; itemIt != mItemWidgetMap.constEnd(); ++itemIt )
{
itemIt.key()->writeXML( composerElem, doc );
}

//store composer view

//store composition
if ( mComposition )
{
@@ -36,6 +36,8 @@ class QgsComposerFrame: public QgsComposerItem
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );

int type() const { return ComposerFrame; }

private:
QgsComposerFrame(); //forbidden

@@ -113,3 +113,12 @@ void QgsComposerHtml::addFrame( QgsComposerFrame* frame )
mComposition->addComposerHtmlFrame( this, frame );
}
}

bool QgsComposerHtml::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
QDomElement htmlElem = doc.createElement( "ComposerHtml" );
htmlElem.setAttribute( "url", mUrl.toString() );
bool state = _writeXML( htmlElem, doc );
elem.appendChild( htmlElem );
return state;
}
@@ -35,6 +35,8 @@ class QgsComposerHtml: public QgsComposerMultiFrame
QSizeF totalSize() const;
void render( QPainter* p, const QRectF& renderExtent );

bool writeXML( QDomElement& elem, QDomDocument & doc ) const;

protected:
void addFrame( QgsComposerFrame* frame );

@@ -52,7 +52,8 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
ComposerShape,
ComposerTable,
ComposerAttributeTable,
ComposerTextTable
ComposerTextTable,
ComposerFrame
};

/**Describes the action (move or resize in different directon) to be done during mouse move*/
@@ -148,3 +148,14 @@ void QgsComposerMultiFrame::update()
( *frameIt )->update();
}
}

bool QgsComposerMultiFrame::_writeXML( QDomElement& elem, QDomDocument& doc ) const
{
elem.setAttribute( "resizeMode", mResizeMode );
QList<QgsComposerFrame*>::const_iterator frameIt = mFrameItems.constBegin();
for ( ; frameIt != mFrameItems.constEnd(); ++frameIt )
{
( *frameIt )->writeXML( elem, doc );
}
return true;
}
@@ -22,6 +22,8 @@
class QgsComposerFrame;
class QgsComposerItem;
class QgsComposition;
class QDomDocument;
class QDomElement;
class QRectF;
class QPainter;

@@ -48,6 +50,9 @@ class QgsComposerMultiFrame: public QObject
void setResizeMode( ResizeMode mode );
ResizeMode resizeMode() const { return mResizeMode; }

virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0;
bool _writeXML( QDomElement& elem, QDomDocument& doc ) const;

protected:
QgsComposition* mComposition;
QList<QgsComposerFrame*> mFrameItems;
@@ -238,6 +238,28 @@ bool QgsComposition::writeXML( QDomElement& composerElem, QDomDocument& doc )
compositionElem.setAttribute( "printResolution", mPrintResolution );
compositionElem.setAttribute( "printAsRaster", mPrintAsRaster );

//save items except paper items and frame items (they are saved with the corresponding multiframe)
QList<QGraphicsItem*> itemList = items();
QList<QGraphicsItem*>::const_iterator itemIt = itemList.constBegin();
for ( ; itemIt != itemList.constEnd(); ++itemIt )
{
const QgsComposerItem* composerItem = dynamic_cast<const QgsComposerItem*>( *itemIt );
if ( composerItem )
{
if ( composerItem->type() != QgsComposerItem::ComposerPaper && composerItem->type() != QgsComposerItem::ComposerFrame )
{
composerItem->writeXML( compositionElem, doc );
}
}
}

//save multiframes
QSet<QgsComposerMultiFrame*>::const_iterator multiFrameIt = mMultiFrames.constBegin();
for ( ; multiFrameIt != mMultiFrames.constEnd(); ++mMultiFrameIt )
{
( *multiFrameIt )->writeXML( compositionElem, doc );
}

composerElem.appendChild( compositionElem );

return true;

0 comments on commit 0e5e367

Please sign in to comment.
You can’t perform that action at this time.