Skip to content
Permalink
Browse files

- extend support for user defined network timeout to QgsNetworkAccess…

…Manager

- support for user defined tile expiration time for WMTS/WMS-C tiles (fixes #5104)
  • Loading branch information
jef-n committed Aug 18, 2012
1 parent 804f253 commit bb623a8c94e49ed478f736a58df49732edd338b4
Showing with 61 additions and 20 deletions.
  1. +6 −0 src/app/qgsoptions.cpp
  2. +10 −0 src/core/qgsnetworkaccessmanager.cpp
  3. +7 −0 src/providers/wms/qgswmsprovider.cpp
  4. +38 −20 src/ui/qgsoptionsbase.ui
@@ -136,6 +136,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
//Network timeout
mNetworkTimeoutSpinBox->setValue( settings.value( "/qgis/networkAndProxy/networkTimeout", "60000" ).toInt() );

// WMS/WMS-C tile expiry time
mDefaultTileExpirySpinBox->setValue( settings.value( "/qgis/defaultTileExpiry", "24" ).toInt() );

//Web proxy settings
grpProxy->setChecked( settings.value( "proxy/proxyEnabled", "0" ).toBool() );
leProxyHost->setText( settings.value( "proxy/proxyHost", "" ).toString() );
@@ -768,6 +771,9 @@ void QgsOptions::saveOptions()
//Network timeout
settings.setValue( "/qgis/networkAndProxy/networkTimeout", mNetworkTimeoutSpinBox->value() );

// WMS/WMS-C tile expiry time
settings.setValue( "/qgis/defaultTileExpiry", mDefaultTileExpirySpinBox->value() );

//Web proxy settings
settings.setValue( "proxy/proxyEnabled", grpProxy->isChecked() );
settings.setValue( "proxy/proxyHost", leProxyHost->text() );
@@ -23,6 +23,9 @@
#include <qgslogger.h>

#include <QUrl>
#include <QSettings>
#include <QTimer>
#include <QNetworkReply>

#if QT_VERSION >= 0x40500
class QgsNetworkProxyFactory : public QNetworkProxyFactory
@@ -126,5 +129,12 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
emit requestAboutToBeCreated( op, req, outgoingData );
QNetworkReply *reply = QNetworkAccessManager::createRequest( op, req, outgoingData );
emit requestCreated( reply );

// abort request, when network timeout happens
QTimer *timer = new QTimer( reply );

QSettings s;
timer->singleShot( s.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt(), reply, SLOT( abort() ) );

return reply;
}
@@ -981,6 +981,13 @@ void QgsWmsProvider::tileReplyFinished()
}
cmd.setRawHeaders( hl );

QgsDebugMsg( QString( "expirationDate:%1" ).arg( cmd.expirationDate().toString() ) );
if( cmd.expirationDate().isNull() )
{
QSettings s;
cmd.setExpirationDate( QDateTime::currentDateTime().addSecs( s.value( "/qgis/defaultTileExpiry", "24" ).toInt() * 60 * 60 ) );
}

QgsNetworkAccessManager::instance()->cache()->updateMetaData( cmd );

int tileReqNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ) ).toInt();
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>807</width>
<height>673</height>
<width>810</width>
<height>674</height>
</rect>
</property>
<property name="windowTitle">
@@ -66,8 +66,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>773</width>
<height>938</height>
<width>784</width>
<height>1099</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
@@ -948,9 +948,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-169</y>
<width>938</width>
<height>785</height>
<y>0</y>
<width>1201</width>
<height>850</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_8">
@@ -1464,8 +1464,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>773</width>
<height>718</height>
<width>646</width>
<height>778</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
@@ -1834,8 +1834,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>791</width>
<height>599</height>
<width>317</width>
<height>91</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_10">
@@ -1915,8 +1915,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>791</width>
<height>599</height>
<width>679</width>
<height>642</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_13">
@@ -2291,8 +2291,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>791</width>
<height>599</height>
<width>745</width>
<height>431</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
@@ -2478,8 +2478,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>791</width>
<height>599</height>
<width>519</width>
<height>575</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_17">
@@ -2575,8 +2575,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>791</width>
<height>599</height>
<width>589</width>
<height>582</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_20">
@@ -2768,7 +2768,7 @@
</item>
</layout>
</item>
<item row="3" column="0">
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="mNetworkTimeoutLabel">
@@ -2786,6 +2786,24 @@
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_32">
<property name="text">
<string>Default expiration period for WMS-C/WMTS tiles (hours)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mDefaultTileExpirySpinBox">
<property name="maximum">
<number>100000000</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>

0 comments on commit bb623a8

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