QGIS API Documentation  2.99.0-Master (ae4d26a)
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 "qgis.h"
21 #include "qgscomposerobject.h"
22 #include <QObject>
23 #include <QSizeF>
24 #include <QPointF>
25 
26 class QgsComposerFrame;
27 class QgsComposerItem;
28 class QgsComposition;
29 class QDomDocument;
30 class QDomElement;
31 class QRectF;
32 class QPainter;
33 
34 
35 #ifdef SIP_RUN
36 % ModuleHeaderCode
37 #include <qgscomposerhtml.h>
38 #include <qgscomposertablev2.h>
40 % End
41 #endif
42 
50 class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
51 {
52 
53 #ifdef SIP_RUN
55  if ( dynamic_cast<QgsComposerHtml *>( sipCpp ) != NULL )
56  sipType = sipType_QgsComposerHtml;
57  else if ( dynamic_cast<QgsComposerAttributeTableV2 *>( sipCpp ) != NULL )
58  sipType = sipType_QgsComposerAttributeTableV2;
59  else if ( dynamic_cast<QgsComposerTableV2 *>( sipCpp ) != NULL )
60  sipType = sipType_QgsComposerTableV2;
61  else if ( dynamic_cast<QgsComposerMultiFrame *>( sipCpp ) != NULL )
62  sipType = sipType_QgsComposerMultiFrame;
63  else
64  sipType = NULL;
65  SIP_END
66 #endif
67 
68  Q_OBJECT
69 
70  public:
71 
76  {
77  UseExistingFrames = 0,
80  RepeatUntilFinished
82  };
83 
89  QgsComposerMultiFrame( QgsComposition *c SIP_TRANSFERTHIS, bool createUndoCommands );
90 
91  virtual ~QgsComposerMultiFrame();
92 
97  virtual QSizeF totalSize() const = 0;
98 
110  virtual QSizeF fixedFrameSize( const int frameIndex = -1 ) const;
111 
123  virtual QSizeF minFrameSize( const int frameIndex = -1 ) const;
124 
132  virtual void render( QPainter *painter, const QRectF &renderExtent, const int frameIndex ) = 0;
133 
140  virtual void addFrame( QgsComposerFrame *frame SIP_TRANSFER, bool recalcFrameSizes = true ) = 0;
141 
149  virtual double findNearbyPageBreak( double yPos );
150 
159  void removeFrame( int i, const bool removeEmptyPages = false );
160 
165  void deleteFrames();
166 
172  void setResizeMode( ResizeMode mode );
173 
179  ResizeMode resizeMode() const { return mResizeMode; }
180 
189  virtual bool writeXml( QDomElement &elem, QDomDocument &doc, bool ignoreFrames = false ) const = 0;
190 
199  bool _writeXml( QDomElement &elem, QDomDocument &doc, bool ignoreFrames = false ) const;
200 
209  virtual bool readXml( const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames = false ) = 0;
210 
219  bool _readXml( const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames = false );
220 
226 
232  bool createUndoCommands() const { return mCreateUndoCommands; }
233 
239  void setCreateUndoCommands( bool enabled ) { mCreateUndoCommands = enabled; }
240 
245  int frameCount() const { return mFrameItems.size(); }
246 
253  QgsComposerFrame *frame( int i ) const;
254 
262  int frameIndex( QgsComposerFrame *frame ) const;
263 
273  QgsComposerFrame *createNewFrame( QgsComposerFrame *currentFrame, QPointF pos, QSizeF size );
274 
280  virtual QString displayName() const;
281 
282  public slots:
283 
287  void update();
288 
296  virtual void recalculateFrameSizes();
297 
307  void recalculateFrameRects();
308 
313  void handleFrameRemoval( QgsComposerItem *item );
314 
315  signals:
316 
321  void changed();
322 
327  void contentsChanged();
328 
329  protected:
330 
331  QList<QgsComposerFrame *> mFrameItems;
332 
333  ResizeMode mResizeMode = UseExistingFrames;
334 
336  bool mCreateUndoCommands = false;
337 
338  protected slots:
339 
343  void handlePageChange();
344 
345  private:
346  QgsComposerMultiFrame(); //forbidden
347 
348  bool mIsRecalculatingSize = false;
349 };
350 
351 #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.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_END
Definition: qgis_sip.h:175
Graphics scene for map printing.
Frame item for a composer multiframe item.
QgsComposition * mComposition
int frameCount() const
Returns the number of frames associated with this multiframe.
QgsComposition * composition()
Returns the parent composition for the multiframe.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:165
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.