Skip to content
Permalink
Browse files

instantiate proxy factory only once

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13272 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Apr 7, 2010
1 parent da9278c commit ff499bcefcc5fcb72d5d141bf9b999817e16b840
Showing with 23 additions and 17 deletions.
  1. +8 −15 src/app/qgisapp.cpp
  2. +7 −0 src/app/qgisapp.h
  3. +5 −1 src/app/qgsnetworkproxyfactory.cpp
  4. +3 −1 src/app/qgsnetworkproxyfactory.h
@@ -359,6 +359,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
, mSplash( splash )
, mPythonUtils( NULL )
, mNAM( NULL )
, mProxyFactory( NULL )
, mpTileScaleWidget( NULL )
#ifdef HAVE_QWT
, mpGpsWidget( NULL )
@@ -972,26 +973,12 @@ void QgisApp::createActions()
mActionAddPgLayer = new QAction( getThemeIcon( "mActionAddLayer.png" ), tr( "Add PostGIS Layer..." ), this );
shortcuts->registerAction( mActionAddPgLayer, tr( "Ctrl+Shift+D", "Add a PostGIS Layer" ) );
mActionAddPgLayer->setStatusTip( tr( "Add a PostGIS Layer" ) );
//#ifdef HAVE_POSTGRESQL
// QgsDebugMsg("HAVE_POSTGRESQL is defined");
// assert(0);
//#else
// QgsDebugMsg("HAVE_POSTGRESQL not defined");
// assert(0);
//#endif
connect( mActionAddPgLayer, SIGNAL( triggered() ), this, SLOT( addDatabaseLayer() ) );

mActionAddSpatiaLiteLayer = new QAction( getThemeIcon( "mActionAddSpatiaLiteLayer.png" ), tr( "Add SpatiaLite Layer..." ), this );
shortcuts->registerAction( mActionAddSpatiaLiteLayer, tr( "Ctrl+Shift+L", "Add a SpatiaLite Layer" ) );
mActionAddSpatiaLiteLayer->setStatusTip( tr( "Add a SpatiaLite Layer" ) );
connect( mActionAddSpatiaLiteLayer, SIGNAL( triggered() ), this, SLOT( addSpatiaLiteLayer() ) );
//#ifdef HAVE_SPATIALITE
// QgsDebugMsg("HAVE_SPATIALITE is defined");
// assert(0);
//#else
// QgsDebugMsg("HAVE_SPATIALITE not defined");
// assert(0);
//#endif

mActionAddWmsLayer = new QAction( getThemeIcon( "mActionAddWmsLayer.png" ), tr( "Add WMS Layer..." ), this );
shortcuts->registerAction( mActionAddWmsLayer, tr( "Ctrl+Shift+W", "Add a Web Mapping Server Layer" ) );
@@ -6724,7 +6711,13 @@ void QgisApp::namUpdate()
}

#if QT_VERSION >= 0x40500
mNAM->setProxyFactory( new QgsNetworkProxyFactory( proxy, excludes ) );
if( !mProxyFactory )
{
mProxyFactory = new QgsNetworkProxyFactory();
mNAM->setProxyFactory( mProxyFactory );
}

mProxyFactory->setProxyAndExcludes( proxy, excludes );

QNetworkDiskCache *cache = qobject_cast<QNetworkDiskCache*>( nam()->cache() );
if ( !cache )
@@ -80,6 +80,10 @@ class QgsGPSInformationWidget;
#include "qgsfeature.h"
#include "qgspoint.h"

#if QT_VERSION >= 0x40500
class QgsNetworkProxyFactory;
#endif

/*! \class QgisApp
* \brief Main window for the Qgis application
*/
@@ -1090,6 +1094,9 @@ class QgisApp : public QMainWindow
QgsUndoWidget* mUndoWidget;

QNetworkAccessManager *mNAM;
#if QT_VERSION >= 0x40500
QgsNetworkProxyFactory *mProxyFactory;
#endif

int mLastComposerId;

@@ -26,7 +26,11 @@
#include "qgsnetworkproxyfactory.h"
#include "qgslogger.h"

QgsNetworkProxyFactory::QgsNetworkProxyFactory( const QNetworkProxy &proxy, const QStringList &excludes )
QgsNetworkProxyFactory::QgsNetworkProxyFactory()
{
}

void QgsNetworkProxyFactory::setProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes )
{
mProxy = proxy;
mExcludedURLs = excludes;
@@ -26,10 +26,12 @@
class QgsNetworkProxyFactory : public QNetworkProxyFactory
{
public:
QgsNetworkProxyFactory( const QNetworkProxy &proxy, const QStringList &excludes );
QgsNetworkProxyFactory();
virtual ~QgsNetworkProxyFactory();
virtual QList<QNetworkProxy> queryProxy( const QNetworkProxyQuery & query = QNetworkProxyQuery() );

void setProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );

private:
QStringList mExcludedURLs;
QNetworkProxy mProxy;

0 comments on commit ff499bc

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