Skip to content

Commit bb623a8

Browse files
committedAug 18, 2012
- extend support for user defined network timeout to QgsNetworkAccessManager
- support for user defined tile expiration time for WMTS/WMS-C tiles (fixes #5104)
1 parent 804f253 commit bb623a8

File tree

4 files changed

+61
-20
lines changed

4 files changed

+61
-20
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
136136
//Network timeout
137137
mNetworkTimeoutSpinBox->setValue( settings.value( "/qgis/networkAndProxy/networkTimeout", "60000" ).toInt() );
138138

139+
// WMS/WMS-C tile expiry time
140+
mDefaultTileExpirySpinBox->setValue( settings.value( "/qgis/defaultTileExpiry", "24" ).toInt() );
141+
139142
//Web proxy settings
140143
grpProxy->setChecked( settings.value( "proxy/proxyEnabled", "0" ).toBool() );
141144
leProxyHost->setText( settings.value( "proxy/proxyHost", "" ).toString() );
@@ -768,6 +771,9 @@ void QgsOptions::saveOptions()
768771
//Network timeout
769772
settings.setValue( "/qgis/networkAndProxy/networkTimeout", mNetworkTimeoutSpinBox->value() );
770773

774+
// WMS/WMS-C tile expiry time
775+
settings.setValue( "/qgis/defaultTileExpiry", mDefaultTileExpirySpinBox->value() );
776+
771777
//Web proxy settings
772778
settings.setValue( "proxy/proxyEnabled", grpProxy->isChecked() );
773779
settings.setValue( "proxy/proxyHost", leProxyHost->text() );

‎src/core/qgsnetworkaccessmanager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include <qgslogger.h>
2424

2525
#include <QUrl>
26+
#include <QSettings>
27+
#include <QTimer>
28+
#include <QNetworkReply>
2629

2730
#if QT_VERSION >= 0x40500
2831
class QgsNetworkProxyFactory : public QNetworkProxyFactory
@@ -126,5 +129,12 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
126129
emit requestAboutToBeCreated( op, req, outgoingData );
127130
QNetworkReply *reply = QNetworkAccessManager::createRequest( op, req, outgoingData );
128131
emit requestCreated( reply );
132+
133+
// abort request, when network timeout happens
134+
QTimer *timer = new QTimer( reply );
135+
136+
QSettings s;
137+
timer->singleShot( s.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt(), reply, SLOT( abort() ) );
138+
129139
return reply;
130140
}

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,13 @@ void QgsWmsProvider::tileReplyFinished()
981981
}
982982
cmd.setRawHeaders( hl );
983983

984+
QgsDebugMsg( QString( "expirationDate:%1" ).arg( cmd.expirationDate().toString() ) );
985+
if( cmd.expirationDate().isNull() )
986+
{
987+
QSettings s;
988+
cmd.setExpirationDate( QDateTime::currentDateTime().addSecs( s.value( "/qgis/defaultTileExpiry", "24" ).toInt() * 60 * 60 ) );
989+
}
990+
984991
QgsNetworkAccessManager::instance()->cache()->updateMetaData( cmd );
985992

986993
int tileReqNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ) ).toInt();

‎src/ui/qgsoptionsbase.ui

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>807</width>
10-
<height>673</height>
9+
<width>810</width>
10+
<height>674</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -66,8 +66,8 @@
6666
<rect>
6767
<x>0</x>
6868
<y>0</y>
69-
<width>773</width>
70-
<height>938</height>
69+
<width>784</width>
70+
<height>1099</height>
7171
</rect>
7272
</property>
7373
<layout class="QGridLayout" name="gridLayout">
@@ -948,9 +948,9 @@
948948
<property name="geometry">
949949
<rect>
950950
<x>0</x>
951-
<y>-169</y>
952-
<width>938</width>
953-
<height>785</height>
951+
<y>0</y>
952+
<width>1201</width>
953+
<height>850</height>
954954
</rect>
955955
</property>
956956
<layout class="QGridLayout" name="gridLayout_8">
@@ -1464,8 +1464,8 @@
14641464
<rect>
14651465
<x>0</x>
14661466
<y>0</y>
1467-
<width>773</width>
1468-
<height>718</height>
1467+
<width>646</width>
1468+
<height>778</height>
14691469
</rect>
14701470
</property>
14711471
<layout class="QGridLayout" name="gridLayout_4">
@@ -1834,8 +1834,8 @@
18341834
<rect>
18351835
<x>0</x>
18361836
<y>0</y>
1837-
<width>791</width>
1838-
<height>599</height>
1837+
<width>317</width>
1838+
<height>91</height>
18391839
</rect>
18401840
</property>
18411841
<layout class="QGridLayout" name="gridLayout_10">
@@ -1915,8 +1915,8 @@
19151915
<rect>
19161916
<x>0</x>
19171917
<y>0</y>
1918-
<width>791</width>
1919-
<height>599</height>
1918+
<width>679</width>
1919+
<height>642</height>
19201920
</rect>
19211921
</property>
19221922
<layout class="QGridLayout" name="gridLayout_13">
@@ -2291,8 +2291,8 @@
22912291
<rect>
22922292
<x>0</x>
22932293
<y>0</y>
2294-
<width>791</width>
2295-
<height>599</height>
2294+
<width>745</width>
2295+
<height>431</height>
22962296
</rect>
22972297
</property>
22982298
<layout class="QGridLayout" name="gridLayout_15">
@@ -2478,8 +2478,8 @@
24782478
<rect>
24792479
<x>0</x>
24802480
<y>0</y>
2481-
<width>791</width>
2482-
<height>599</height>
2481+
<width>519</width>
2482+
<height>575</height>
24832483
</rect>
24842484
</property>
24852485
<layout class="QGridLayout" name="gridLayout_17">
@@ -2575,8 +2575,8 @@
25752575
<rect>
25762576
<x>0</x>
25772577
<y>0</y>
2578-
<width>791</width>
2579-
<height>599</height>
2578+
<width>589</width>
2579+
<height>582</height>
25802580
</rect>
25812581
</property>
25822582
<layout class="QGridLayout" name="gridLayout_20">
@@ -2768,7 +2768,7 @@
27682768
</item>
27692769
</layout>
27702770
</item>
2771-
<item row="3" column="0">
2771+
<item row="4" column="0">
27722772
<layout class="QHBoxLayout" name="horizontalLayout">
27732773
<item>
27742774
<widget class="QLabel" name="mNetworkTimeoutLabel">
@@ -2786,6 +2786,24 @@
27862786
</item>
27872787
</layout>
27882788
</item>
2789+
<item row="5" column="0">
2790+
<layout class="QHBoxLayout" name="horizontalLayout_17">
2791+
<item>
2792+
<widget class="QLabel" name="label_32">
2793+
<property name="text">
2794+
<string>Default expiration period for WMS-C/WMTS tiles (hours)</string>
2795+
</property>
2796+
</widget>
2797+
</item>
2798+
<item>
2799+
<widget class="QSpinBox" name="mDefaultTileExpirySpinBox">
2800+
<property name="maximum">
2801+
<number>100000000</number>
2802+
</property>
2803+
</widget>
2804+
</item>
2805+
</layout>
2806+
</item>
27892807
</layout>
27902808
</widget>
27912809
</widget>

0 commit comments

Comments
 (0)
Please sign in to comment.