QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgscomposermultiframe.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposermultiframe.h
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 #ifndef QGSCOMPOSERMULTIFRAME_H
17 #define QGSCOMPOSERMULTIFRAME_H
18 
19 #include "qgscomposerobject.h"
20 #include <QObject>
21 #include <QSizeF>
22 #include <QPointF>
23 
24 class QgsComposerFrame;
25 class QgsComposerItem;
26 class QgsComposition;
27 class QDomDocument;
28 class QDomElement;
29 class QRectF;
30 class QPainter;
31 
39 class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
40 {
41  Q_OBJECT
42 
43  public:
44 
48  {
49  UseExistingFrames = 0,
52  RepeatUntilFinished
54  };
55 
60  QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands );
61 
62  virtual ~QgsComposerMultiFrame();
63 
67  virtual QSizeF totalSize() const = 0;
68 
79  virtual QSizeF fixedFrameSize( const int frameIndex = -1 ) const { Q_UNUSED( frameIndex ); return QSizeF( 0, 0 ); }
80 
91  virtual QSizeF minFrameSize( const int frameIndex = -1 ) const { Q_UNUSED( frameIndex ); return QSizeF( 0, 0 ); }
92 
98  Q_DECL_DEPRECATED virtual void render( QPainter* p, const QRectF& renderExtent );
99 
106  virtual void render( QPainter* painter, const QRectF& renderExtent, const int frameIndex );
107 
113  virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true ) = 0;
114 
121  virtual double findNearbyPageBreak( double yPos ) { return yPos; }
122 
130  void removeFrame( int i, const bool removeEmptyPages = false );
131 
135  void deleteFrames();
136 
141  void setResizeMode( ResizeMode mode );
142 
147  ResizeMode resizeMode() const { return mResizeMode; }
148 
156  virtual bool writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames = false ) const = 0;
157 
165  bool _writeXML( QDomElement& elem, QDomDocument& doc, bool ignoreFrames = false ) const;
166 
174  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false ) = 0;
175 
183  bool _readXML( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false );
184 
189 
194  bool createUndoCommands() const { return mCreateUndoCommands; }
195 
200  void setCreateUndoCommands( bool enabled ) { mCreateUndoCommands = enabled; }
201 
206  int frameCount() const { return mFrameItems.size(); }
207 
213  QgsComposerFrame* frame( int i ) const;
214 
221  int frameIndex( QgsComposerFrame *frame ) const;
222 
231  QgsComposerFrame* createNewFrame( QgsComposerFrame* currentFrame, QPointF pos, QSizeF size );
232 
237  virtual QString displayName() const;
238 
239  public slots:
240 
243  void update();
244 
251  virtual void recalculateFrameSizes();
252 
261  void recalculateFrameRects();
262 
263  signals:
264 
268  void changed();
269 
273  void contentsChanged();
274 
275  protected:
276 
277  QList<QgsComposerFrame*> mFrameItems;
278 
280 
283 
284  protected slots:
285 
289  void handleFrameRemoval( QgsComposerItem* item );
290 
293  void handlePageChange();
294 
295  private:
296  QgsComposerMultiFrame(); //forbidden
297 
298  bool mIsRecalculatingSize;
299 };
300 
301 #endif // QGSCOMPOSERMULTIFRAME_H
ResizeMode
Definition: qgscomposermultiframe.h:47
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.
Definition: qgscomposerobject.cpp:61
A base class for objects which belong to a map composition.
Definition: qgscomposerobject.h:33
virtual double findNearbyPageBreak(double yPos)
Finds the optimal position to break a frame at.
Definition: qgscomposermultiframe.h:121
A item that forms part of a map composition.
Definition: qgscomposeritem.h:38
ResizeMode resizeMode() const
Returns the resize mode for the multiframe.
Definition: qgscomposermultiframe.h:147
Definition: qgscomposermultiframe.h:50
void setCreateUndoCommands(bool enabled)
Sets whether undo commands should be created for interactions with the multiframe.
Definition: qgscomposermultiframe.h:200
Abstract base class for composer items with the ability to distribute the content to several frames (...
Definition: qgscomposermultiframe.h:39
Definition: qgscomposermultiframe.h:51
QList< QgsComposerFrame * > mFrameItems
Definition: qgscomposermultiframe.h:277
bool mCreateUndoCommands
True: creates QgsMultiFrameCommands on internal changes (e.g.
Definition: qgscomposermultiframe.h:282
ResizeMode mResizeMode
Definition: qgscomposermultiframe.h:279
int frameCount() const
Returns the number of frames associated with this multiframe.
Definition: qgscomposermultiframe.h:206
Graphics scene for map printing.
Definition: qgscomposition.h:73
Frame item for a composer multiframe item.
Definition: qgscomposerframe.h:25
virtual QSizeF minFrameSize(const int frameIndex=-1) const
Returns the minimum size for a frames, if desired.
Definition: qgscomposermultiframe.h:91
QgsComposition * mComposition
Definition: qgscomposerobject.h:141
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
Definition: qgscomposerobject.cpp:74
QgsComposition * composition()
Returns the parent composition for the multiframe.
Definition: qgscomposermultiframe.h:188
virtual QSizeF fixedFrameSize(const int frameIndex=-1) const
Returns the fixed size for a frame, if desired.
Definition: qgscomposermultiframe.h:79
bool createUndoCommands() const
Returns whether undo commands should be created for interactions with the multiframe.
Definition: qgscomposermultiframe.h:194
double size
Definition: qgssvgcache.cpp:77