QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerhtml.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerhtml.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 QGSCOMPOSERHTML_H
17 #define QGSCOMPOSERHTML_H
18 
19 #include "qgscomposermultiframe.h"
20 #include <QUrl>
21 
22 class QWebPage;
23 class QImage;
24 
25 class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
26 {
27  Q_OBJECT
28  public:
29  QgsComposerHtml( QgsComposition* c, bool createUndoCommands );
31  ~QgsComposerHtml();
32 
33  void setUrl( const QUrl& url );
34  const QUrl& url() const { return mUrl; }
35 
36  QSizeF totalSize() const;
37  void render( QPainter* p, const QRectF& renderExtent );
38 
39  bool writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames = false ) const;
40  bool readXML( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false );
41 
42  void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true );
43 
44  //overriden to break frames without dividing lines of text
45  double findNearbyPageBreak( double yPos );
46 
52  bool useSmartBreaks() const { return mUseSmartBreaks; }
53 
60  void setUseSmartBreaks( bool useSmartBreaks );
61 
74  void setMaxBreakDistance( double maxBreakDistance );
75 
85  double maxBreakDistance() const { return mMaxBreakDistance; }
86 
87  public slots:
88 
93  void loadHtml();
94 
95  private slots:
96  void frameLoaded( bool ok );
97 
98  private:
99  QUrl mUrl;
100  QWebPage* mWebPage;
101  bool mLoaded;
102  QSizeF mSize; //total size in mm
104  QImage* mRenderedPage;
107 
108  double htmlUnitsToMM(); //calculate scale factor
109 
110  //renders a snapshot of the page to a cached image
111  void renderCachedImage();
112 };
113 
114 #endif // QGSCOMPOSERHTML_H
QWebPage * mWebPage
virtual void render(QPainter *p, const QRectF &renderExtent)=0
virtual double findNearbyPageBreak(double yPos)
Finds the optimal position to break a frame at.
virtual QSizeF totalSize() const =0
bool useSmartBreaks() const
Returns whether html item is using smart breaks.
virtual void addFrame(QgsComposerFrame *frame, bool recalcFrameSizes=true)=0
QImage * mRenderedPage
Abstract base class for composer entries with the ability to distribute the content to several frames...
Graphics scene for map printing.
Frame for html, table, text which can be divided onto several frames.
const QUrl & url() const
virtual bool writeXML(QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const =0
double maxBreakDistance() const
Returns the maximum distance allowed when calculating where to place page breaks in the html...
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false)=0