[QGIS Commit] r11914 - in trunk/qgis/src: app core plugins/wfs providers/wfs ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Nov 4 03:28:21 EST 2009


Author: mhugent
Date: 2009-11-04 03:28:18 -0500 (Wed, 04 Nov 2009)
New Revision: 11914

Modified:
   trunk/qgis/src/app/qgsoptions.cpp
   trunk/qgis/src/core/qgshttptransaction.cpp
   trunk/qgis/src/core/qgshttptransaction.h
   trunk/qgis/src/plugins/wfs/qgswfssourceselect.cpp
   trunk/qgis/src/providers/wfs/qgswfsdata.cpp
   trunk/qgis/src/providers/wfs/qgswfsdata.h
   trunk/qgis/src/ui/qgsoptionsbase.ui
Log:
[FEATUE]: Add option to specify network timeout instead of using the hardcoded one in qgshttptransaction

Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp	2009-11-03 19:43:22 UTC (rev 11913)
+++ trunk/qgis/src/app/qgsoptions.cpp	2009-11-04 08:28:18 UTC (rev 11914)
@@ -78,6 +78,9 @@
     }
   }
 
+  //Network timeout
+  mNetworkTimeoutSpinBox->setValue( settings.value( "/qgis/networkAndProxy/networkTimeout", "60000" ).toInt() );
+
   //Web proxy settings
   grpProxy->setChecked( settings.value( "proxy/proxyEnabled", "0" ).toBool() );
   leProxyHost->setText( settings.value( "proxy/proxyHost", "" ).toString() );
@@ -274,7 +277,7 @@
   {
     mMarkerStyleComboBox->setCurrentIndex( mMarkerStyleComboBox->findText( tr( "None" ) ) );
   }
-  mMarkerSizeSpinBox->setValue( settings.value( "/qgis/digitizing/marker_size", 7 ).toInt()*2+1 );
+  mMarkerSizeSpinBox->setValue( settings.value( "/qgis/digitizing/marker_size", 7 ).toInt()*2 + 1 );
 
   chkDisableAttributeValuesDlg->setChecked( settings.value( "/qgis/digitizing/disable_enter_attribute_values_dialog", false ).toBool() );
 
@@ -352,7 +355,7 @@
 void QgsOptions::saveOptions()
 {
   QSettings settings;
-  
+
   //search directories for svgs
   QString myPaths;
   for ( int i = 0; i < mListSVGPaths->count(); ++i )
@@ -365,6 +368,9 @@
   }
   settings.setValue( "svg/searchPathsForSVG", myPaths );
 
+  //Network timeout
+  settings.setValue( "/qgis/networkAndProxy/networkTimeout", mNetworkTimeoutSpinBox->value() );
+
   //Web proxy settings
   settings.setValue( "proxy/proxyEnabled", grpProxy->isChecked() );
   settings.setValue( "proxy/proxyHost", leProxyHost->text() );
@@ -518,7 +524,7 @@
   {
     settings.setValue( "/qgis/digitizing/marker_style", "None" );
   }
-  settings.setValue( "/qgis/digitizing/marker_size", (mMarkerSizeSpinBox->value()-1)/2 );
+  settings.setValue( "/qgis/digitizing/marker_size", ( mMarkerSizeSpinBox->value() - 1 ) / 2 );
 
   settings.setValue( "/qgis/digitizing/disable_enter_attribute_values_dialog", chkDisableAttributeValuesDlg->isChecked() );
 
