[QGIS Commit] r10009 - in trunk/qgis/src: app core providers/wms ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jan 24 10:56:01 EST 2009


Author: mhugent
Date: 2009-01-24 10:56:01 -0500 (Sat, 24 Jan 2009)
New Revision: 10009

Modified:
   trunk/qgis/src/app/qgsoptions.cpp
   trunk/qgis/src/app/qgsoptions.h
   trunk/qgis/src/core/qgshttptransaction.cpp
   trunk/qgis/src/core/qgshttptransaction.h
   trunk/qgis/src/providers/wms/qgswmsprovider.cpp
   trunk/qgis/src/ui/qgsoptionsbase.ui
Log:
WMS: don't apply proxy to a list of selected urls. Done in QgsHttpTransaction::applyProxySettings so WFS & co can later also use this function. Not tested yet and still needs some cleanups

Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp	2009-01-24 10:31:10 UTC (rev 10008)
+++ trunk/qgis/src/app/qgsoptions.cpp	2009-01-24 15:56:01 UTC (rev 10009)
@@ -72,6 +72,21 @@
   QString settingProxyType = settings.value("proxy/proxyType", "DefaultProxy").toString();
   mProxyTypeComboBox->setCurrentIndex(mProxyTypeComboBox->findText(settingProxyType));
 
+  //URLs excluded not going through proxies
+  QString proxyExcludedURLs = settings.value( "proxy/proxyExcludedUrls", "").toString();
+  if(!proxyExcludedURLs.isEmpty())
+  {
+    QStringList splittedUrls = proxyExcludedURLs.split("|");
+    QStringList::const_iterator urlIt = splittedUrls.constBegin();
+    for(; urlIt != splittedUrls.constEnd(); ++urlIt)
+    {
+      QListWidgetItem* newItem = new QListWidgetItem(mExcludeUrlListWidget);
+      newItem->setText(*urlIt);
+      newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+      mExcludeUrlListWidget->addItem(newItem);
+    }
+  }
+
   // set the current theme
   cmbTheme->setItemText( cmbTheme->currentIndex(), settings.value( "/Themes" ).toString() );
 
@@ -275,6 +290,18 @@
   settings.setValue( "proxy/proxyPassword", leProxyPassword->text() );
   settings.setValue( "proxy/proxyType", mProxyTypeComboBox->currentText());
 
+  //url to exclude from proxys
+  QString proxyExcludeString;
+  for(int i = 0; i < mExcludeUrlListWidget->count(); ++i)
+  {
+    if(i != 0)
+    {
+      proxyExcludeString += "|";
+    }
+    proxyExcludeString += mExcludeUrlListWidget->item(i)->text();
+  }
+  settings.setValue( "proxy/proxyExcludedUrls", proxyExcludeString);
+
   //general settings
   settings.setValue( "/Map/identifyRadius", spinBoxIdentifyValue->value() );
   settings.setValue( "/qgis/showLegendClassifiers", cbxLegendClassifiers->isChecked() );
@@ -547,3 +574,19 @@
   }
   return myList;
 }
+
+void QgsOptions::on_mAddUrlPushButton_clicked()
+{
+  QListWidgetItem* newItem = new QListWidgetItem(mExcludeUrlListWidget);
+  newItem->setText("URL");
+  newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+  mExcludeUrlListWidget->addItem(newItem);
+  mExcludeUrlListWidget->setCurrentItem(newItem);
+}
+
+void QgsOptions::on_mRemoveUrlPushButton_clicked()
+{
+  int currentRow = mExcludeUrlListWidget->currentRow();
+  QListWidgetItem* itemToRemove = mExcludeUrlListWidget->takeItem(currentRow);
+  delete itemToRemove;
+}

Modified: trunk/qgis/src/app/qgsoptions.h
===================================================================
--- trunk/qgis/src/app/qgsoptions.h	2009-01-24 10:31:10 UTC (rev 10008)
+++ trunk/qgis/src/app/qgsoptions.h	2009-01-24 15:56:01 UTC (rev 10009)
@@ -82,6 +82,12 @@
      */
     void on_mLineColourToolButton_clicked();
 
+    /**Add a new URL to exclude from Proxy*/
+    void on_mAddUrlPushButton_clicked();
+
+    /**Remove an URL to exclude from Proxy*/
+    void on_mRemoveUrlPushButton_clicked();
+
   protected:
     //! Populates combo box with ellipsoids
     void getEllipsoidList();

