QGIS API Documentation  2.99.0-Master (8ec3eaf)
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 
99  virtual void render( QPainter* painter, const QRectF& renderExtent, const int frameIndex ) = 0;
100 
106  virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true ) = 0;
107 
114  virtual double findNearbyPageBreak( double yPos ) { return yPos; }
115 
123  void removeFrame( int i, const bool removeEmptyPages = false );
124 
128  void deleteFrames();
129 
134  void setResizeMode( ResizeMode mode );
135 
140  ResizeMode resizeMode() const { return mResizeMode; }
141 
149  virtual bool writeXml( QDomElement& elem, QDomDocument & doc, bool ignoreFrames = false ) const = 0;
150 
158  bool _writeXml( QDomElement& elem, QDomDocument& doc, bool ignoreFrames = false ) const;
159 
167  virtual bool readXml( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false ) = 0;
168 
176  bool _readXml( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false );
177 
182 
187  bool createUndoCommands() const { return mCreateUndoCommands; }
188 
193  void setCreateUndoCommands( bool enabled ) { mCreateUndoCommands = enabled; }
194 
198  int frameCount() const { return mFrameItems.size(); }
199 
205  QgsComposerFrame* frame( int i ) const;
206 
213  int frameIndex( QgsComposerFrame *frame ) const;
214 
223  QgsComposerFrame* createNewFrame( QgsComposerFrame* currentFrame, QPointF pos, QSizeF size );
224 
229  virtual QString displayName() const;
230 
231  public slots:
232 
235  void update();
236 
243  virtual void recalculateFrameSizes();
244 
253  void recalculateFrameRects();
254 
255  signals:
256 
260  void changed();
261 
265  void contentsChanged();
266 
267  protected:
268 
269  QList<QgsComposerFrame*> mFrameItems;
270 
272 
275 
276  protected slots:
277 
281  void handleFrameRemoval( QgsComposerItem* item );
282 
285  void handlePageChange();
286 
287  private:
288  QgsComposerMultiFrame(); //forbidden
289 
290  bool mIsRecalculatingSize;
291 };
292 
293 #endif // QGSCOMPOSERMULTIFRAME_H
ResizeMode
Specifies the behaviour 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.
QList< QgsComposerFrame * > mFrameItems
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.
virtual bool writeXml(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.
ResizeMode resizeMode() const
Returns the resize mode for the multiframe.