QGIS API Documentation  2.5.0-Master
 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 
33 class CORE_EXPORT QgsComposerMultiFrame: public QgsComposerObject
34 {
35  Q_OBJECT
36  public:
37 
39  {
40  UseExistingFrames = 0,
41  ExtendToNextPage, //uses the next page(s) until the content has been printed
42  RepeatOnEveryPage, //repeats the same frame on every page
43  RepeatUntilFinished //duplicates last frame to next page to fit the total size
44  };
45 
46  QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands );
47  virtual ~QgsComposerMultiFrame();
48  virtual QSizeF totalSize() const = 0;
49  virtual void render( QPainter* p, const QRectF& renderExtent ) = 0;
50 
51  virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true ) = 0;
52 
58  virtual double findNearbyPageBreak( double yPos ) { return yPos; }
59 
60  void removeFrame( int i );
61 
62  void update();
63 
64  void setResizeMode( ResizeMode mode );
65  ResizeMode resizeMode() const { return mResizeMode; }
66 
67  virtual bool writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames = false ) const = 0;
68  bool _writeXML( QDomElement& elem, QDomDocument& doc, bool ignoreFrames = false ) const;
69 
70  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false ) = 0;
71  bool _readXML( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false );
72 
74 
75  bool createUndoCommands() const { return mCreateUndoCommands; }
76  void setCreateUndoCommands( bool enabled ) { mCreateUndoCommands = enabled; }
77 
79  void deleteFrames();
80 
84  int frameCount() const { return mFrameItems.size(); }
85  QgsComposerFrame* frame( int i ) const;
86 
95  QgsComposerFrame* createNewFrame( QgsComposerFrame* currentFrame, QPointF pos, QSizeF size );
96 
101  virtual QString displayName() const;
102 
103  public slots:
104 
110  void recalculateFrameSizes();
111 
112  protected:
113  QList<QgsComposerFrame*> mFrameItems;
117 
118  protected slots:
120  void handleFrameRemoval( QgsComposerItem* item );
122  void handlePageChange();
123 
124  private:
125  QgsComposerMultiFrame(); //forbidden
126 
128 
129  signals:
130  void changed();
131 
135  void contentsChanged();
136 };
137 
138 #endif // QGSCOMPOSERMULTIFRAME_H
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.
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.
ResizeMode resizeMode() const
void setCreateUndoCommands(bool enabled)
Abstract base class for composer entries with the ability to distribute the content to several frames...
QList< QgsComposerFrame * > mFrameItems
bool mCreateUndoCommands
True: creates QgsMultiFrameCommands on internal changes (e.g.
int frameCount() const
Return the number of frames associated with this multiframeset.
Graphics scene for map printing.
Frame for html, table, text which can be divided onto several frames.
QgsComposition * mComposition
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
QgsComposition * composition()
double size
Definition: qgssvgcache.cpp:77