Modified: trunk/qgis/src/core/qgshttptransaction.cpp
===================================================================
--- trunk/qgis/src/core/qgshttptransaction.cpp	2009-01-24 10:31:10 UTC (rev 10008)
+++ trunk/qgis/src/core/qgshttptransaction.cpp	2009-01-24 15:56:01 UTC (rev 10009)
@@ -27,6 +27,7 @@
 
 #include <QApplication>
 #include <QUrl>
+#include <QSettings>
 #include <QTimer>
 #include "qgslogger.h"
 
@@ -97,17 +98,17 @@
   // Set the host in the QHttp object
   http->setHost( qurl.host(), qurl.port( HTTP_PORT_DEFAULT ) );
 
-  if ( httphost.isEmpty() )
+  if(!QgsHttpTransaction::applyProxySettings(*http, httpurl))
   {
-    // No proxy was specified - connect directly to host in URI
     httphost = qurl.host();
     httpport = qurl.port( HTTP_PORT_DEFAULT );
-
   }
   else
   {
-    // Insert proxy username and password authentication
-    http->setProxy( QNetworkProxy(mProxyType, httphost, httpport, httpuser, httppass) );
+    //proxy enabled, read httphost and httpport from settings
+    QSettings settings;
+    httphost = settings.value( "proxy/proxyHost", "" ).toString();
+    httpport = settings.value( "proxy/proxyPort", "" ).toString().toInt();
   }
 
 //  int httpid1 = http->setHost( qurl.host(), qurl.port() );
@@ -470,6 +471,63 @@
   return mError;
 }
 
