QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
205  int frameCount() const { return mFrameItems.size(); }
206 
212  QgsComposerFrame* frame( int i ) const;
213 
220  int frameIndex( QgsComposerFrame *frame ) const;
221 
230  QgsComposerFrame* createNewFrame( QgsComposerFrame* currentFrame, QPointF pos, QSizeF size );
231 
236  virtual QString displayName() const;
237 
238  public slots:
239 
242  void update();
243 
250  virtual void recalculateFrameSizes();
251 
260  void recalculateFrameRects();
261 
262  signals:
263 
267  void changed();
268 
272  void contentsChanged();
273 
274  protected:
275 
276  QList<QgsComposerFrame*> mFrameItems;
277 
279 
282 
283  protected slots:
284 
288  void handleFrameRemoval( QgsComposerItem* item );
289 
292  void handlePageChange();
293 
294  private:
295  QgsComposerMultiFrame(); //forbidden
296 
297  bool mIsRecalculatingSize;
298 };
299 
300 #endif // QGSCOMPOSERMULTIFRAME_H