QGIS API Documentation  2.99.0-Master (f867b65)
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 
75  {
76  UseExistingFrames = 0,
79  RepeatUntilFinished
81  };
82 
87  QgsComposerMultiFrame( QgsComposition *c SIP_TRANSFERTHIS, bool createUndoCommands );
88 
89  virtual ~QgsComposerMultiFrame();
90 
94  virtual QSizeF totalSize() const = 0;
95 
106  virtual QSizeF fixedFrameSize( const int frameIndex = -1 ) const;
107 
118  virtual QSizeF minFrameSize( const int frameIndex = -1 ) const;
119 
126  virtual void render( QPainter *painter, const QRectF &renderExtent, const int frameIndex ) = 0;
127 
133  virtual void addFrame( QgsComposerFrame *frame SIP_TRANSFER, bool recalcFrameSizes = true ) = 0;
134 
141  virtual double findNearbyPageBreak( double yPos );
142 
150  void removeFrame( int i, const bool removeEmptyPages = false );
151 
155  void deleteFrames();
156 
161  void setResizeMode( ResizeMode mode );
162 
167  ResizeMode resizeMode() const { return mResizeMode; }
168 
176  virtual bool writeXml( QDomElement &elem, QDomDocument &doc, bool ignoreFrames = false ) const = 0;
177 
185  bool _writeXml( QDomElement &elem, QDomDocument &doc, bool ignoreFrames = false ) const;
186 
194  virtual bool readXml( const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames = false ) = 0;
195 
203  bool _readXml( const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames = false );
204 
209 
214  bool createUndoCommands() const { return mCreateUndoCommands; }
215 
220  void setCreateUndoCommands( bool enabled ) { mCreateUndoCommands = enabled; }
221 
225  int frameCount() const { return mFrameItems.size(); }
226 
232  QgsComposerFrame *frame( int i ) const;
233 
240  int frameIndex( QgsComposerFrame *frame ) const;
241 
250  QgsComposerFrame *createNewFrame( QgsComposerFrame *currentFrame, QPointF pos, QSizeF size );
251 
256  virtual QString displayName() const;
257 
258  public slots:
259 
262  void update();
263 
270  virtual void recalculateFrameSizes();
271 
280  void recalculateFrameRects();
281 
285  void handleFrameRemoval( QgsComposerItem *item );
286 
287  signals:
288 
292  void changed();
293 
297  void contentsChanged();
298 
299  protected:
300 
301  QList<QgsComposerFrame *> mFrameItems;
302 
304 
307 
308  protected slots:
309 
312  void handlePageChange();
313 
314  private:
315  QgsComposerMultiFrame(); //forbidden
316 
317  bool mIsRecalculatingSize;
318 };
319 
320 #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.
bool mCreateUndoCommands
True: creates QgsMultiFrameCommands on internal changes (e.g. changing frames )
#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.