QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerframe.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerframe.cpp
3  ------------------------------------------------------------
4  begin : July 2012
5  copyright : (C) 2012 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgscomposerframe.h"
17 #include "qgscomposermultiframe.h"
18 #include "qgscomposition.h"
19 
20 QgsComposerFrame::QgsComposerFrame( QgsComposition* c, QgsComposerMultiFrame* mf, qreal x, qreal y, qreal width, qreal height )
21  : QgsComposerItem( x, y, width, height, c )
22  , mMultiFrame( mf )
23 {
24 }
25 
27  : QgsComposerItem( 0, 0, 0, 0, 0 )
28  , mMultiFrame( 0 )
29 {
30 }
31 
33 {
34 }
35 
36 bool QgsComposerFrame::writeXML( QDomElement& elem, QDomDocument & doc ) const
37 {
38  QDomElement frameElem = doc.createElement( "ComposerFrame" );
39  frameElem.setAttribute( "sectionX", QString::number( mSection.x() ) );
40  frameElem.setAttribute( "sectionY", QString::number( mSection.y() ) );
41  frameElem.setAttribute( "sectionWidth", QString::number( mSection.width() ) );
42  frameElem.setAttribute( "sectionHeight", QString::number( mSection.height() ) );
43  elem.appendChild( frameElem );
44  return _writeXML( frameElem, doc );
45 }
46 
47 bool QgsComposerFrame::readXML( const QDomElement& itemElem, const QDomDocument& doc )
48 {
49  double x = itemElem.attribute( "sectionX" ).toDouble();
50  double y = itemElem.attribute( "sectionY" ).toDouble();
51  double width = itemElem.attribute( "sectionWidth" ).toDouble();
52  double height = itemElem.attribute( "sectionHeight" ).toDouble();
53  mSection = QRectF( x, y, width, height );
54  QDomElement composerItem = itemElem.firstChildElement( "ComposerItem" );
55  if ( composerItem.isNull() )
56  {
57  return false;
58  }
59  return _readXML( composerItem, doc );
60 }
61 
62 void QgsComposerFrame::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
63 {
64  Q_UNUSED( itemStyle );
65  Q_UNUSED( pWidget );
66 
67  if ( !painter )
68  {
69  return;
70  }
71 
72  drawBackground( painter );
73  if ( mMultiFrame )
74  {
75  mMultiFrame->render( painter, mSection );
76  }
77 
78  drawFrame( painter );
79  if ( isSelected() )
80  {
81  drawSelectionBoxes( painter );
82  }
83 }
84 
85 void QgsComposerFrame::beginItemCommand( const QString& text )
86 {
87  if ( mComposition )
88  {
90  }
91 }
92 
94 {
95  if ( mComposition )
96  {
98  }
99 }