@@ -710,11 +716,11 @@
 void QgsOptions::on_mBtnAddSVGPath_clicked()
 {
   QString myDir = QFileDialog::getExistingDirectory(
-      this,
-      tr( "Choose a directory" ),
-      QDir::toNativeSeparators( QDir::homePath() ),
-      QFileDialog::ShowDirsOnly
-      );
+                    this,
+                    tr( "Choose a directory" ),
+                    QDir::toNativeSeparators( QDir::homePath() ),
+                    QFileDialog::ShowDirsOnly
+                  );
 
   if ( ! myDir.isEmpty() )
   {

Modified: trunk/qgis/src/core/qgshttptransaction.cpp
===================================================================
--- trunk/qgis/src/core/qgshttptransaction.cpp	2009-11-03 19:43:22 UTC (rev 11913)
+++ trunk/qgis/src/core/qgshttptransaction.cpp	2009-11-04 08:28:18 UTC (rev 11914)
@@ -31,7 +31,6 @@
 #include <QTimer>
 #include "qgslogger.h"
 
-static int NETWORK_TIMEOUT_MSEC = ( 120 * 1000 );  // 120 seconds
 static int HTTP_PORT_DEFAULT = 80;
 
 //XXX Set the connection name when creating the provider instance
@@ -51,8 +50,15 @@
     httphost( proxyHost ),
     mError( 0 )
 {
+  QSettings s;
+  mNetworkTimeoutMsec = s.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt();
 }
 
+QgsHttpTransaction::QgsHttpTransaction()
+{
+
+}
+
 QgsHttpTransaction::~QgsHttpTransaction()
 {
   QgsDebugMsg( "deconstructing." );
@@ -175,7 +181,7 @@
            this,     SLOT( networkTimedOut() ) );
 
   mWatchdogTimer->setSingleShot( TRUE );
-  mWatchdogTimer->start( NETWORK_TIMEOUT_MSEC );
+  mWatchdogTimer->start( mNetworkTimeoutMsec );
 
   QgsDebugMsg( "Starting get with id " + QString::number( httpid ) + "." );
   QgsDebugMsg( "Setting httpactive = TRUE" );
@@ -251,7 +257,7 @@
                resp.value( "Content-Type" ) + "'." );
 
   // We saw something come back, therefore restart the watchdog timer
-  mWatchdogTimer->start( NETWORK_TIMEOUT_MSEC );
+  mWatchdogTimer->start( mNetworkTimeoutMsec );
 
   if ( resp.statusCode() == 302 ) // Redirect
   {
@@ -298,7 +304,7 @@
 //  QgsDebugMsg("got " + QString::number(done) + " of " + QString::number(total));
 
   // We saw something come back, therefore restart the watchdog timer
-  mWatchdogTimer->start( NETWORK_TIMEOUT_MSEC );
+  mWatchdogTimer->start( mNetworkTimeoutMsec );
 
   emit dataReadProgress( done );
   emit totalSteps( total );
@@ -414,7 +420,7 @@
   QgsDebugMsg( "state " + QString::number( state ) + "." );
 
   // We saw something come back, therefore restart the watchdog timer
-  mWatchdogTimer->start( NETWORK_TIMEOUT_MSEC );
+  mWatchdogTimer->start( mNetworkTimeoutMsec );
 
   switch ( state )
   {
@@ -467,7 +473,7 @@
   QgsDebugMsg( "entering." );
 
   mError = tr( "Network timed out after %n second(s) of inactivity.\n"
-               "This may be a problem in your network connection or at the WMS server.", "inactivity timeout", NETWORK_TIMEOUT_MSEC / 1000 );
+               "This may be a problem in your network connection or at the WMS server.", "inactivity timeout", mNetworkTimeoutMsec / 1000 );
 
   QgsDebugMsg( "Setting httpactive = FALSE" );
   httpactive = FALSE;

Modified: trunk/qgis/src/core/qgshttptransaction.h
===================================================================
--- trunk/qgis/src/core/qgshttptransaction.h	2009-11-03 19:43:22 UTC (rev 11913)
+++ trunk/qgis/src/core/qgshttptransaction.h	2009-11-04 08:28:18 UTC (rev 11914)
@@ -96,7 +96,12 @@
 
     void setCredentials( const QString& username, const QString &password );
 
+    /**Returns the network timeout in msec*/
+    int networkTimeout() const { return mNetworkTimeoutMsec;}
+    /**Sets the network timeout in milliseconds*/
+    void setNetworkTimeout( int msec ) { mNetworkTimeoutMsec = msec;}
 
+
   public slots:
 
     void dataStarted( int id );
@@ -134,6 +139,9 @@
 
   private:
 
+    /**Default constructor is forbidden*/
+    QgsHttpTransaction();
+
     /**
      * Indicates the associated QHttp object
      *
@@ -207,6 +215,9 @@
      * Password
      */
     QString mPassword;
+
+    /**Network timeout in milliseconds*/
+    int mNetworkTimeoutMsec;
 };
 
 #endif

