Skip to content

Commit 9491851

Browse files
committedNov 27, 2014
[composer] Fix refresh HTML item always using cached copy (fix #11747)
1 parent f00db95 commit 9491851

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed
 

‎python/core/composer/qgscomposerhtml.sip

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,12 @@ class QgsComposerHtml: QgsComposerMultiFrame
183183
public slots:
184184

185185
/**Reloads the html source from the url and redraws the item.
186+
* @param useCache set to true to use a cached copy of remote html
187+
* content
186188
* @see setUrl
187189
* @see url
188190
*/
189-
void loadHtml();
191+
void loadHtml( const bool useCache = false );
190192

191193
/**Recalculates the frame sizes for the current viewport dimensions*/
192194
void recalculateFrameSizes();

‎src/core/composer/qgscomposerhtml.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void QgsComposerHtml::setUrl( const QUrl& url )
120120
}
121121

122122
mUrl = url;
123-
loadHtml();
123+
loadHtml( true );
124124
emit changed();
125125
}
126126

@@ -136,11 +136,11 @@ void QgsComposerHtml::setHtml( const QString html )
136136
void QgsComposerHtml::setEvaluateExpressions( bool evaluateExpressions )
137137
{
138138
mEvaluateExpressions = evaluateExpressions;
139-
loadHtml();
139+
loadHtml( true );
140140
emit changed();
141141
}
142142

143-
void QgsComposerHtml::loadHtml()
143+
void QgsComposerHtml::loadHtml( const bool useCache )
144144
{
145145
if ( !mWebPage )
146146
{
@@ -166,7 +166,7 @@ void QgsComposerHtml::loadHtml()
166166
{
167167
return;
168168
}
169-
if ( currentUrl != mLastFetchedUrl )
169+
if ( !( useCache && currentUrl == mLastFetchedUrl ) )
170170
{
171171
loadedHtml = fetchHtml( QUrl( currentUrl ) );
172172
mLastFetchedUrl = currentUrl;
@@ -459,7 +459,7 @@ void QgsComposerHtml::setUserStylesheetEnabled( const bool stylesheetEnabled )
459459
if ( mEnableUserStylesheet != stylesheetEnabled )
460460
{
461461
mEnableUserStylesheet = stylesheetEnabled;
462-
loadHtml();
462+
loadHtml( true );
463463
emit changed();
464464
}
465465
}
@@ -518,7 +518,7 @@ bool QgsComposerHtml::readXML( const QDomElement& itemElem, const QDomDocument&
518518
{
519519
mUrl = urlString;
520520
}
521-
loadHtml();
521+
loadHtml( true );
522522

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

564564
setExpressionContext( feature, vl );
565-
loadHtml();
565+
loadHtml( true );
566566
}
567567

568568
void QgsComposerHtml::refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property )
569569
{
570570
//updates data defined properties and redraws item to match
571571
if ( property == QgsComposerObject::SourceUrl || property == QgsComposerObject::AllProperties )
572572
{
573-
loadHtml();
573+
loadHtml( true );
574574
}
575575
QgsComposerObject::refreshDataDefinedProperty( property );
576576
}

‎src/core/composer/qgscomposerhtml.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,12 @@ class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
211211
public slots:
212212

213213
/**Reloads the html source from the url and redraws the item.
214+
* @param useCache set to true to use a cached copy of remote html
215+
* content
214216
* @see setUrl
215217
* @see url
216218
*/
217-
void loadHtml();
219+
void loadHtml( const bool useCache = false );
218220

219221
/**Recalculates the frame sizes for the current viewport dimensions*/
220222
void recalculateFrameSizes();

0 commit comments

Comments
 (0)
Please sign in to comment.