diff --git a/src/core/composer/qgscomposerlegend.cpp b/src/core/composer/qgscomposerlegend.cpp index 182703d5f77..737fb6da994 100644 --- a/src/core/composer/qgscomposerlegend.cpp +++ b/src/core/composer/qgscomposerlegend.cpp @@ -624,20 +624,20 @@ void QgsComposerLegend::setComposerMap( const QgsComposerMap *map ) { if ( mComposerMap ) { - disconnect( mComposerMap, SIGNAL( destroyed( QObject * ) ), this, SLOT( invalidateCurrentMap() ) ); - disconnect( mComposerMap, SIGNAL( itemChanged() ), this, SLOT( updateFilterByMap() ) ); - disconnect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( updateFilterByMap() ) ); - disconnect( mComposerMap, SIGNAL( layerStyleOverridesChanged() ), this, SLOT( mapLayerStyleOverridesChanged() ) ); + disconnect( mComposerMap, &QObject::destroyed, this, &QgsComposerLegend::invalidateCurrentMap ); + disconnect( mComposerMap, &QgsComposerObject::itemChanged, this, &QgsComposerLegend::updateFilterByMapAndRedraw ); + disconnect( mComposerMap, &QgsComposerMap::extentChanged, this, &QgsComposerLegend::updateFilterByMapAndRedraw ); + disconnect( mComposerMap, &QgsComposerMap::layerStyleOverridesChanged, this, &QgsComposerLegend::mapLayerStyleOverridesChanged ); } mComposerMap = map; if ( map ) { - QObject::connect( map, SIGNAL( destroyed( QObject * ) ), this, SLOT( invalidateCurrentMap() ) ); - QObject::connect( map, SIGNAL( itemChanged() ), this, SLOT( updateFilterByMap() ) ); - QObject::connect( map, SIGNAL( extentChanged() ), this, SLOT( updateFilterByMap() ) ); - QObject::connect( map, SIGNAL( layerStyleOverridesChanged() ), this, SLOT( mapLayerStyleOverridesChanged() ) ); + connect( map, &QObject::destroyed, this, &QgsComposerLegend::invalidateCurrentMap ); + connect( map, &QgsComposerObject::itemChanged, this, &QgsComposerLegend::updateFilterByMapAndRedraw ); + connect( map, &QgsComposerMap::extentChanged, this, &QgsComposerLegend::updateFilterByMapAndRedraw ); + connect( map, &QgsComposerMap::layerStyleOverridesChanged, this, &QgsComposerLegend::mapLayerStyleOverridesChanged ); } updateItem(); @@ -684,6 +684,11 @@ void QgsComposerLegend::refreshDataDefinedProperty( const QgsComposerObject::Dat QgsComposerObject::refreshDataDefinedProperty( property, context ); } +void QgsComposerLegend::updateFilterByMapAndRedraw() +{ + updateFilterByMap( true ); +} + void QgsComposerLegend::mapLayerStyleOverridesChanged() { if ( !mComposerMap ) diff --git a/src/core/composer/qgscomposerlegend.h b/src/core/composer/qgscomposerlegend.h index 23711e7eea3..d04758b352f 100644 --- a/src/core/composer/qgscomposerlegend.h +++ b/src/core/composer/qgscomposerlegend.h @@ -288,6 +288,9 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem private slots: + + void updateFilterByMapAndRedraw(); + void updateFilterByMap( bool redraw = true ); //! update legend in case style of associated map has changed diff --git a/src/core/gps/qextserialport/posix_qextserialport.cpp b/src/core/gps/qextserialport/posix_qextserialport.cpp index ef59cb3d1e5..72637f4ae91 100644 --- a/src/core/gps/qextserialport/posix_qextserialport.cpp +++ b/src/core/gps/qextserialport/posix_qextserialport.cpp @@ -721,7 +721,7 @@ bool QextSerialPort::open(OpenMode mode) if (queryMode() == QextSerialPort::EventDriven) { readNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); - connect(readNotifier, SIGNAL(activated(int)), this, SIGNAL(readyRead())); + connect(readNotifier, &QSocketNotifier::activated, this, [=] { emit readyRead(); } ); } } else { qDebug() << "could not open file:" << strerror(errno); diff --git a/src/core/gps/qextserialport/qextserialenumerator.h b/src/core/gps/qextserialport/qextserialenumerator.h index a4af415e5db..fcdeb652cd3 100644 --- a/src/core/gps/qextserialport/qextserialenumerator.h +++ b/src/core/gps/qextserialport/qextserialenumerator.h @@ -88,10 +88,10 @@ class QextSerialRegistrationWidget : public QWidget \b Example \code QextSerialEnumerator* enumerator = new QextSerialEnumerator(); - connect(enumerator, SIGNAL(deviceDiscovered(const QextPortInfo &)), - myClass, SLOT(onDeviceDiscovered(const QextPortInfo &))); - connect(enumerator, SIGNAL(deviceRemoved(const QextPortInfo &)), - myClass, SLOT(onDeviceRemoved(const QextPortInfo &))); + connect(enumerator, &QextSerialEnumerator::deviceDiscovered, + myClass, &MyObject::onDeviceDiscovered); + connect(enumerator, &QextSerialEnumerator::deviceRemoved, + myClass, &MyObject::onDeviceRemoved); \endcode \section Credits diff --git a/src/core/gps/qextserialport/qextserialport.h b/src/core/gps/qextserialport/qextserialport.h index 76d6e95c98f..dee04bf8bf3 100644 --- a/src/core/gps/qextserialport/qextserialport.h +++ b/src/core/gps/qextserialport/qextserialport.h @@ -150,7 +150,7 @@ to use, since you never have to worry about checking for new data. \b Example \code QextSerialPort* port = new QextSerialPort("COM1", QextSerialPort::EventDriven); -connect(port, SIGNAL(readyRead()), myClass, SLOT(onDataAvailable())); +connect(port, &QextSerialPort::readyRead, myClass, &MyObject::onDataAvailable); port->open(); void MyClass::onDataAvailable() { diff --git a/src/core/gps/qgsgpsconnection.cpp b/src/core/gps/qgsgpsconnection.cpp index 3c59edd2def..18e63cbb5a3 100644 --- a/src/core/gps/qgsgpsconnection.cpp +++ b/src/core/gps/qgsgpsconnection.cpp @@ -32,7 +32,7 @@ QgsGPSConnection::QgsGPSConnection( QIODevice *dev ): QObject( nullptr ), mSource( dev ), mStatus( NotConnected ) { clearLastGPSInformation(); - QObject::connect( dev, SIGNAL( readyRead() ), this, SLOT( parseData() ) ); + QObject::connect( dev, &QIODevice::readyRead, this, &QgsGPSConnection::parseData ); } QgsGPSConnection::~QgsGPSConnection() diff --git a/src/core/gps/qgsgpsdetector.cpp b/src/core/gps/qgsgpsdetector.cpp index ad28ff5e007..1e1e9e77d72 100644 --- a/src/core/gps/qgsgpsdetector.cpp +++ b/src/core/gps/qgsgpsdetector.cpp @@ -183,8 +183,8 @@ void QgsGPSDetector::advance() } } - connect( mConn, SIGNAL( stateChanged( const QgsGPSInformation & ) ), this, SLOT( detected( const QgsGPSInformation & ) ) ); - connect( mConn, SIGNAL( destroyed( QObject * ) ), this, SLOT( connDestroyed( QObject * ) ) ); + connect( mConn, &QgsGPSConnection::stateChanged, this, static_cast < void ( QgsGPSDetector::* )( const QgsGPSInformation & ) >( &QgsGPSDetector::detected ) ); + connect( mConn, &QObject::destroyed, this, &QgsGPSDetector::connDestroyed ); // leave 2s to pickup a valid string QTimer::singleShot( 2000, this, SLOT( advance() ) ); diff --git a/src/core/gps/qgsqtlocationconnection.cpp b/src/core/gps/qgsqtlocationconnection.cpp index 8c52b8a3e24..c93c943e2aa 100644 --- a/src/core/gps/qgsqtlocationconnection.cpp +++ b/src/core/gps/qgsqtlocationconnection.cpp @@ -171,10 +171,10 @@ void QgsQtLocationConnection::startGPS() locationDataSource->setUpdateInterval( 1000 ); // Whenever the location data source signals that the current // position is updated, the positionUpdated function is called. - QObject::connect( locationDataSource, - SIGNAL( positionUpdated( QGeoPositionInfo ) ), + QObject::connect( locationDataSource.data(), + &QGeoPositionInfoSource::positionUpdated, this, - SLOT( positionUpdated( QGeoPositionInfo ) ) ); + &QgsQtLocationConnection::positionUpdated ); // Start listening for position updates locationDataSource->startUpdates(); } @@ -204,22 +204,18 @@ void QgsQtLocationConnection::startSatelliteMonitor() // Whenever the satellite info source signals that the number of // satellites in use is updated, the satellitesInUseUpdated function // is called - QObject::connect( satelliteInfoSource, - SIGNAL( satellitesInUseUpdated( - const QList & ) ), + QObject::connect( satelliteInfoSource.data(), + &QGeoSatelliteInfoSource::satellitesInUseUpdated, this, - SLOT( satellitesInUseUpdated( - const QList & ) ) ); + &QgsQtLocationConnection::satellitesInUseUpdated ); // Whenever the satellite info source signals that the number of // satellites in view is updated, the satellitesInViewUpdated function // is called - QObject::connect( satelliteInfoSource, - SIGNAL( satellitesInViewUpdated( - const QList & ) ), + QObject::connect( satelliteInfoSource.data(), + &QGeoSatelliteInfoSource::satellitesInViewUpdated, this, - SLOT( satellitesInViewUpdated( - const QList & ) ) ); + &QgsQtLocationConnection::satellitesInViewUpdated ); // Start listening for satellite updates satelliteInfoSource->startUpdates(); diff --git a/src/core/layertree/qgslayertreemodel.cpp b/src/core/layertree/qgslayertreemodel.cpp index 1c4777fb401..6896a9fdee3 100644 --- a/src/core/layertree/qgslayertreemodel.cpp +++ b/src/core/layertree/qgslayertreemodel.cpp @@ -866,9 +866,10 @@ void QgsLayerTreeModel::connectToLayer( QgsLayerTreeLayer *nodeLayer ) // using unique connection because there may be temporarily more nodes for a layer than just one // which would create multiple connections, however disconnect() would disconnect all multiple connections // even if we wanted to disconnect just one connection in each call. - connect( layer, SIGNAL( editingStarted() ), this, SLOT( layerNeedsUpdate() ), Qt::UniqueConnection ); - connect( layer, SIGNAL( editingStopped() ), this, SLOT( layerNeedsUpdate() ), Qt::UniqueConnection ); - connect( layer, SIGNAL( layerModified() ), this, SLOT( layerNeedsUpdate() ), Qt::UniqueConnection ); + QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( layer ); + connect( vl, &QgsVectorLayer::editingStarted, this, &QgsLayerTreeModel::layerNeedsUpdate, Qt::UniqueConnection ); + connect( vl, &QgsVectorLayer::editingStopped, this, &QgsLayerTreeModel::layerNeedsUpdate, Qt::UniqueConnection ); + connect( vl, &QgsVectorLayer::layerModified, this, &QgsLayerTreeModel::layerNeedsUpdate, Qt::UniqueConnection ); } } diff --git a/src/core/layertree/qgslayertreemodellegendnode.cpp b/src/core/layertree/qgslayertreemodellegendnode.cpp index 350a69b7966..8dd19497a63 100644 --- a/src/core/layertree/qgslayertreemodellegendnode.cpp +++ b/src/core/layertree/qgslayertreemodellegendnode.cpp @@ -603,9 +603,9 @@ QImage QgsWmsLegendNode::getLegendGraphic() const mFetcher.reset( prov->getLegendGraphicFetcher( ms ) ); if ( mFetcher ) { - connect( mFetcher.get(), SIGNAL( finish( const QImage & ) ), this, SLOT( getLegendGraphicFinished( const QImage & ) ) ); - connect( mFetcher.get(), SIGNAL( error( const QString & ) ), this, SLOT( getLegendGraphicErrored( const QString & ) ) ); - connect( mFetcher.get(), SIGNAL( progress( qint64, qint64 ) ), this, SLOT( getLegendGraphicProgress( qint64, qint64 ) ) ); + connect( mFetcher.get(), &QgsImageFetcher::finish, this, &QgsWmsLegendNode::getLegendGraphicFinished ); + connect( mFetcher.get(), &QgsImageFetcher::error, this, &QgsWmsLegendNode::getLegendGraphicErrored ); + connect( mFetcher.get(), &QgsImageFetcher::progress, this, &QgsWmsLegendNode::getLegendGraphicProgress ); mFetcher->start(); } // else QgsDebugMsg("XXX No legend supported?"); diff --git a/src/core/layertree/qgslayertreenode.cpp b/src/core/layertree/qgslayertreenode.cpp index d462f2e1b6b..51e2f02296c 100644 --- a/src/core/layertree/qgslayertreenode.cpp +++ b/src/core/layertree/qgslayertreenode.cpp @@ -207,17 +207,18 @@ void QgsLayerTreeNode::insertChildrenPrivate( int index, QList( &QProcess::finished ), this, [ = ] { processExited(); } ); - connect( process, SIGNAL( error( QProcess::ProcessError ) ), this, SLOT( error( QProcess::ProcessError ) ) ); + connect( process, static_cast < void ( QProcess::* )( QProcess::ProcessError ) >( &QProcess::error ), this, &QgsContextHelp::error ); #ifdef Q_OS_WIN if ( QgsApplication::isRunningFromBuildDir() ) diff --git a/src/core/qgsdataitem.cpp b/src/core/qgsdataitem.cpp index ba927b4b506..ac92f4ffc2c 100644 --- a/src/core/qgsdataitem.cpp +++ b/src/core/qgsdataitem.cpp @@ -406,7 +406,7 @@ void QgsDataItem::setParent( QgsDataItem *parent ) connect( this, &QgsDataItem::beginInsertItems, parent, &QgsDataItem::beginInsertItems ); connect( this, &QgsDataItem::endInsertItems, parent, &QgsDataItem::endInsertItems ); connect( this, &QgsDataItem::beginRemoveItems, parent, &QgsDataItem::beginRemoveItems ); - connect( this, SIGNAL( endRemoveItems() ), parent, SIGNAL( endRemoveItems() ) ); + connect( this, &QgsDataItem::endRemoveItems, parent, &QgsDataItem::endRemoveItems ); connect( this, &QgsDataItem::dataChanged, parent, &QgsDataItem::dataChanged ); connect( this, &QgsDataItem::stateChanged, parent, &QgsDataItem::stateChanged ); } diff --git a/src/core/qgsgeometryvalidator.cpp b/src/core/qgsgeometryvalidator.cpp index b9e76c6a315..ffe079228e6 100644 --- a/src/core/qgsgeometryvalidator.cpp +++ b/src/core/qgsgeometryvalidator.cpp @@ -354,7 +354,7 @@ void QgsGeometryValidator::addError( const QgsGeometry::Error &e ) void QgsGeometryValidator::validateGeometry( const QgsGeometry *g, QList &errors ) { QgsGeometryValidator *gv = new QgsGeometryValidator( g, &errors ); - connect( gv, SIGNAL( errorFound( QgsGeometry::Error ) ), gv, SLOT( addError( QgsGeometry::Error ) ) ); + connect( gv, &QgsGeometryValidator::errorFound, gv, &QgsGeometryValidator::addError ); gv->run(); gv->wait(); } diff --git a/src/core/qgsgml.cpp b/src/core/qgsgml.cpp index de560fae6da..778fa74139a 100644 --- a/src/core/qgsgml.cpp +++ b/src/core/qgsgml.cpp @@ -93,8 +93,8 @@ int QgsGml::getFeatures( const QString &uri, QgsWkbTypes::Type *wkbType, QgsRect } } - connect( reply, SIGNAL( finished() ), this, SLOT( setFinished() ) ); - connect( reply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( handleProgressEvent( qint64, qint64 ) ) ); + connect( reply, &QNetworkReply::finished, this, &QgsGml::setFinished ); + connect( reply, &QNetworkReply::downloadProgress, this, &QgsGml::handleProgressEvent ); //find out if there is a QGIS main window. If yes, display a progress dialog QProgressDialog *progressDialog = nullptr; @@ -112,9 +112,9 @@ int QgsGml::getFeatures( const QString &uri, QgsWkbTypes::Type *wkbType, QgsRect { progressDialog = new QProgressDialog( tr( "Loading GML data\n%1" ).arg( mTypeName ), tr( "Abort" ), 0, 0, mainWindow ); progressDialog->setWindowModality( Qt::ApplicationModal ); - connect( this, SIGNAL( dataReadProgress( int ) ), progressDialog, SLOT( setValue( int ) ) ); - connect( this, SIGNAL( totalStepsUpdate( int ) ), progressDialog, SLOT( setMaximum( int ) ) ); - connect( progressDialog, SIGNAL( canceled() ), this, SLOT( setFinished() ) ); + connect( this, &QgsGml::dataReadProgress, progressDialog, &QProgressDialog::setValue ); + connect( this, &QgsGml::totalStepsUpdate, progressDialog, &QProgressDialog::setMaximum ); + connect( progressDialog, &QProgressDialog::canceled, this, &QgsGml::setFinished ); progressDialog->show(); } diff --git a/src/core/qgsmaplayerlegend.cpp b/src/core/qgsmaplayerlegend.cpp index d4b21286313..3761ae3ac03 100644 --- a/src/core/qgsmaplayerlegend.cpp +++ b/src/core/qgsmaplayerlegend.cpp @@ -179,7 +179,7 @@ void QgsMapLayerLegendUtils::applyLayerNodeProperties( QgsLayerTreeLayer *nodeLa QgsDefaultVectorLayerLegend::QgsDefaultVectorLayerLegend( QgsVectorLayer *vl ) : mLayer( vl ) { - connect( mLayer, SIGNAL( rendererChanged() ), this, SIGNAL( itemsChanged() ) ); + connect( mLayer, &QgsMapLayer::rendererChanged, this, &QgsMapLayerLegend::itemsChanged ); } QList QgsDefaultVectorLayerLegend::createLayerTreeModelLegendNodes( QgsLayerTreeLayer *nodeLayer ) @@ -229,7 +229,7 @@ QList QgsDefaultVectorLayerLegend::createLayerTre QgsDefaultRasterLayerLegend::QgsDefaultRasterLayerLegend( QgsRasterLayer *rl ) : mLayer( rl ) { - connect( mLayer, SIGNAL( rendererChanged() ), this, SIGNAL( itemsChanged() ) ); + connect( mLayer, &QgsMapLayer::rendererChanged, this, &QgsMapLayerLegend::itemsChanged ); } QList QgsDefaultRasterLayerLegend::createLayerTreeModelLegendNodes( QgsLayerTreeLayer *nodeLayer ) diff --git a/src/core/qgsmaplayermodel.cpp b/src/core/qgsmaplayermodel.cpp index fbc8271e08e..282ae2012f5 100644 --- a/src/core/qgsmaplayermodel.cpp +++ b/src/core/qgsmaplayermodel.cpp @@ -29,7 +29,7 @@ QgsMapLayerModel::QgsMapLayerModel( const QList &layers, QObject , mAllowEmpty( false ) , mShowCrs( false ) { - connect( QgsProject::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( removeLayers( QStringList ) ) ); + connect( QgsProject::instance(), static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers ); addLayers( layers ); } @@ -40,8 +40,8 @@ QgsMapLayerModel::QgsMapLayerModel( QObject *parent ) , mAllowEmpty( false ) , mShowCrs( false ) { - connect( QgsProject::instance(), SIGNAL( layersAdded( QList ) ), this, SLOT( addLayers( QList ) ) ); - connect( QgsProject::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( removeLayers( QStringList ) ) ); + connect( QgsProject::instance(), &QgsProject::layersAdded, this, &QgsMapLayerModel::addLayers ); + connect( QgsProject::instance(), static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers ); addLayers( QgsProject::instance()->mapLayers().values() ); } diff --git a/src/core/qgsmaprenderersequentialjob.cpp b/src/core/qgsmaprenderersequentialjob.cpp index 2020105573e..95494f91e87 100644 --- a/src/core/qgsmaprenderersequentialjob.cpp +++ b/src/core/qgsmaprenderersequentialjob.cpp @@ -66,7 +66,7 @@ void QgsMapRendererSequentialJob::start() mInternalJob = new QgsMapRendererCustomPainterJob( mSettings, mPainter ); mInternalJob->setCache( mCache ); - connect( mInternalJob, SIGNAL( finished() ), SLOT( internalFinished() ) ); + connect( mInternalJob, &QgsMapRendererJob::finished, this, &QgsMapRendererSequentialJob::internalFinished ); mInternalJob->start(); } diff --git a/src/core/qgsmessagelog.cpp b/src/core/qgsmessagelog.cpp index a75677c1921..e147e635e93 100644 --- a/src/core/qgsmessagelog.cpp +++ b/src/core/qgsmessagelog.cpp @@ -47,8 +47,8 @@ void QgsMessageLog::emitMessage( const QString &message, const QString &tag, Qgs QgsMessageLogConsole::QgsMessageLogConsole() : QObject( QgsApplication::messageLog() ) { - connect( QgsApplication::messageLog(), SIGNAL( messageReceived( QString, QString, QgsMessageLog::MessageLevel ) ), - this, SLOT( logMessage( QString, QString, QgsMessageLog::MessageLevel ) ) ); + connect( QgsApplication::messageLog(), static_cast < void ( QgsMessageLog::* )( const QString &, const QString &, QgsMessageLog::MessageLevel ) >( &QgsMessageLog::messageReceived ), + this, &QgsMessageLogConsole::logMessage ); } void QgsMessageLogConsole::logMessage( const QString &message, const QString &tag, QgsMessageLog::MessageLevel level ) diff --git a/src/core/qgsnetworkaccessmanager.cpp b/src/core/qgsnetworkaccessmanager.cpp index c41f43ceb3f..dd1ecc775cb 100644 --- a/src/core/qgsnetworkaccessmanager.cpp +++ b/src/core/qgsnetworkaccessmanager.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #ifndef QT_NO_SSL #include @@ -214,13 +215,13 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op // uploadProgress. QTimer *timer = new QTimer( reply ); timer->setObjectName( QStringLiteral( "timeoutTimer" ) ); - connect( timer, SIGNAL( timeout() ), this, SLOT( abortRequest() ) ); + connect( timer, &QTimer::timeout, this, &QgsNetworkAccessManager::abortRequest ); timer->setSingleShot( true ); timer->start( s.value( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), "60000" ).toInt() ); - connect( reply, SIGNAL( downloadProgress( qint64, qint64 ) ), timer, SLOT( start() ) ); - connect( reply, SIGNAL( uploadProgress( qint64, qint64 ) ), timer, SLOT( start() ) ); - connect( reply, SIGNAL( finished( ) ), timer, SLOT( stop( ) ) ); + connect( reply, &QNetworkReply::downloadProgress, timer, [timer] { timer->start(); } ); + connect( reply, &QNetworkReply::uploadProgress, timer, [timer] { timer->start(); } ); + connect( reply, &QNetworkReply::finished, timer, &QTimer::stop ); QgsDebugMsgLevel( QString( "Created [reply:%1]" ).arg( ( qint64 ) reply, 0, 16 ), 3 ); return reply; @@ -291,20 +292,20 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache() if ( sMainNAM != this ) { - connect( this, SIGNAL( authenticationRequired( QNetworkReply *, QAuthenticator * ) ), - sMainNAM, SIGNAL( authenticationRequired( QNetworkReply *, QAuthenticator * ) ), + connect( this, &QNetworkAccessManager::authenticationRequired, + sMainNAM, &QNetworkAccessManager::authenticationRequired, Qt::BlockingQueuedConnection ); - connect( this, SIGNAL( proxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ), - sMainNAM, SIGNAL( proxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ), + connect( this, &QNetworkAccessManager::proxyAuthenticationRequired, + sMainNAM, &QNetworkAccessManager::proxyAuthenticationRequired, Qt::BlockingQueuedConnection ); - connect( this, SIGNAL( requestTimedOut( QNetworkReply * ) ), - sMainNAM, SIGNAL( requestTimedOut( QNetworkReply * ) ) ); + connect( this, &QgsNetworkAccessManager::requestTimedOut, + sMainNAM, &QgsNetworkAccessManager::requestTimedOut ); #ifndef QT_NO_SSL - connect( this, SIGNAL( sslErrors( QNetworkReply *, const QList & ) ), - sMainNAM, SIGNAL( sslErrors( QNetworkReply *, const QList & ) ), + connect( this, &QNetworkAccessManager::sslErrors, + sMainNAM, &QNetworkAccessManager::sslErrors, Qt::BlockingQueuedConnection ); #endif } diff --git a/src/core/qgsnetworkcontentfetcher.cpp b/src/core/qgsnetworkcontentfetcher.cpp index 283e816f59e..6cb1453a3b2 100644 --- a/src/core/qgsnetworkcontentfetcher.cpp +++ b/src/core/qgsnetworkcontentfetcher.cpp @@ -59,7 +59,7 @@ void QgsNetworkContentFetcher::fetchContent( const QUrl &url ) } mReply = QgsNetworkAccessManager::instance()->get( request ); - connect( mReply, SIGNAL( finished() ), this, SLOT( contentLoaded() ) ); + connect( mReply, &QNetworkReply::finished, this, [ = ] { contentLoaded(); } ); } QNetworkReply *QgsNetworkContentFetcher::reply() diff --git a/src/core/qgsofflineediting.cpp b/src/core/qgsofflineediting.cpp index 111da773923..4aafa0a03ea 100644 --- a/src/core/qgsofflineediting.cpp +++ b/src/core/qgsofflineediting.cpp @@ -59,7 +59,7 @@ extern "C" QgsOfflineEditing::QgsOfflineEditing() { - connect( QgsProject::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( layerAdded( QgsMapLayer * ) ) ); + connect( QgsProject::instance(), &QgsProject::layerWasAdded, this, &QgsOfflineEditing::layerAdded ); } /** @@ -1372,17 +1372,18 @@ void QgsOfflineEditing::startListenFeatureChanges() // enable logging, check if editBuffer is not null if ( vLayer->editBuffer() ) { - connect( vLayer->editBuffer(), SIGNAL( committedAttributesAdded( const QString &, const QList & ) ), - this, SLOT( committedAttributesAdded( const QString &, const QList & ) ) ); - connect( vLayer->editBuffer(), SIGNAL( committedAttributeValuesChanges( const QString &, const QgsChangedAttributesMap & ) ), - this, SLOT( committedAttributeValuesChanges( const QString &, const QgsChangedAttributesMap & ) ) ); - connect( vLayer->editBuffer(), SIGNAL( committedGeometriesChanges( const QString &, const QgsGeometryMap & ) ), - this, SLOT( committedGeometriesChanges( const QString &, const QgsGeometryMap & ) ) ); + QgsVectorLayerEditBuffer *editBuffer = vLayer->editBuffer(); + connect( editBuffer, &QgsVectorLayerEditBuffer::committedAttributesAdded, + this, &QgsOfflineEditing::committedAttributesAdded ); + connect( editBuffer, &QgsVectorLayerEditBuffer::committedAttributeValuesChanges, + this, &QgsOfflineEditing::committedAttributeValuesChanges ); + connect( editBuffer, &QgsVectorLayerEditBuffer::committedGeometriesChanges, + this, &QgsOfflineEditing::committedGeometriesChanges ); } - connect( vLayer, SIGNAL( committedFeaturesAdded( const QString &, const QgsFeatureList & ) ), - this, SLOT( committedFeaturesAdded( const QString &, const QgsFeatureList & ) ) ); - connect( vLayer, SIGNAL( committedFeaturesRemoved( const QString &, const QgsFeatureIds & ) ), - this, SLOT( committedFeaturesRemoved( const QString &, const QgsFeatureIds & ) ) ); + connect( vLayer, &QgsVectorLayer::committedFeaturesAdded, + this, &QgsOfflineEditing::committedFeaturesAdded ); + connect( vLayer, &QgsVectorLayer::committedFeaturesRemoved, + this, &QgsOfflineEditing::committedFeaturesRemoved ); } void QgsOfflineEditing::stopListenFeatureChanges() @@ -1391,17 +1392,18 @@ void QgsOfflineEditing::stopListenFeatureChanges() // disable logging, check if editBuffer is not null if ( vLayer->editBuffer() ) { - disconnect( vLayer->editBuffer(), SIGNAL( committedAttributesAdded( const QString &, const QList & ) ), - this, SLOT( committedAttributesAdded( const QString &, const QList & ) ) ); - disconnect( vLayer->editBuffer(), SIGNAL( committedAttributeValuesChanges( const QString &, const QgsChangedAttributesMap & ) ), - this, SLOT( committedAttributeValuesChanges( const QString &, const QgsChangedAttributesMap & ) ) ); - disconnect( vLayer->editBuffer(), SIGNAL( committedGeometriesChanges( const QString &, const QgsGeometryMap & ) ), - this, SLOT( committedGeometriesChanges( const QString &, const QgsGeometryMap & ) ) ); + QgsVectorLayerEditBuffer *editBuffer = vLayer->editBuffer(); + disconnect( editBuffer, &QgsVectorLayerEditBuffer::committedAttributesAdded, + this, &QgsOfflineEditing::committedAttributesAdded ); + disconnect( editBuffer, &QgsVectorLayerEditBuffer::committedAttributeValuesChanges, + this, &QgsOfflineEditing::committedAttributeValuesChanges ); + disconnect( editBuffer, &QgsVectorLayerEditBuffer::committedGeometriesChanges, + this, &QgsOfflineEditing::committedGeometriesChanges ); } - disconnect( vLayer, SIGNAL( committedFeaturesAdded( const QString &, const QgsFeatureList & ) ), - this, SLOT( committedFeaturesAdded( const QString &, const QgsFeatureList & ) ) ); - disconnect( vLayer, SIGNAL( committedFeaturesRemoved( const QString &, const QgsFeatureIds & ) ), - this, SLOT( committedFeaturesRemoved( const QString &, const QgsFeatureIds & ) ) ); + disconnect( vLayer, &QgsVectorLayer::committedFeaturesAdded, + this, &QgsOfflineEditing::committedFeaturesAdded ); + disconnect( vLayer, &QgsVectorLayer::committedFeaturesRemoved, + this, &QgsOfflineEditing::committedFeaturesRemoved ); } void QgsOfflineEditing::layerAdded( QgsMapLayer *layer ) @@ -1410,8 +1412,8 @@ void QgsOfflineEditing::layerAdded( QgsMapLayer *layer ) if ( layer->customProperty( CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE, false ).toBool() ) { QgsVectorLayer *vLayer = qobject_cast( layer ); - connect( vLayer, SIGNAL( editingStarted() ), this, SLOT( startListenFeatureChanges() ) ); - connect( vLayer, SIGNAL( editingStopped() ), this, SLOT( stopListenFeatureChanges() ) ); + connect( vLayer, &QgsVectorLayer::editingStarted, this, &QgsOfflineEditing::startListenFeatureChanges ); + connect( vLayer, &QgsVectorLayer::editingStopped, this, &QgsOfflineEditing::stopListenFeatureChanges ); } } diff --git a/src/core/qgspointlocator.cpp b/src/core/qgspointlocator.cpp index 2518d557dbb..f6b63186806 100644 --- a/src/core/qgspointlocator.cpp +++ b/src/core/qgspointlocator.cpp @@ -629,9 +629,9 @@ QgsPointLocator::QgsPointLocator( QgsVectorLayer *layer, const QgsCoordinateRefe mStorage = StorageManager::createNewMemoryStorageManager(); - connect( mLayer, SIGNAL( featureAdded( QgsFeatureId ) ), this, SLOT( onFeatureAdded( QgsFeatureId ) ) ); - connect( mLayer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( onFeatureDeleted( QgsFeatureId ) ) ); - connect( mLayer, SIGNAL( geometryChanged( QgsFeatureId, const QgsGeometry & ) ), this, SLOT( onGeometryChanged( QgsFeatureId, const QgsGeometry & ) ) ); + connect( mLayer, &QgsVectorLayer::featureAdded, this, &QgsPointLocator::onFeatureAdded ); + connect( mLayer, &QgsVectorLayer::featureDeleted, this, &QgsPointLocator::onFeatureDeleted ); + connect( mLayer, &QgsVectorLayer::geometryChanged, this, &QgsPointLocator::onGeometryChanged ); connect( mLayer, &QgsVectorLayer::dataChanged, this, &QgsPointLocator::destroyIndex ); } diff --git a/src/core/qgsproject.cpp b/src/core/qgsproject.cpp index b2ac9c14d50..0a9cd18a878 100644 --- a/src/core/qgsproject.cpp +++ b/src/core/qgsproject.cpp @@ -339,9 +339,9 @@ QgsProject::QgsProject( QObject *parent ) // whenever layers are added to or removed from the registry, // layer tree will be updated mLayerTreeRegistryBridge = new QgsLayerTreeRegistryBridge( mRootGroup, this, this ); - connect( this, SIGNAL( layersAdded( QList ) ), this, SLOT( onMapLayersAdded( QList ) ) ); - connect( this, SIGNAL( layersRemoved( QStringList ) ), this, SLOT( cleanTransactionGroups() ) ); - connect( this, SIGNAL( layersWillBeRemoved( QList ) ), this, SLOT( onMapLayersRemoved( QList ) ) ); + connect( this, &QgsProject::layersAdded, this, &QgsProject::onMapLayersAdded ); + connect( this, &QgsProject::layersRemoved, this, [ = ] { cleanTransactionGroups(); } ); + connect( this, static_cast < void ( QgsProject::* )( const QList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsProject::onMapLayersRemoved ); } @@ -1130,7 +1130,7 @@ void QgsProject::onMapLayersAdded( const QList &layers ) if ( tgChanged ) emit transactionGroupsChanged(); - connect( layer, SIGNAL( configChanged() ), this, SLOT( setDirty() ) ); + connect( layer, &QgsMapLayer::configChanged, this, [ = ] { setDirty(); } ); // check if we have to update connections for layers with dependencies for ( QMap::iterator it = existingMaps.begin(); it != existingMaps.end(); it++ ) @@ -2128,7 +2128,7 @@ QList QgsProject::addMapLayers( { myLayer->setParent( this ); } - connect( myLayer, SIGNAL( destroyed( QObject * ) ), this, SLOT( onMapLayerDeleted( QObject * ) ) ); + connect( myLayer, &QObject::destroyed, this, &QgsProject::onMapLayerDeleted ); emit layerWasAdded( myLayer ); } } diff --git a/src/core/qgsrelationmanager.cpp b/src/core/qgsrelationmanager.cpp index ba11855186a..6c79784ccc8 100644 --- a/src/core/qgsrelationmanager.cpp +++ b/src/core/qgsrelationmanager.cpp @@ -25,9 +25,9 @@ QgsRelationManager::QgsRelationManager( QgsProject *project ) : QObject( project ) , mProject( project ) { - connect( project, SIGNAL( readProject( const QDomDocument & ) ), SLOT( readProject( const QDomDocument & ) ) ); - connect( project, SIGNAL( writeProject( QDomDocument & ) ), SLOT( writeProject( QDomDocument & ) ) ); - connect( project, SIGNAL( layersRemoved( QStringList ) ), this, SLOT( layersRemoved( QStringList ) ) ); + connect( project, &QgsProject::readProject, this, &QgsRelationManager::readProject ); + connect( project, &QgsProject::writeProject, this, &QgsRelationManager::writeProject ); + connect( project, &QgsProject::layersRemoved, this, &QgsRelationManager::layersRemoved ); } void QgsRelationManager::setRelations( const QList &relations ) diff --git a/src/core/qgsrunprocess.cpp b/src/core/qgsrunprocess.cpp index 7d98414762c..2b31a6822d2 100644 --- a/src/core/qgsrunprocess.cpp +++ b/src/core/qgsrunprocess.cpp @@ -40,13 +40,13 @@ QgsRunProcess::QgsRunProcess( const QString &action, bool capture ) if ( capture ) { - connect( mProcess, SIGNAL( error( QProcess::ProcessError ) ), this, SLOT( processError( QProcess::ProcessError ) ) ); - connect( mProcess, SIGNAL( readyReadStandardOutput() ), this, SLOT( stdoutAvailable() ) ); - connect( mProcess, SIGNAL( readyReadStandardError() ), this, SLOT( stderrAvailable() ) ); + connect( mProcess, static_cast < void ( QProcess::* )( QProcess::ProcessError ) >( &QProcess::error ), this, &QgsRunProcess::processError ); + connect( mProcess, &QProcess::readyReadStandardOutput, this, &QgsRunProcess::stdoutAvailable ); + connect( mProcess, &QProcess::readyReadStandardError, this, &QgsRunProcess::stderrAvailable ); // We only care if the process has finished if we are capturing // the output from the process, hence this connect() call is // inside the capture if() statement. - connect( mProcess, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( processExit( int, QProcess::ExitStatus ) ) ); + connect( mProcess, static_cast < void ( QProcess::* )( int, QProcess::ExitStatus ) >( &QProcess::finished ), this, &QgsRunProcess::processExit ); // Use QgsMessageOutput for displaying output to user // It will delete itself when the dialog box is closed. @@ -59,7 +59,7 @@ QgsRunProcess::QgsRunProcess( const QString &action, bool capture ) QObject *mOutputObj = dynamic_cast( mOutput ); if ( mOutputObj ) { - connect( mOutputObj, SIGNAL( destroyed() ), this, SLOT( dialogGone() ) ); + connect( mOutputObj, &QObject::destroyed, this, &QgsRunProcess::dialogGone ); } // start the process! @@ -141,10 +141,10 @@ void QgsRunProcess::dialogGone() mOutput = nullptr; - disconnect( mProcess, SIGNAL( error( QProcess::ProcessError ) ), this, SLOT( processError( QProcess::ProcessError ) ) ); - disconnect( mProcess, SIGNAL( readyReadStandardOutput() ), this, SLOT( stdoutAvailable() ) ); - disconnect( mProcess, SIGNAL( readyReadStandardError() ), this, SLOT( stderrAvailable() ) ); - disconnect( mProcess, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( processExit( int, QProcess::ExitStatus ) ) ); + disconnect( mProcess, static_cast < void ( QProcess::* )( QProcess::ProcessError ) >( &QProcess::error ), this, &QgsRunProcess::processError ); + disconnect( mProcess, &QProcess::readyReadStandardOutput, this, &QgsRunProcess::stdoutAvailable ); + disconnect( mProcess, &QProcess::readyReadStandardError, this, &QgsRunProcess::stderrAvailable ); + disconnect( mProcess, static_cast < void ( QProcess::* )( int, QProcess::ExitStatus ) >( &QProcess::finished ), this, &QgsRunProcess::processExit ); die(); } diff --git a/src/core/qgstracer.cpp b/src/core/qgstracer.cpp index d81e780061a..e0b95973f2a 100644 --- a/src/core/qgstracer.cpp +++ b/src/core/qgstracer.cpp @@ -583,20 +583,20 @@ void QgsTracer::setLayers( const QList &layers ) Q_FOREACH ( QgsVectorLayer *layer, mLayers ) { - disconnect( layer, SIGNAL( featureAdded( QgsFeatureId ) ), this, SLOT( onFeatureAdded( QgsFeatureId ) ) ); - disconnect( layer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( onFeatureDeleted( QgsFeatureId ) ) ); - disconnect( layer, SIGNAL( geometryChanged( QgsFeatureId, const QgsGeometry & ) ), this, SLOT( onGeometryChanged( QgsFeatureId, const QgsGeometry & ) ) ); - disconnect( layer, SIGNAL( destroyed( QObject * ) ), this, SLOT( onLayerDestroyed( QObject * ) ) ); + disconnect( layer, &QgsVectorLayer::featureAdded, this, &QgsTracer::onFeatureAdded ); + disconnect( layer, &QgsVectorLayer::featureDeleted, this, &QgsTracer::onFeatureDeleted ); + disconnect( layer, &QgsVectorLayer::geometryChanged, this, &QgsTracer::onGeometryChanged ); + disconnect( layer, &QObject::destroyed, this, &QgsTracer::onLayerDestroyed ); } mLayers = layers; Q_FOREACH ( QgsVectorLayer *layer, mLayers ) { - connect( layer, SIGNAL( featureAdded( QgsFeatureId ) ), this, SLOT( onFeatureAdded( QgsFeatureId ) ) ); - connect( layer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( onFeatureDeleted( QgsFeatureId ) ) ); - connect( layer, SIGNAL( geometryChanged( QgsFeatureId, const QgsGeometry & ) ), this, SLOT( onGeometryChanged( QgsFeatureId, const QgsGeometry & ) ) ); - connect( layer, SIGNAL( destroyed( QObject * ) ), this, SLOT( onLayerDestroyed( QObject * ) ) ); + connect( layer, &QgsVectorLayer::featureAdded, this, &QgsTracer::onFeatureAdded ); + connect( layer, &QgsVectorLayer::featureDeleted, this, &QgsTracer::onFeatureDeleted ); + connect( layer, &QgsVectorLayer::geometryChanged, this, &QgsTracer::onGeometryChanged ); + connect( layer, &QObject::destroyed, this, &QgsTracer::onLayerDestroyed ); } invalidateGraph(); diff --git a/src/core/qgstransaction.cpp b/src/core/qgstransaction.cpp index 25c272a5fd3..677f70c7eb2 100644 --- a/src/core/qgstransaction.cpp +++ b/src/core/qgstransaction.cpp @@ -110,7 +110,7 @@ bool QgsTransaction::addLayer( QgsVectorLayer *layer ) } connect( this, &QgsTransaction::afterRollback, layer->dataProvider(), &QgsVectorDataProvider::dataChanged ); - connect( QgsProject::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( onLayersDeleted( QStringList ) ) ); + connect( QgsProject::instance(), static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsTransaction::onLayersDeleted ); mLayers.insert( layer ); if ( mTransactionActive ) diff --git a/tests/src/core/testqgis.cpp b/tests/src/core/testqgis.cpp index 8b3c20ca16a..24dc7dd4b34 100644 --- a/tests/src/core/testqgis.cpp +++ b/tests/src/core/testqgis.cpp @@ -160,7 +160,7 @@ void TestQgis::signalBlocker() { std::unique_ptr< QCheckBox > checkbox( new QCheckBox() ); - QSignalSpy spy( checkbox.get(), SIGNAL( toggled( bool ) ) ); + QSignalSpy spy( checkbox.get(), &QCheckBox::toggled ); //first check that signals are not blocked QVERIFY( !checkbox->signalsBlocked() );