Modified: trunk/qgis/src/plugins/wfs/qgswfssourceselect.cpp
===================================================================
--- trunk/qgis/src/plugins/wfs/qgswfssourceselect.cpp	2009-11-03 19:43:22 UTC (rev 11913)
+++ trunk/qgis/src/plugins/wfs/qgswfssourceselect.cpp	2009-11-04 08:28:18 UTC (rev 11914)
@@ -143,7 +143,10 @@
 
   QByteArray result;
   QgsHttpTransaction http( request );
-  http.getSynchronously( result );
+  if ( !http.getSynchronously( result ) )
+  {
+    QMessageBox::critical( 0, tr( "Error" ), tr( "The capabilities document could not be retrieved from the server" ) );
+  }
 
   QDomDocument capabilitiesDocument;
   if ( !capabilitiesDocument.setContent( result, true ) )

Modified: trunk/qgis/src/providers/wfs/qgswfsdata.cpp
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsdata.cpp	2009-11-03 19:43:22 UTC (rev 11913)
+++ trunk/qgis/src/providers/wfs/qgswfsdata.cpp	2009-11-04 08:28:18 UTC (rev 11914)
@@ -23,6 +23,7 @@
 #include <QList>
 #include <QProgressDialog>
 #include <QSet>
+#include <QSettings>
 
 //just for a test
 //#include <QProgressDialog>
@@ -64,8 +65,12 @@
     }
   }
 
+  QSettings s;
+  mNetworkTimeoutMsec = s.value( "/qgis/networkAndProxy/networkTimeout", "60000" ).toInt();
+
   mEndian = QgsApplication::endian();
   QObject::connect( &mHttp, SIGNAL( done( bool ) ), this, SLOT( setFinished( bool ) ) );
+  QObject::connect( &mNetworkTimeoutTimer, SIGNAL( timeout() ), this, SLOT( setFinished() ) );
 }
 
 QgsWFSData::~QgsWFSData()
@@ -115,7 +120,9 @@
     progressDialog->show();
   }
 
-  //mHttp.get( mUri );
+  //setup timer
+  mNetworkTimeoutTimer.setSingleShot( true );
+  mNetworkTimeoutTimer.start( mNetworkTimeoutMsec );
   mHttp.get( requestUrl.path() + "?" + QString( requestUrl.encodedQuery() ) );
 
 
@@ -169,6 +176,7 @@
 {
   emit dataReadProgress( progress );
   emit totalStepsUpdate( totalSteps );
+  mNetworkTimeoutTimer.start( mNetworkTimeoutMsec );
 }
 
 void QgsWFSData::startElement( const XML_Char* el, const XML_Char** attr )

Modified: trunk/qgis/src/providers/wfs/qgswfsdata.h
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsdata.h	2009-11-03 19:43:22 UTC (rev 11913)
+++ trunk/qgis/src/providers/wfs/qgswfsdata.h	2009-11-04 08:28:18 UTC (rev 11914)
@@ -16,6 +16,7 @@
 #define QGSWFSDATA_H
 
 #include <QHttp>
+#include <QTimer>
 #include <expat.h>
 #include "qgis.h"
 #include "qgsapplication.h"
@@ -56,7 +57,7 @@
     const QHttp* http() const {return &mHttp;}
 
   private slots:
-    void setFinished( bool error );
+    void setFinished( bool error = true );
 
     /**Takes progress value and total steps and emit signals 'dataReadProgress' and 'totalStepUpdate'*/
     void handleProgressEvent( int progress, int totalSteps );
@@ -178,6 +179,8 @@
     QString mCoordinateSeparator;
     /**Tuple separator for coordinate strings. Usually " " */
     QString mTupleSeparator;
