Skip to content
Permalink
Browse files

Add QWebPage to composer html, link core to webkit

  • Loading branch information
mhugent committed Jul 24, 2012
1 parent 682d8b3 commit 4f52d9fbd678cbbd741d3478f93bb12629cb8616
@@ -282,6 +282,7 @@ SET(QGIS_CORE_MOC_HDRS
composer/qgscomposerlabel.h
composer/qgscomposershape.h
composer/qgscomposerattributetable.h
composer/qgscomposerhtml.h
composer/qgscomposermultiframe.h
composer/qgscomposition.h

@@ -520,6 +521,7 @@ TARGET_LINK_LIBRARIES(qgis_core
${QT_QTGUI_LIBRARY}
${QT_QTNETWORK_LIBRARY}
${QT_QTSVG_LIBRARY}
${QT_QTWEBKIT_LIBRARY}

${PROJ_LIBRARY}
${GEOS_LIBRARY}
@@ -14,16 +14,51 @@
***************************************************************************/

#include "qgscomposerhtml.h"
#include <QCoreApplication>
#include <QWebFrame>
#include <QWebPage>

QgsComposerHtml::QgsComposerHtml( QgsComposition* c ): QgsComposerMultiFrame( c )
QgsComposerHtml::QgsComposerHtml( QgsComposition* c ): QgsComposerMultiFrame( c ), mWebPage( 0 ), mLoaded( false )
{
mWebPage = new QWebPage();
QObject::connect( mWebPage, SIGNAL( loadFinished( bool ) ), this, SLOT( frameLoaded( bool ) ) );
}

QgsComposerHtml::QgsComposerHtml(): QgsComposerMultiFrame( 0 ), mWebPage( 0 ), mLoaded( false )
{
}

QgsComposerHtml::~QgsComposerHtml()
{
delete mWebPage;
}

void QgsComposerHtml::setUrl( const QUrl& url )
{
if ( !mWebPage )
{
return;
}

mUrl = url;
mWebPage->mainFrame()->load( mUrl );
while ( !mLoaded )
{
qApp->processEvents();
}
}

void QgsComposerHtml::frameLoaded( bool ok )
{
mLoaded = true;
}

QSizeF QgsComposerHtml::totalSize() const
{
return QSizeF(); //soon...
}

void QgsComposerHtml::render( QPainter* p, const QRectF& renderExtent )
{
//soon...
}
@@ -19,19 +19,29 @@
#include "qgscomposermultiframe.h"
#include <QUrl>

class QWebPage;

class QgsComposerHtml: public QgsComposerMultiFrame
{
Q_OBJECT
public:
QgsComposerHtml( QgsComposition* c );
QgsComposerHtml();
~QgsComposerHtml();

void setUrl( const QUrl& url ) { mUrl = url; }
void setUrl( const QUrl& url );
const QUrl& url() const { return mUrl; }

QSizeF totalSize() const;
void render( QPainter* p, const QRectF& renderExtent );

private slots:
void frameLoaded( bool ok );

private:
QUrl mUrl;
QWebPage* mWebPage;
bool mLoaded;
};

#endif // QGSCOMPOSERHTML_H
@@ -21,6 +21,8 @@

class QgsComposerItem;
class QgsComposition;
class QRectF;
class QPainter;

/**Abstract base class for composer entries with the ability to distribute the content to several frames (items)*/
class QgsComposerMultiFrame: public QObject
@@ -37,6 +39,7 @@ class QgsComposerMultiFrame: public QObject
QgsComposerMultiFrame( QgsComposition* c );
virtual ~QgsComposerMultiFrame();
virtual QSizeF totalSize() const = 0;
virtual void render( QPainter* p, const QRectF& renderExtent ) = 0;

protected:
QgsComposition* mComposition;

0 comments on commit 4f52d9f

Please sign in to comment.
You can’t perform that action at this time.