Skip to content

Commit

Permalink
Fix a bunch of new Qt deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 25, 2021
1 parent e15ec7d commit bdcaae5
Show file tree
Hide file tree
Showing 38 changed files with 217 additions and 27 deletions.
Expand Up @@ -132,7 +132,11 @@ bool QgsExtractSpecificVerticesAlgorithm::prepareAlgorithm( const QVariantMap &p
mGeometryType = QgsWkbTypes::geometryType( source->wkbType() );

QString verticesString = parameterAsString( parameters, QStringLiteral( "VERTICES" ), context );
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList verticesList = verticesString.split( ',', QString::SkipEmptyParts );
#else
const QStringList verticesList = verticesString.split( ',', Qt::SkipEmptyParts );
#endif
for ( const QString &vertex : verticesList )
{
bool ok = false;
Expand Down
6 changes: 5 additions & 1 deletion src/analysis/processing/qgsalgorithmsavefeatures.cpp
Expand Up @@ -88,9 +88,13 @@ QVariantMap QgsSaveFeaturesAlgorithm::processAlgorithm( const QVariantMap &param
createOptions[QStringLiteral( "layerName" )] = layerName;
}

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList datasourceOptions = parameterAsString( parameters, QStringLiteral( "DATASOURCE_OPTIONS" ), context ).trimmed().split( ';', QString::SkipEmptyParts );
QStringList layerOptions = parameterAsString( parameters, QStringLiteral( "LAYER_OPTIONS" ), context ).trimmed().split( ';', QString::SkipEmptyParts );

#else
QStringList datasourceOptions = parameterAsString( parameters, QStringLiteral( "DATASOURCE_OPTIONS" ), context ).trimmed().split( ';', Qt::SkipEmptyParts );
QStringList layerOptions = parameterAsString( parameters, QStringLiteral( "LAYER_OPTIONS" ), context ).trimmed().split( ';', Qt::SkipEmptyParts );
#endif

QString dest;
std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, source->fields(),
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -7232,8 +7232,8 @@ bool QgisApp::fileSave()
tr( "The loaded project file on disk was meanwhile changed. Do you want to overwrite the changes?\n"
"\nLast modification date on load was: %1"
"\nCurrent last modification date is: %2" )
.arg( mProjectLastModified.toString( Qt::DefaultLocaleLongDate ),
QgsProject::instance()->lastModified().toString( Qt::DefaultLocaleLongDate ) ),
.arg( QLocale::system().toString( mProjectLastModified, QLocale::LongFormat ),
QLocale::system().toString( QgsProject::instance()->lastModified(), QLocale::LongFormat ) ),
QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsabout.cpp
Expand Up @@ -87,7 +87,11 @@ void QgsAbout::init()
//ignore the line if it starts with a hash....
if ( !line.isEmpty() && line.at( 0 ) == '#' )
continue;
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myTokens = line.split( '\t', QString::SkipEmptyParts );
#else
QStringList myTokens = line.split( '\t', Qt::SkipEmptyParts );
#endif
lines << myTokens[0];
}
file.close();
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsversioninfo.cpp
Expand Up @@ -61,7 +61,11 @@ void QgsVersionInfo::versionReplyFinished()
pos += contentFlag.length();

versionMessage = versionMessage.mid( pos );
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList parts = versionMessage.split( '|', QString::SkipEmptyParts );
#else
QStringList parts = versionMessage.split( '|', Qt::SkipEmptyParts );
#endif
// check the version from the server against our version
mLatestVersion = parts[0].toInt();
mDownloadInfo = parts.value( 1 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/geocms/geonode/qgsgeonoderequest.cpp
Expand Up @@ -543,7 +543,7 @@ bool QgsGeoNodeRequest::requestBlocking( const QString &endPoint )
QNetworkReply *QgsGeoNodeRequest::requestUrl( const QString &url )
{
QNetworkRequest request( url );
request.setAttribute( QNetworkRequest::FollowRedirectsAttribute, true );
request.setAttribute( QNetworkRequest::RedirectPolicyAttribute, 1 );

QgsSetRequestInitiatorClass( request, QStringLiteral( "QgsGeoNodeRequest" ) );
// Add authentication check here
Expand Down
12 changes: 12 additions & 0 deletions src/core/geometry/qgsgeometryutils.cpp
Expand Up @@ -1101,7 +1101,11 @@ QgsPointSequence QgsGeometryUtils::pointsFromWKT( const QString &wktCoordinateLi
int dim = 2 + is3D + isMeasure;
QgsPointSequence points;

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList coordList = wktCoordinateList.split( ',', QString::SkipEmptyParts );
#else
const QStringList coordList = wktCoordinateList.split( ',', Qt::SkipEmptyParts );
#endif

//first scan through for extra unexpected dimensions
bool foundZ = false;
Expand All @@ -1110,7 +1114,11 @@ QgsPointSequence QgsGeometryUtils::pointsFromWKT( const QString &wktCoordinateLi
QRegularExpression rxIsNumber( QStringLiteral( "^[+-]?(\\d\\.?\\d*[Ee][+\\-]?\\d+|(\\d+\\.\\d*|\\d*\\.\\d+)|\\d+)$" ) );
for ( const QString &pointCoordinates : coordList )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList coordinates = pointCoordinates.split( rx, QString::SkipEmptyParts );
#else
QStringList coordinates = pointCoordinates.split( rx, Qt::SkipEmptyParts );
#endif

// exit with an empty set if one list contains invalid value.
if ( coordinates.filter( rxIsNumber ).size() != coordinates.size() )
Expand All @@ -1133,7 +1141,11 @@ QgsPointSequence QgsGeometryUtils::pointsFromWKT( const QString &wktCoordinateLi

for ( const QString &pointCoordinates : coordList )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList coordinates = pointCoordinates.split( rx, QString::SkipEmptyParts );
#else
QStringList coordinates = pointCoordinates.split( rx, Qt::SkipEmptyParts );
#endif
if ( coordinates.size() < dim )
continue;

Expand Down
4 changes: 4 additions & 0 deletions src/core/geometry/qgspoint.cpp
Expand Up @@ -178,7 +178,11 @@ bool QgsPoint::fromWkt( const QString &wkt )
return true;

QRegularExpression rx( QStringLiteral( "\\s" ) );
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList coordinates = parts.second.split( rx, QString::SkipEmptyParts );
#else
QStringList coordinates = parts.second.split( rx, Qt::SkipEmptyParts );
#endif

// So far the parser hasn't looked at the coordinates. We'll avoid having anything but numbers and return NULL instead of 0 as a coordinate.
// Without this check, "POINT (a, b)" or "POINT (( 4, 3 ))" returned "POINT (0 ,0)"
Expand Down
15 changes: 11 additions & 4 deletions src/core/raster/qgspalettedrasterrenderer.cpp
Expand Up @@ -388,11 +388,18 @@ QgsPalettedRasterRenderer::ClassData QgsPalettedRasterRenderer::classDataFromStr

QRegularExpression linePartRx( QStringLiteral( "[\\s,:]+" ) );

QStringList parts = string.split( '\n', QString::SkipEmptyParts );
const auto constParts = parts;
for ( const QString &part : constParts )
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList parts = string.split( '\n', QString::SkipEmptyParts );
#else
const QStringList parts = string.split( '\n', Qt::SkipEmptyParts );
#endif
for ( const QString &part : parts )
{
QStringList lineParts = part.split( linePartRx, QString::SkipEmptyParts );
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList lineParts = part.split( linePartRx, QString::SkipEmptyParts );
#else
const QStringList lineParts = part.split( linePartRx, Qt::SkipEmptyParts );
#endif
bool ok = false;
switch ( lineParts.count() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/layout/qgslayoutview.cpp
Expand Up @@ -942,7 +942,7 @@ void QgsLayoutView::mousePressEvent( QMouseEvent *event )

if ( !mTool || !event->isAccepted() )
{
if ( event->button() == Qt::MidButton )
if ( event->button() == Qt::MiddleButton )
{
// Pan layout with middle mouse button
setTool( mMidMouseButtonPanTool );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/layout/qgslayoutviewtooltemporarymousepan.cpp
Expand Up @@ -34,7 +34,7 @@ void QgsLayoutViewToolTemporaryMousePan::layoutMoveEvent( QgsLayoutViewMouseEven

void QgsLayoutViewToolTemporaryMousePan::layoutReleaseEvent( QgsLayoutViewMouseEvent *event )
{
if ( event->button() == Qt::MidButton )
if ( event->button() == Qt::MiddleButton )
{
view()->setTool( mPreviousViewTool );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/processing/models/qgsmodelgraphicsview.cpp
Expand Up @@ -228,7 +228,7 @@ void QgsModelGraphicsView::mousePressEvent( QMouseEvent *event )

if ( !mTool || !event->isAccepted() )
{
if ( event->button() == Qt::MidButton )
if ( event->button() == Qt::MiddleButton )
{
// Pan layout with middle mouse button
setTool( mMidMouseButtonPanTool );
Expand Down
Expand Up @@ -33,7 +33,7 @@ void QgsModelViewToolTemporaryMousePan::modelMoveEvent( QgsModelViewMouseEvent *

void QgsModelViewToolTemporaryMousePan::modelReleaseEvent( QgsModelViewMouseEvent *event )
{
if ( event->button() == Qt::MidButton )
if ( event->button() == Qt::MiddleButton )
{
view()->setTool( mPreviousViewTool );
}
Expand Down
4 changes: 4 additions & 0 deletions src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp
Expand Up @@ -6394,7 +6394,11 @@ QVariant QgsProcessingBandWidgetWrapper::widgetValue() const
const QgsProcessingParameterBand *bandParam = static_cast< const QgsProcessingParameterBand * >( parameterDefinition() );
if ( bandParam->allowMultiple() )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList parts = mLineEdit->text().split( ';', QString::SkipEmptyParts );
#else
const QStringList parts = mLineEdit->text().split( ';', Qt::SkipEmptyParts );
#endif
QVariantList res;
res.reserve( parts.count() );
for ( const QString &s : parts )
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsfilewidget.cpp
Expand Up @@ -80,7 +80,11 @@ QString QgsFileWidget::filePath()
QStringList QgsFileWidget::splitFilePaths( const QString &path )
{
QStringList paths;
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList pathParts = path.split( QRegExp( "\"\\s+\"" ), QString::SkipEmptyParts );
#else
const QStringList pathParts = path.split( QRegExp( "\"\\s+\"" ), Qt::SkipEmptyParts );
#endif
for ( const auto &pathsPart : pathParts )
{
QString cleaned = pathsPart;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1878,7 +1878,7 @@ void QgsMapCanvas::endZoomRect( QPoint pos )
void QgsMapCanvas::mousePressEvent( QMouseEvent *e )
{
//use middle mouse button for panning, map tools won't receive any events in that case
if ( e->button() == Qt::MidButton )
if ( e->button() == Qt::MiddleButton )
{
mCanvasProperties->panSelectorDown = true;
panActionStart( mCanvasProperties->mouseLastXY );
Expand Down Expand Up @@ -1920,7 +1920,7 @@ void QgsMapCanvas::mousePressEvent( QMouseEvent *e )
void QgsMapCanvas::mouseReleaseEvent( QMouseEvent *e )
{
//use middle mouse button for panning, map tools won't receive any events in that case
if ( e->button() == Qt::MidButton )
if ( e->button() == Qt::MiddleButton )
{
mCanvasProperties->panSelectorDown = false;
panActionEnd( mCanvasProperties->mouseLastXY );
Expand Down
12 changes: 12 additions & 0 deletions src/gui/qgsrasterformatsaveoptionswidget.cpp
Expand Up @@ -219,7 +219,11 @@ void QgsRasterFormatSaveOptionsWidget::updateOptions()
{
mBlockOptionUpdates++;
QString myOptions = mOptionsMap.value( currentProfileKey() );
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myOptionsList = myOptions.trimmed().split( ' ', QString::SkipEmptyParts );
#else
QStringList myOptionsList = myOptions.trimmed().split( ' ', Qt::SkipEmptyParts );
#endif

// If the default JPEG compression profile was selected, remove PHOTOMETRIC_OVERVIEW=YCBCR
// if the raster is not RGB. Otherwise this is bound to fail afterwards.
Expand Down Expand Up @@ -473,7 +477,11 @@ QString QgsRasterFormatSaveOptionsWidget::currentProfileKey() const

QStringList QgsRasterFormatSaveOptionsWidget::options() const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
return mOptionsMap.value( currentProfileKey() ).trimmed().split( ' ', QString::SkipEmptyParts );
#else
return mOptionsMap.value( currentProfileKey() ).trimmed().split( ' ', Qt::SkipEmptyParts );
#endif
}

QString QgsRasterFormatSaveOptionsWidget::createOptions( const QString &profileName ) const
Expand Down Expand Up @@ -599,7 +607,11 @@ void QgsRasterFormatSaveOptionsWidget::setOptions( const QString &options )
mBlockOptionUpdates++;
mOptionsTable->clearContents();

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList optionsList = options.trimmed().split( ' ', QString::SkipEmptyParts );
#else
const QStringList optionsList = options.trimmed().split( ' ', Qt::SkipEmptyParts );
#endif
for ( const QString &opt : optionsList )
{
int rowCount = mOptionsTable->rowCount();
Expand Down
12 changes: 10 additions & 2 deletions src/gui/qgsrasterpyramidsoptionswidget.cpp
Expand Up @@ -96,7 +96,11 @@ void QgsRasterPyramidsOptionsWidget::updateUi()
it.value()->setChecked( false );
}
tmpStr = mySettings.value( prefix + "overviewList", "" ).toString();
const auto constSplit = tmpStr.split( ' ', QString::SkipEmptyParts );
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList constSplit = tmpStr.split( ' ', QString::SkipEmptyParts );
#else
const QStringList constSplit = tmpStr.split( ' ', Qt::SkipEmptyParts );
#endif
for ( const QString &lev : constSplit )
{
if ( mOverviewCheckBoxes.contains( lev.toInt() ) )
Expand Down Expand Up @@ -195,7 +199,11 @@ void QgsRasterPyramidsOptionsWidget::setOverviewList()
if ( cbxPyramidsLevelsCustom->isChecked() )
{
// should we also validate that numbers are increasing?
const auto constSplit = lePyramidsLevels->text().trimmed().split( ' ', QString::SkipEmptyParts );
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList constSplit = lePyramidsLevels->text().trimmed().split( ' ', QString::SkipEmptyParts );
#else
const QStringList constSplit = lePyramidsLevels->text().trimmed().split( ' ', Qt::SkipEmptyParts );
#endif
for ( const QString &lev : constSplit )
{
QgsDebugMsg( "lev= " + lev );
Expand Down
8 changes: 8 additions & 0 deletions src/gui/raster/qgsrasterlayerproperties.cpp
Expand Up @@ -1898,7 +1898,11 @@ void QgsRasterLayerProperties::pbnImportTransparentPixelValues_clicked()
{
if ( !myInputLine.simplified().startsWith( '#' ) )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
#else
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), Qt::SkipEmptyParts );
#endif
if ( myTokens.count() != 4 )
{
myImportError = true;
Expand Down Expand Up @@ -1931,7 +1935,11 @@ void QgsRasterLayerProperties::pbnImportTransparentPixelValues_clicked()
{
if ( !myInputLine.simplified().startsWith( '#' ) )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
#else
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), Qt::SkipEmptyParts );
#endif
if ( myTokens.count() != 3 && myTokens.count() != 2 ) // 2 for QGIS < 1.9 compatibility
{
myImportError = true;
Expand Down
8 changes: 8 additions & 0 deletions src/gui/raster/qgsrastertransparencywidget.cpp
Expand Up @@ -305,7 +305,11 @@ void QgsRasterTransparencyWidget::pbnImportTransparentPixelValues_clicked()
{
if ( !myInputLine.simplified().startsWith( '#' ) )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
#else
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), Qt::SkipEmptyParts );
#endif
if ( myTokens.count() != 4 )
{
myImportError = true;
Expand Down Expand Up @@ -338,7 +342,11 @@ void QgsRasterTransparencyWidget::pbnImportTransparentPixelValues_clicked()
{
if ( !myInputLine.simplified().startsWith( '#' ) )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
#else
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), Qt::SkipEmptyParts );
#endif
if ( myTokens.count() != 3 && myTokens.count() != 2 ) // 2 for QGIS < 1.9 compatibility
{
myImportError = true;
Expand Down
4 changes: 4 additions & 0 deletions src/gui/symbology/qgsstylemanagerdialog.cpp
Expand Up @@ -585,7 +585,11 @@ void QgsStyleManagerDialog::copyItemsToDefault()
if ( !ok )
return;

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
const QStringList parts = tags.split( ',', QString::SkipEmptyParts );
#else
const QStringList parts = tags.split( ',', Qt::SkipEmptyParts );
#endif
QStringList additionalTags;
additionalTags.reserve( parts.count() );
for ( const QString &tag : parts )
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/gps_importer/qgsbabelformat.cpp
Expand Up @@ -132,12 +132,20 @@ QgsBabelCommand::QgsBabelCommand( const QString &importCmd,
mSupportsExport = false;
if ( !importCmd.isEmpty() )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
mImportCmd = importCmd.split( QRegExp( "\\s" ), QString::SkipEmptyParts );
#else
mImportCmd = importCmd.split( QRegExp( "\\s" ), Qt::SkipEmptyParts );
#endif
mSupportsImport = true;
}
if ( !exportCmd.isEmpty() )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
mExportCmd = exportCmd.split( QRegExp( "\\s" ), QString::SkipEmptyParts );
#else
mExportCmd = exportCmd.split( QRegExp( "\\s" ), Qt::SkipEmptyParts );
#endif
mSupportsExport = true;
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/plugins/gps_importer/qgsgpsdevice.cpp
Expand Up @@ -21,6 +21,7 @@ QgsGpsDevice::QgsGpsDevice( const QString &wptDlCmd, const QString &wptUlCmd,
const QString &rteDlCmd, const QString &rteUlCmd,
const QString &trkDlCmd, const QString &trkUlCmd )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
if ( !wptDlCmd.isEmpty() )
mWptDlCmd = wptDlCmd.split( QRegExp( "\\s" ), QString::SkipEmptyParts );
if ( !wptUlCmd.isEmpty() )
Expand All @@ -33,6 +34,20 @@ QgsGpsDevice::QgsGpsDevice( const QString &wptDlCmd, const QString &wptUlCmd,
mTrkDlCmd = trkDlCmd.split( QRegExp( "\\s" ), QString::SkipEmptyParts );
if ( !trkUlCmd.isEmpty() )
mTrkUlCmd = trkUlCmd.split( QRegExp( "\\s" ), QString::SkipEmptyParts );
#else
if ( !wptDlCmd.isEmpty() )
mWptDlCmd = wptDlCmd.split( QRegExp( "\\s" ), Qt::SkipEmptyParts );
if ( !wptUlCmd.isEmpty() )
mWptUlCmd = wptUlCmd.split( QRegExp( "\\s" ), Qt::SkipEmptyParts );
if ( !rteDlCmd.isEmpty() )
mRteDlCmd = rteDlCmd.split( QRegExp( "\\s" ), Qt::SkipEmptyParts );
if ( !rteUlCmd.isEmpty() )
mRteUlCmd = rteUlCmd.split( QRegExp( "\\s" ), Qt::SkipEmptyParts );
if ( !trkDlCmd.isEmpty() )
mTrkDlCmd = trkDlCmd.split( QRegExp( "\\s" ), Qt::SkipEmptyParts );
if ( !trkUlCmd.isEmpty() )
mTrkUlCmd = trkUlCmd.split( QRegExp( "\\s" ), Qt::SkipEmptyParts );
#endif
}


Expand Down

0 comments on commit bdcaae5

Please sign in to comment.