QGIS API Documentation  2.99.0-Master (314842d)
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 "qgis_core.h"
20 #include "qgscomposerobject.h"
21 #include <QObject>
22 #include <QSizeF>
23 #include <QPointF>
24 
25 class QgsComposerFrame;
26 class QgsComposerItem;
27 class QgsComposition;
28 class QDomDocument;
29 class QDomElement;
30 class QRectF;
31 class QPainter;
32 
40 class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
41 {
42  Q_OBJECT
43 
44  public:
45 
49  {
50  UseExistingFrames = 0,
53  RepeatUntilFinished
55  };
56 
61  QgsComposerMultiFrame( QgsComposition *c, bool createUndoCommands );
62 
63  virtual ~QgsComposerMultiFrame();
64 
68  virtual QSizeF totalSize() const = 0;
69 
80  virtual QSizeF fixedFrameSize( const int frameIndex = -1 ) const { Q_UNUSED( frameIndex ); return QSizeF( 0, 0 ); }
81 
92  virtual QSizeF minFrameSize( const int frameIndex = -1 ) const { Q_UNUSED( frameIndex ); return QSizeF( 0, 0 ); }
93 
100  virtual void render( QPainter *painter, const QRectF &renderExtent, const int frameIndex ) = 0;
101 
107  virtual void addFrame( QgsComposerFrame *frame, bool recalcFrameSizes = true ) = 0;
108 
115  virtual double findNearbyPageBreak( double yPos ) { return yPos; }
116 
124  void removeFrame( int i, const bool removeEmptyPages = false );
125 
129  void deleteFrames();
130 
135  void setResizeMode( ResizeMode mode );
136 
141  ResizeMode resizeMode() const { return mResizeMode; }
142 
150  virtual bool writeXml( QDomElement &elem, QDomDocument &doc, bool ignoreFrames = false ) const = 0;
151 
159  bool _writeXml( QDomElement &elem, QDomDocument &doc, bool ignoreFrames = false ) const;
160 
168  virtual bool readXml( const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames = false ) = 0;
169 
177  bool _readXml( const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames = false );
178 
183 
188  bool createUndoCommands() const { return mCreateUndoCommands; }
189 
194  void setCreateUndoCommands( bool enabled ) { mCreateUndoCommands = enabled; }
195 
199  int frameCount() const { return mFrameItems.size(); }
200 
206  QgsComposerFrame *frame( int i ) const;
207 
214  int frameIndex( QgsComposerFrame *frame ) const;
215 
224  QgsComposerFrame *createNewFrame( QgsComposerFrame *currentFrame, QPointF pos, QSizeF size );
225 
230  virtual QString displayName() const;
231 
232  public slots:
233 
236  void update();
237 
244  virtual void recalculateFrameSizes();
245 
254  void recalculateFrameRects();
255 
259  void handleFrameRemoval( QgsComposerItem *item );
260 
261  signals:
262 
266  void changed();
267 
271  void contentsChanged();
272 
273  protected:
274 
275  QList<QgsComposerFrame *> mFrameItems;
276 
278 
281 
282  protected slots:
283 
286  void handlePageChange();
287 
288  private:
289  QgsComposerMultiFrame(); //forbidden
290 
291  bool mIsRecalculatingSize;
292 };
293 
294 #endif // QGSCOMPOSERMULTIFRAME_H
ResizeMode
Specifies the behavior for creating new frames to fit the multiframe&#39;s content.
A base class for objects which belong to a map composition.
virtual double findNearbyPageBreak(double yPos)
Finds the optimal position to break a frame at.
A item that forms part of a map composition.
Creates new full page frames on the following page(s) until the entire multiframe content is visible...
void setCreateUndoCommands(bool enabled)
Sets whether undo commands should be created for interactions with the multiframe.
virtual bool readXml(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
bool createUndoCommands() const
Returns whether undo commands should be created for interactions with the multiframe.
Abstract base class for composer items with the ability to distribute the content to several frames (...
Repeats the same frame on every page.
bool mCreateUndoCommands
True: creates QgsMultiFrameCommands on internal changes (e.g. changing frames )
Graphics scene for map printing.
Frame item for a composer multiframe item.
QgsComposition * mComposition
virtual QSizeF minFrameSize(const int frameIndex=-1) const
Returns the minimum size for a frames, if desired.
int frameCount() const
Returns the number of frames associated with this multiframe.
QgsComposition * composition()
Returns the parent composition for the multiframe.
virtual QSizeF fixedFrameSize(const int frameIndex=-1) const
Returns the fixed size for a frame, if desired.
QList< QgsComposerFrame * > mFrameItems
virtual bool writeXml(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.
ResizeMode resizeMode() const
Returns the resize mode for the multiframe.