+bool QgsHttpTransaction::applyProxySettings(QHttp& http, const QString& url)
+{
+  QSettings settings;
+  //check if proxy is enabled
+  bool proxyEnabled = settings.value( "proxy/proxyEnabled", false ).toBool();
+  if(!proxyEnabled)
+  {
+    return false;
+  }
+
+  //check if the url should go through proxy
+  QString  proxyExcludedURLs = settings.value( "proxy/proxyExcludedUrls", "").toString();
+  if(!proxyExcludedURLs.isEmpty())
+  {
+    QStringList excludedURLs = proxyExcludedURLs.split("|");
+    QStringList::const_iterator exclIt = excludedURLs.constBegin();
+    for(; exclIt != excludedURLs.constEnd(); ++exclIt)
+    {
+      if(url.startsWith(*exclIt))
+      {
+        return false; //url does not go through proxy
+      }
+    }
+  }
+
+  //read type, host, port, user, passw from settings
+  QString proxyHost = settings.value( "proxy/proxyHost", "" ).toString();
+  int proxyPort = settings.value( "proxy/proxyPort", "" ).toString().toInt();
+  QString proxyUser = settings.value( "proxy/proxyUser", "" ).toString();
+  QString proxyPassword = settings.value( "proxy/proxyPassword", "" ).toString();
+
+  QString proxyTypeString =  settings.value( "proxy/proxyType", "" ).toString();
+  QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
+    if(proxyTypeString == "DefaultProxy")
+    {
+         proxyType = QNetworkProxy::DefaultProxy;
+     }
+     else if(proxyTypeString == "Socks5Proxy")
+     {
+         proxyType = QNetworkProxy::Socks5Proxy;
+    }
+     else if(proxyTypeString == "HttpProxy")
+     {
+         proxyType = QNetworkProxy::HttpProxy;
+     }
+     else if(proxyTypeString == "HttpCachingProxy")
+     {
+         proxyType = QNetworkProxy::HttpCachingProxy;
+     }
+     else if(proxyTypeString == "FtpCachingProxy")
+     {
+        proxyType = QNetworkProxy::FtpCachingProxy;
+     }
+  http.setProxy( QNetworkProxy(proxyType, proxyHost, proxyPort, proxyUser, proxyPassword) );
+  return true;
+}
+
 void QgsHttpTransaction::abort()
 {
     if(http)

Modified: trunk/qgis/src/core/qgshttptransaction.h
===================================================================
--- trunk/qgis/src/core/qgshttptransaction.h	2009-01-24 10:31:10 UTC (rev 10008)
+++ trunk/qgis/src/core/qgshttptransaction.h	2009-01-24 15:56:01 UTC (rev 10009)
@@ -82,7 +82,11 @@
      */
     QString errorString();
 
+    /**Apply proxy settings from QSettings to a http object
+    @param return true if proxy settings was applied, false else*/
+    static bool applyProxySettings(QHttp& http, const QString& url);
 
+
   public slots:
 
     void dataStarted( int id );

Modified: trunk/qgis/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2009-01-24 10:31:10 UTC (rev 10008)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2009-01-24 15:56:01 UTC (rev 10009)
@@ -638,6 +638,7 @@
 {
   QgsDebugMsg( "WMS request Url: " + url );
 
+#if 0 //MH: not necessary any more
   //read proxy settings
    QSettings settings;
    QString proxyHost, proxyUser, proxyPassword;
@@ -675,8 +676,11 @@
    }
 
 
+
     QgsHttpTransaction http(url, proxyHost, proxyPort, proxyUser, proxyPassword, proxyType );
+#endif //0
 
+QgsHttpTransaction http(url);
 
   // Do a passthrough for the status bar text
   connect(

Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui	2009-01-24 10:31:10 UTC (rev 10008)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui	2009-01-24 15:56:01 UTC (rev 10009)
@@ -5,17 +5,15 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>617</width>
-    <height>559</height>
+    <width>851</width>
+    <height>776</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <string>QGIS Options</string>
   </property>
   <property name="windowIcon" >
-   <iconset>
-    <normaloff/>
-   </iconset>
+   <iconset/>
   </property>
   <property name="sizeGripEnabled" >
    <bool>true</bool>
@@ -40,9 +38,18 @@
           <string>Project files</string>
          </property>
          <layout class="QVBoxLayout" >
-          <property name="margin" >
+          <property name="leftMargin" >
            <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" >
@@ -81,7 +88,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" stdset="0" >
+            <property name="sizeHint" >
              <size>
               <width>40</width>
               <height>20</height>
@@ -117,7 +124,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" stdset="0" >
+            <property name="sizeHint" >
              <size>
               <width>40</width>
               <height>20</height>
@@ -249,7 +256,7 @@
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" stdset="0" >
+         <property name="sizeHint" >
           <size>
            <width>577</width>
            <height>21</height>
@@ -316,9 +323,18 @@
           <string>Rendering quality</string>
          </property>
          <layout class="QVBoxLayout" >
-          <property name="margin" >
+          <property name="leftMargin" >
            <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" >
@@ -351,7 +367,7 @@
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" stdset="0" >
+         <property name="sizeHint" >
           <size>
            <width>20</width>
            <height>40</height>
@@ -366,18 +382,36 @@
        <string>&amp;Map tools</string>
       </attribute>
       <layout class="QGridLayout" >
-       <property name="margin" >
+       <property name="leftMargin" >
         <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="margin" >
+          <property name="leftMargin" >
            <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>
@@ -438,15 +472,24 @@
           <string>Measure tool</string>
          </property>
          <layout class="QGridLayout" >
-          <property name="margin" >
+          <property name="leftMargin" >
            <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" stdset="0" >
+            <property name="sizeHint" >
              <size>
               <width>191</width>
               <height>20</height>
@@ -499,9 +542,18 @@
           <string>Search radius</string>
          </property>
          <layout class="QGridLayout" >
-          <property name="margin" >
+          <property name="leftMargin" >
            <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="0" colspan="2" >
            <widget class="QLabel" name="textLabel2" >
             <property name="text" >
@@ -546,7 +598,7 @@
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" stdset="0" >
+         <property name="sizeHint" >
           <size>
            <width>20</width>
            <height>40</height>
@@ -560,7 +612,7 @@
       <attribute name="title" >
        <string>Digitizing</string>
       </attribute>
-      <layout class="QVBoxLayout" name="verticalLayout" >
+      <layout class="QVBoxLayout" >
        <item>
         <widget class="QGroupBox" name="mRubberBandGroupBox" >
          <property name="title" >
@@ -631,7 +683,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" stdset="0" >
+            <property name="sizeHint" >
              <size>
               <width>311</width>
               <height>20</height>
@@ -661,7 +713,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" stdset="0" >
+            <property name="sizeHint" >
              <size>
               <width>241</width>
               <height>20</height>
@@ -691,7 +743,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" stdset="0" >
+            <property name="sizeHint" >
              <size>
               <width>61</width>
               <height>20</height>
@@ -730,7 +782,7 @@
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" stdset="0" >
+            <property name="sizeHint" >
              <size>
               <width>281</width>
               <height>20</height>
@@ -756,7 +808,7 @@
          <property name="title" >
           <string>Enter attribute values</string>
          </property>
-         <layout class="QHBoxLayout" name="horizontalLayout" >
+         <layout class="QHBoxLayout" >
           <item>
            <widget class="QCheckBox" name="chkDisableAttributeValuesDlg" >
             <property name="text" >
@@ -775,7 +827,7 @@
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" stdset="0" >
+         <property name="sizeHint" >
           <size>
            <width>547</width>
            <height>71</height>
@@ -790,15 +842,24 @@
        <string>CRS</string>
       </attribute>
       <layout class="QGridLayout" >
-       <property name="margin" >
+       <property name="leftMargin" >
         <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" stdset="0" >
+         <property name="sizeHint" >
           <size>
            <width>51</width>
            <height>31</height>
@@ -822,9 +883,18 @@
           <string>When layer is loaded that has no coordinate reference system (CRS)</string>
          </property>
          <layout class="QVBoxLayout" >
-          <property name="margin" >
+          <property name="leftMargin" >
            <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" >
@@ -896,7 +966,7 @@
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" stdset="0" >
+         <property name="sizeHint" >
           <size>
            <width>501</width>
            <height>51</height>
@@ -949,7 +1019,7 @@
             </property>
            </widget>
           </item>
-          <item row="0" column="1" colspan="2" >
+          <item row="0" column="1" colspan="5" >
            <widget class="QLineEdit" name="leProxyHost" />
           </item>
           <item row="1" column="0" >
@@ -962,7 +1032,7 @@
             </property>
            </widget>
           </item>
-          <item row="1" column="1" colspan="2" >
+          <item row="1" column="1" colspan="5" >
            <widget class="QLineEdit" name="leProxyPort" />
           </item>
           <item row="2" column="0" >
@@ -975,7 +1045,7 @@
             </property>
            </widget>
           </item>
-          <item row="2" column="1" colspan="2" >
+          <item row="2" column="1" colspan="5" >
            <widget class="QLineEdit" name="leProxyUser" >
             <property name="toolTip" >
              <string>Leave this blank if no proxy username / password are required</string>
@@ -992,7 +1062,7 @@
             </property>
            </widget>
           </item>
-          <item row="3" column="1" colspan="2" >
+          <item row="3" column="1" colspan="5" >
            <widget class="QLineEdit" name="leProxyPassword" >
             <property name="toolTip" >
              <string>Leave this blank if no proxy username / password are required</string>
@@ -1009,15 +1079,15 @@
             </property>
            </widget>
           </item>
-          <item row="4" column="1" >
+          <item row="4" column="1" colspan="2" >
            <widget class="QComboBox" name="mProxyTypeComboBox" />
           </item>
-          <item row="4" column="2" >
+          <item row="4" column="3" colspan="3" >
            <spacer>
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" stdset="0" >
+            <property name="sizeHint" >
              <size>
               <width>241</width>
               <height>20</height>
@@ -1025,22 +1095,46 @@
             </property>
            </spacer>
           </item>
+          <item row="5" column="0" colspan="2" >
+           <widget class="QLabel" name="mExcludeUrlsLabel" >
+            <property name="text" >
+             <string>Exclude URLs:</string>
+            </property>
+           </widget>
+          </item>
+          <item row="5" column="2" colspan="2" >
+           <widget class="QPushButton" name="mAddUrlPushButton" >
+            <property name="text" >
+             <string>Add</string>
+            </property>
+           </widget>
+          </item>
+          <item row="5" column="4" >
+           <widget class="QPushButton" name="mRemoveUrlPushButton" >
+            <property name="text" >
+             <string>Remove</string>
+            </property>
+           </widget>
+          </item>
+          <item row="5" column="5" >
+           <spacer>
+            <property name="orientation" >
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" >
+             <size>
+              <width>391</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item row="6" column="0" colspan="6" >
+           <widget class="QListWidget" name="mExcludeUrlListWidget" />
+          </item>
          </layout>
         </widget>
        </item>
-       <item row="1" column="0" >
-        <spacer>
-         <property name="orientation" >
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0" >
-          <size>
-           <width>577</width>
-           <height>251</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
       </layout>
      </widget>
     </widget>
@@ -1051,7 +1145,7 @@
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="standardButtons" >
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
      </property>
     </widget>
    </item>



More information about the QGIS-commit mailing list