Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Modernize code
  • Loading branch information
nyalldawson committed Jul 24, 2018
1 parent 84d87a7 commit 409d47e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/providers/wfs/qgswfsrequest.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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 ) )
Expand Down Expand Up @@ -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() ) );
Expand All @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions src/providers/wfs/qgswfsshareddata.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() );
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 409d47e

Please sign in to comment.