+    int mNetworkTimeoutMsec;
+    QTimer mNetworkTimeoutTimer;
 };
 
 #endif

Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui	2009-11-03 19:43:22 UTC (rev 11913)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui	2009-11-04 08:28:18 UTC (rev 11914)
@@ -5,7 +5,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>657</width>
+    <width>807</width>
     <height>594</height>
    </rect>
   </property>
@@ -25,14 +25,14 @@
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="standardButtons" >
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
      </property>
     </widget>
    </item>
    <item row="0" column="0" >
     <widget class="QTabWidget" name="tabWidget" >
      <property name="currentIndex" >
-      <number>1</number>
+      <number>0</number>
      </property>
      <widget class="QWidget" name="tabGeneral" >
       <attribute name="title" >
@@ -45,18 +45,9 @@
           <string>Project files</string>
          </property>
          <layout class="QVBoxLayout" >
-          <property name="leftMargin" >
+          <property name="margin" >
            <number>11</number>
           </property>
-          <property name="topMargin" >
-           <number>11</number>
-          </property>
-          <property name="rightMargin" >
-           <number>11</number>
-          </property>
-          <property name="bottomMargin" >
-           <number>11</number>
-          </property>
           <item>
            <widget class="QCheckBox" name="chbAskToSaveProjectChanges" >
             <property name="text" >
@@ -95,7 +86,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>40</width>
               <height>20</height>
@@ -131,7 +122,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>40</width>
               <height>20</height>
@@ -197,7 +188,7 @@
             <property name="sizeType" >
              <enum>QSizePolicy::Fixed</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>20</width>
               <height>10</height>
@@ -316,18 +307,9 @@
           <string>Rendering quality</string>
          </property>
          <layout class="QVBoxLayout" >
-          <property name="leftMargin" >
+          <property name="margin" >
            <number>11</number>
           </property>
-          <property name="topMargin" >
-           <number>11</number>
-          </property>
-          <property name="rightMargin" >
-           <number>11</number>
-          </property>
-          <property name="bottomMargin" >
-           <number>11</number>
-          </property>
           <item>
            <widget class="QCheckBox" name="chkAntiAliasing" >
             <property name="text" >
@@ -366,7 +348,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>31</width>
               <height>20</height>
@@ -401,36 +383,18 @@
        <string>&amp;Map tools</string>
       </attribute>
       <layout class="QGridLayout" >
-       <property name="leftMargin" >
+       <property name="margin" >
         <number>11</number>
        </property>
-       <property name="topMargin" >
-        <number>11</number>
-       </property>
-       <property name="rightMargin" >
-        <number>11</number>
-       </property>
-       <property name="bottomMargin" >
-        <number>11</number>
-       </property>
        <item row="2" column="0" >
         <widget class="QGroupBox" name="groupBox_10" >
          <property name="title" >
           <string>Panning and zooming</string>
          </property>
          <layout class="QGridLayout" >
-          <property name="leftMargin" >
+          <property name="margin" >
            <number>11</number>
           </property>
-          <property name="topMargin" >
-           <number>11</number>
-          </property>
-          <property name="rightMargin" >
-           <number>11</number>
-          </property>
-          <property name="bottomMargin" >
-           <number>11</number>
-          </property>
           <item row="0" column="1" >
            <widget class="QComboBox" name="cmbWheelAction" >
             <item>
@@ -491,24 +455,15 @@
           <string>Measure tool</string>
          </property>
          <layout class="QGridLayout" >
-          <property name="leftMargin" >
+          <property name="margin" >
            <number>11</number>
           </property>
-          <property name="topMargin" >
-           <number>11</number>
-          </property>
-          <property name="rightMargin" >
-           <number>11</number>
-          </property>
-          <property name="bottomMargin" >
-           <number>11</number>
-          </property>
           <item row="1" column="2" >
            <spacer>
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>191</width>
               <height>20</height>
@@ -582,18 +537,9 @@
           <string>Identify</string>
          </property>
          <layout class="QGridLayout" >
