Skip to content
Permalink
Browse files

[composer] Add refresh button to html items, to reload the html sourc…

…e from the url.
  • Loading branch information
nyalldawson committed May 1, 2014
1 parent 79ab952 commit 8eb929aeda2e185a0cab340d52e518609178e856
@@ -10,7 +10,7 @@ class QgsComposerHtml: QgsComposerMultiFrame
~QgsComposerHtml();

void setUrl( const QUrl& url );
const QUrl& url() const;
const QUrl& url() const;

QSizeF totalSize() const;
void render( QPainter* p, const QRectF& renderExtent );
@@ -34,4 +34,12 @@ class QgsComposerHtml: QgsComposerMultiFrame
* @see useSmartBreaks
*/
void setUseSmartBreaks( bool useSmartBreaks );

public slots:

/**Reloads the html source from the url and redraws the item.
* @see setUrl
* @see url
*/
void loadHtml();
};
@@ -133,6 +133,16 @@ void QgsComposerHtmlWidget::on_mUseSmartBreaksCheckBox_stateChanged( int state )
}
}

void QgsComposerHtmlWidget::on_mReloadPushButton_clicked()
{
if ( !mHtml )
{
return;
}

mHtml->loadHtml();
}

void QgsComposerHtmlWidget::setGuiElementValues()
{
if ( !mHtml )
@@ -32,6 +32,7 @@ class QgsComposerHtmlWidget: public QWidget, private Ui::QgsComposerHtmlWidgetBa
void on_mFileToolButton_clicked();
void on_mResizeModeComboBox_currentIndexChanged( int index );
void on_mUseSmartBreaksCheckBox_stateChanged( int state );
void on_mReloadPushButton_clicked();

/**Sets the GUI elements to the values of mHtmlItem*/
void setGuiElementValues();
@@ -60,9 +60,19 @@ void QgsComposerHtml::setUrl( const QUrl& url )
{
return;
}
mLoaded = false;

mUrl = url;
loadHtml();
}

void QgsComposerHtml::loadHtml()
{
if ( !mWebPage || mUrl.isEmpty() )
{
return;
}

mLoaded = false;
mWebPage->mainFrame()->load( mUrl );
while ( !mLoaded )
{
@@ -59,6 +59,14 @@ class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
*/
void setUseSmartBreaks( bool useSmartBreaks );

public slots:

/**Reloads the html source from the url and redraws the item.
* @see setUrl
* @see url
*/
void loadHtml();

private slots:
void frameLoaded( bool ok );

@@ -93,7 +93,7 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="mResizeModeLabel">
<property name="text">
<string>Resize mode</string>
@@ -103,16 +103,23 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QComboBox" name="mResizeModeComboBox"/>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="mUseSmartBreaksCheckBox">
<property name="text">
<string>Use smart page breaks</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="mReloadPushButton">
<property name="text">
<string>Refresh HTML</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

0 comments on commit 8eb929a

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