Skip to content

Commit

Permalink
instantiate proxy factory only once
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13272 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 7, 2010
1 parent 5a2d1cf commit fa23471
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
23 changes: 8 additions & 15 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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" ) );
Expand Down Expand Up @@ -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 )
Expand Down
7 changes: 7 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -1090,6 +1094,9 @@ class QgisApp : public QMainWindow
QgsUndoWidget* mUndoWidget;

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

int mLastComposerId;

Expand Down
6 changes: 5 additions & 1 deletion src/app/qgsnetworkproxyfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgsnetworkproxyfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fa23471

Please sign in to comment.