Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[composer] Fix refresh HTML item always using cached copy (fix #11747)
  • Loading branch information
nyalldawson committed Nov 27, 2014
1 parent f00db95 commit 9491851
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 3 additions & 1 deletion python/core/composer/qgscomposerhtml.sip
Expand Up @@ -183,10 +183,12 @@ class QgsComposerHtml: QgsComposerMultiFrame
public slots:

/**Reloads the html source from the url and redraws the item.
* @param useCache set to true to use a cached copy of remote html
* content
* @see setUrl
* @see url
*/
void loadHtml();
void loadHtml( const bool useCache = false );

/**Recalculates the frame sizes for the current viewport dimensions*/
void recalculateFrameSizes();
Expand Down
16 changes: 8 additions & 8 deletions src/core/composer/qgscomposerhtml.cpp
Expand Up @@ -120,7 +120,7 @@ void QgsComposerHtml::setUrl( const QUrl& url )
}

mUrl = url;
loadHtml();
loadHtml( true );
emit changed();
}

Expand All @@ -136,11 +136,11 @@ void QgsComposerHtml::setHtml( const QString html )
void QgsComposerHtml::setEvaluateExpressions( bool evaluateExpressions )
{
mEvaluateExpressions = evaluateExpressions;
loadHtml();
loadHtml( true );
emit changed();
}

void QgsComposerHtml::loadHtml()
void QgsComposerHtml::loadHtml( const bool useCache )
{
if ( !mWebPage )
{
Expand All @@ -166,7 +166,7 @@ void QgsComposerHtml::loadHtml()
{
return;
}
if ( currentUrl != mLastFetchedUrl )
if ( !( useCache && currentUrl == mLastFetchedUrl ) )
{
loadedHtml = fetchHtml( QUrl( currentUrl ) );
mLastFetchedUrl = currentUrl;
Expand Down Expand Up @@ -459,7 +459,7 @@ void QgsComposerHtml::setUserStylesheetEnabled( const bool stylesheetEnabled )
if ( mEnableUserStylesheet != stylesheetEnabled )
{
mEnableUserStylesheet = stylesheetEnabled;
loadHtml();
loadHtml( true );
emit changed();
}
}
Expand Down Expand Up @@ -518,7 +518,7 @@ bool QgsComposerHtml::readXML( const QDomElement& itemElem, const QDomDocument&
{
mUrl = urlString;
}
loadHtml();
loadHtml( true );

//since frames had to be created before, we need to emit a changed signal to refresh the widget
emit changed();
Expand Down Expand Up @@ -562,15 +562,15 @@ void QgsComposerHtml::refreshExpressionContext()
}

setExpressionContext( feature, vl );
loadHtml();
loadHtml( true );
}

void QgsComposerHtml::refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property )
{
//updates data defined properties and redraws item to match
if ( property == QgsComposerObject::SourceUrl || property == QgsComposerObject::AllProperties )
{
loadHtml();
loadHtml( true );
}
QgsComposerObject::refreshDataDefinedProperty( property );
}
4 changes: 3 additions & 1 deletion src/core/composer/qgscomposerhtml.h
Expand Up @@ -211,10 +211,12 @@ class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
public slots:

/**Reloads the html source from the url and redraws the item.
* @param useCache set to true to use a cached copy of remote html
* content
* @see setUrl
* @see url
*/
void loadHtml();
void loadHtml( const bool useCache = false );

/**Recalculates the frame sizes for the current viewport dimensions*/
void recalculateFrameSizes();
Expand Down

0 comments on commit 9491851

Please sign in to comment.