-          <property name="leftMargin" >
+          <property name="margin" >
            <number>11</number>
           </property>
-          <property name="topMargin" >
-           <number>11</number>
-          </property>
-          <property name="rightMargin" >
-           <number>11</number>
-          </property>
-          <property name="bottomMargin" >
-           <number>11</number>
-          </property>
           <item row="2" column="0" colspan="2" >
            <widget class="QLabel" name="textLabel2" >
             <property name="text" >
@@ -648,7 +594,7 @@
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>20</width>
            <height>40</height>
@@ -687,7 +633,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>221</width>
               <height>20</height>
@@ -703,7 +649,7 @@
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>20</width>
            <height>40</height>
@@ -791,7 +737,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>311</width>
               <height>20</height>
@@ -824,7 +770,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>241</width>
               <height>20</height>
@@ -857,7 +803,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>61</width>
               <height>20</height>
@@ -940,7 +886,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>281</width>
               <height>20</height>
@@ -986,7 +932,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>40</width>
               <height>20</height>
@@ -1021,7 +967,7 @@
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>547</width>
            <height>71</height>
@@ -1036,24 +982,15 @@
        <string>CRS</string>
       </attribute>
       <layout class="QGridLayout" >
-       <property name="leftMargin" >
+       <property name="margin" >
         <number>11</number>
        </property>
-       <property name="topMargin" >
-        <number>11</number>
-       </property>
-       <property name="rightMargin" >
-        <number>11</number>
-       </property>
-       <property name="bottomMargin" >
-        <number>11</number>
-       </property>
        <item row="3" column="0" >
         <spacer>
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>51</width>
            <height>31</height>
@@ -1077,18 +1014,9 @@
           <string>When a new layer is created, or when a layer is loaded that has no coordinate reference system (CRS)</string>
          </property>
          <layout class="QVBoxLayout" >
-          <property name="leftMargin" >
+          <property name="margin" >
            <number>11</number>
           </property>
-          <property name="topMargin" >
-           <number>11</number>
-          </property>
-          <property name="rightMargin" >
-           <number>11</number>
-          </property>
-          <property name="bottomMargin" >
-           <number>11</number>
-          </property>
           <item>
            <widget class="QRadioButton" name="radPromptForProjection" >
             <property name="text" >
@@ -1160,7 +1088,7 @@
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>501</width>
            <height>51</height>
@@ -1188,10 +1116,28 @@
      </widget>
      <widget class="QWidget" name="tab" >
       <attribute name="title" >
-       <string>Proxy</string>
+       <string>Network and Proxy</string>
       </attribute>
-      <layout class="QGridLayout" >
+      <layout class="QGridLayout" name="gridLayout_2" >
        <item row="0" column="0" >
+        <layout class="QHBoxLayout" name="horizontalLayout" >
+         <item>
+          <widget class="QLabel" name="mNetworkTimeoutLabel" >
+           <property name="text" >
+            <string>Timeout for network requests (ms):</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QSpinBox" name="mNetworkTimeoutSpinBox" >
+           <property name="maximum" >
+            <number>100000000</number>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item row="1" column="0" >
         <widget class="QGroupBox" name="grpProxy" >
          <property name="title" >
           <string>Use proxy for web access</string>
@@ -1202,7 +1148,7 @@
          <property name="checkable" >
           <bool>true</bool>
          </property>
-         <layout class="QGridLayout" >
+         <layout class="QGridLayout" name="gridLayout" >
           <item row="0" column="0" >
            <widget class="QLabel" name="lblProxyHost" >
             <property name="text" >
@@ -1281,7 +1227,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>241</width>
               <height>20</height>
@@ -1292,7 +1238,7 @@
           <item row="5" column="0" colspan="2" >
            <widget class="QLabel" name="mExcludeUrlsLabel" >
             <property name="text" >
-             <string>Exclude URLs:</string>
+             <string>Exclude URLs (starting with):</string>
             </property>
            </widget>
           </item>
@@ -1315,7 +1261,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>391</width>
               <height>20</height>



More information about the QGIS-commit mailing list