Skip to content
Permalink
Browse files
Recompute webpage viewport dimensions when resizing html frames (Fund…
…ed by Sourcepole QGIS Enterprise)
  • Loading branch information
manisandro committed Aug 25, 2014
1 parent 88b13e8 commit aaa92ccead28792e44196b52b3e5b87cf728cb4c
Showing with 18 additions and 15 deletions.
  1. +17 −14 src/core/composer/qgscomposerhtml.cpp
  2. +1 −1 src/core/composer/qgscomposerhtml.h
@@ -45,6 +45,8 @@ QgsComposerHtml::QgsComposerHtml( QgsComposition* c, bool createUndoCommands ):
{
mHtmlUnitsToMM = htmlUnitsToMM();
mWebPage = new QWebPage();
mWebPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
mWebPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
mWebPage->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
QObject::connect( mWebPage, SIGNAL( loadFinished( bool ) ), this, SLOT( frameLoaded( bool ) ) );
if ( mComposition )
@@ -181,6 +183,20 @@ void QgsComposerHtml::loadHtml()
qApp->processEvents();
}

renderCachedImage();
recalculateFrameSizes();
//trigger a repaint
emit contentsChanged();
}

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

void QgsComposerHtml::recalculateFrameSizes()
{
if ( frameCount() < 1 ) return;

QSize contentsSize = mWebPage->mainFrame()->contentsSize();
@@ -196,23 +212,10 @@ void QgsComposerHtml::loadHtml()
contentsSize.setWidth( maxFrameWidth * mHtmlUnitsToMM );

mWebPage->setViewportSize( contentsSize );
mWebPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
mWebPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
mSize.setWidth( contentsSize.width() / mHtmlUnitsToMM );
mSize.setHeight( contentsSize.height() / mHtmlUnitsToMM );

renderCachedImage();

recalculateFrameSizes();
QgsComposerMultiFrame::recalculateFrameSizes();
emit changed();
//trigger a repaint
emit contentsChanged();
}

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

void QgsComposerHtml::renderCachedImage()
@@ -214,7 +214,7 @@ class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
* @see url
*/
void loadHtml();

void recalculateFrameSizes();
void refreshExpressionContext();

virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties );

0 comments on commit aaa92cc

Please sign in to comment.