Skip to content
Permalink
Browse files

Modernize code

(cherry-picked from 409d47e)
  • Loading branch information
nyalldawson committed Jul 24, 2018
1 parent a1f8efa commit b3879cfd0de152740f980a1a16ce7f90c5692ad0
Showing with 13 additions and 13 deletions.
  1. +8 −8 src/providers/wfs/qgswfsrequest.cpp
  2. +5 −5 src/providers/wfs/qgswfsshareddata.cpp
@@ -78,7 +78,7 @@ bool QgsWfsRequest::sendGET( const QUrl &url, bool synchronous, bool forceRefres
QString modifiedUrlString = modifiedUrl.toString();
// Qt5 does URL encoding from some reason (of the FILTER parameter for example)
modifiedUrlString = QUrl::fromPercentEncoding( modifiedUrlString.toUtf8() );
QgsDebugMsg( QString( "Get %1" ).arg( modifiedUrlString ) );
QgsDebugMsg( QStringLiteral( "Get %1" ).arg( modifiedUrlString ) );
modifiedUrlString = modifiedUrlString.mid( QStringLiteral( "http://" ).size() );
QString args = modifiedUrlString.mid( modifiedUrlString.indexOf( '?' ) );
if ( modifiedUrlString.size() > 256 )
@@ -280,7 +280,7 @@ void QgsWfsRequest::abort()

void QgsWfsRequest::replyProgress( qint64 bytesReceived, qint64 bytesTotal )
{
QgsDebugMsg( QStringLiteral( "%1 of %2 bytes downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QString( "unknown number of" ) : QString::number( bytesTotal ) ) );
QgsDebugMsg( QStringLiteral( "%1 of %2 bytes downloaded." ).arg( bytesReceived ).arg( bytesTotal < 0 ? QStringLiteral( "unknown number of" ) : QString::number( bytesTotal ) ) );

if ( bytesReceived != 0 )
mGotNonEmptyResponse = true;
@@ -307,11 +307,11 @@ void QgsWfsRequest::replyFinished()
{
if ( mReply->error() == QNetworkReply::NoError )
{
QgsDebugMsg( "reply OK" );
QgsDebugMsg( QStringLiteral( "reply OK" ) );
QVariant redirect = mReply->attribute( QNetworkRequest::RedirectionTargetAttribute );
if ( !redirect.isNull() )
{
QgsDebugMsg( "Request redirected." );
QgsDebugMsg( QStringLiteral( "Request redirected." ) );

const QUrl &toUrl = redirect.toUrl();
mReply->request();
@@ -339,7 +339,7 @@ void QgsWfsRequest::replyFinished()
mReply->deleteLater();
mReply = nullptr;

QgsDebugMsg( QString( "redirected: %1 forceRefresh=%2" ).arg( redirect.toString() ).arg( mForceRefresh ) );
QgsDebugMsg( QStringLiteral( "redirected: %1 forceRefresh=%2" ).arg( redirect.toString() ).arg( mForceRefresh ) );
mReply = QgsNetworkAccessManager::instance()->get( request );
mReply->setReadBufferSize( READ_BUFFER_SIZE_HINT );
if ( !mUri.auth().setAuthorizationReply( mReply ) )
@@ -372,7 +372,7 @@ void QgsWfsRequest::replyFinished()
}
cmd.setRawHeaders( hl );

QgsDebugMsg( QString( "expirationDate:%1" ).arg( cmd.expirationDate().toString() ) );
QgsDebugMsg( QStringLiteral( "expirationDate:%1" ).arg( cmd.expirationDate().toString() ) );
if ( cmd.expirationDate().isNull() )
{
cmd.setExpirationDate( QDateTime::currentDateTime().addSecs( defaultExpirationInSec() ) );
@@ -382,12 +382,12 @@ void QgsWfsRequest::replyFinished()
}
else
{
QgsDebugMsg( "No cache!" );
QgsDebugMsg( QStringLiteral( "No cache!" ) );
}

#ifdef QGISDEBUG
bool fromCache = mReply->attribute( QNetworkRequest::SourceIsFromCacheAttribute ).toBool();
QgsDebugMsg( QString( "Reply was cached: %1" ).arg( fromCache ) );
QgsDebugMsg( QStringLiteral( "Reply was cached: %1" ).arg( fromCache ) );
#endif

mResponse = mReply->readAll();
@@ -219,7 +219,7 @@ bool QgsWFSSharedData::createCache()
Q_ASSERT( !QFile::exists( mCacheDbname ) );

QgsFields cacheFields;
Q_FOREACH ( const QgsField &field, mFields )
for ( const QgsField &field : qgis::as_const( mFields ) )
{
QVariant::Type type = field.type();
// Map DateTime to int64 milliseconds from epoch
@@ -261,11 +261,11 @@ bool QgsWFSSharedData::createCache()
vsimemFilename.sprintf( "/vsimem/qgis_wfs_cache_template_%p/features.sqlite", this );
mCacheTablename = CPLGetBasename( vsimemFilename.toStdString().c_str() );
VSIUnlink( vsimemFilename.toStdString().c_str() );
QgsVectorFileWriter *writer = new QgsVectorFileWriter( vsimemFilename, QLatin1String( "" ),
std::unique_ptr< QgsVectorFileWriter > writer = qgis::make_unique< QgsVectorFileWriter >( vsimemFilename, QString(),
cacheFields, QgsWkbTypes::Polygon, QgsCoordinateReferenceSystem(), QStringLiteral( "SpatiaLite" ), datasourceOptions, layerOptions );
if ( writer->hasError() == QgsVectorFileWriter::NoError )
{
delete writer;
writer.reset();

// Copy the temporary database back to disk
vsi_l_offset nLength = 0;
@@ -293,7 +293,7 @@ bool QgsWFSSharedData::createCache()
// not define SPATIALITE_412_OR_LATER, and thus the call to
// spatialite_init() may cause failures, which will require using the
// slower method
delete writer;
writer.reset();
VSIUnlink( vsimemFilename.toStdString().c_str() );
}
}
@@ -446,7 +446,7 @@ bool QgsWFSSharedData::createCache()
// regarding crashes, since this is a temporary DB
QgsDataSourceUri dsURI;
dsURI.setDatabase( mCacheDbname );
dsURI.setDataSource( QLatin1String( "" ), mCacheTablename, geometryFieldname, QLatin1String( "" ), fidName );
dsURI.setDataSource( QString(), mCacheTablename, geometryFieldname, QString(), fidName );
QStringList pragmas;
pragmas << QStringLiteral( "synchronous=OFF" );
pragmas << QStringLiteral( "journal_mode=WAL" ); // WAL is needed to avoid reader to block writers

0 comments on commit b3879cf

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