Skip to content
Permalink
Browse files
Convert almost all core connects to new style
Just a handful remain which for various reasons cannot
be converted
  • Loading branch information
nyalldawson committed Mar 22, 2017
1 parent b7d2b9f commit a8e8eec95d21e84116aef9c716b7f21f9b6e5fab
@@ -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 )
@@ -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
@@ -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);
@@ -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
@@ -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() {
@@ -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()
@@ -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() ) );
@@ -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<QGeoSatelliteInfo> & ) ),
QObject::connect( satelliteInfoSource.data(),
&QGeoSatelliteInfoSource::satellitesInUseUpdated,
this,
SLOT( satellitesInUseUpdated(
const QList<QGeoSatelliteInfo> & ) ) );
&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<QGeoSatelliteInfo> & ) ),
QObject::connect( satelliteInfoSource.data(),
&QGeoSatelliteInfoSource::satellitesInViewUpdated,
this,
SLOT( satellitesInViewUpdated(
const QList<QGeoSatelliteInfo> & ) ) );
&QgsQtLocationConnection::satellitesInViewUpdated );

// Start listening for satellite updates
satelliteInfoSource->startUpdates();
@@ -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 );
}
}

@@ -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?");

@@ -207,17 +207,18 @@ void QgsLayerTreeNode::insertChildrenPrivate( int index, QList<QgsLayerTreeNode
emit willAddChildren( this, index, indexTo );
for ( int i = 0; i < nodes.count(); ++i )
{
mChildren.insert( index + i, nodes[i] );
QgsLayerTreeNode *node = nodes.at( i );
mChildren.insert( index + i, node );

// forward the signal towards the root
connect( nodes[i], SIGNAL( willAddChildren( QgsLayerTreeNode *, int, int ) ), this, SIGNAL( willAddChildren( QgsLayerTreeNode *, int, int ) ) );
connect( nodes[i], SIGNAL( addedChildren( QgsLayerTreeNode *, int, int ) ), this, SIGNAL( addedChildren( QgsLayerTreeNode *, int, int ) ) );
connect( nodes[i], SIGNAL( willRemoveChildren( QgsLayerTreeNode *, int, int ) ), this, SIGNAL( willRemoveChildren( QgsLayerTreeNode *, int, int ) ) );
connect( nodes[i], SIGNAL( removedChildren( QgsLayerTreeNode *, int, int ) ), this, SIGNAL( removedChildren( QgsLayerTreeNode *, int, int ) ) );
connect( nodes[i], SIGNAL( customPropertyChanged( QgsLayerTreeNode *, QString ) ), this, SIGNAL( customPropertyChanged( QgsLayerTreeNode *, QString ) ) );
connect( nodes[i], &QgsLayerTreeNode::visibilityChanged, this, &QgsLayerTreeNode::visibilityChanged );
connect( nodes[i], SIGNAL( expandedChanged( QgsLayerTreeNode *, bool ) ), this, SIGNAL( expandedChanged( QgsLayerTreeNode *, bool ) ) );
connect( nodes[i], SIGNAL( nameChanged( QgsLayerTreeNode *, QString ) ), this, SIGNAL( nameChanged( QgsLayerTreeNode *, QString ) ) );
connect( node, &QgsLayerTreeNode::willAddChildren, this, &QgsLayerTreeNode::willAddChildren );
connect( node, &QgsLayerTreeNode::addedChildren, this, &QgsLayerTreeNode::addedChildren );
connect( node, &QgsLayerTreeNode::willRemoveChildren, this, &QgsLayerTreeNode::willRemoveChildren );
connect( node, &QgsLayerTreeNode::removedChildren, this, &QgsLayerTreeNode::removedChildren );
connect( node, &QgsLayerTreeNode::customPropertyChanged, this, &QgsLayerTreeNode::customPropertyChanged );
connect( node, &QgsLayerTreeNode::visibilityChanged, this, &QgsLayerTreeNode::visibilityChanged );
connect( node, &QgsLayerTreeNode::expandedChanged, this, &QgsLayerTreeNode::expandedChanged );
connect( node, &QgsLayerTreeNode::nameChanged, this, &QgsLayerTreeNode::nameChanged );
}
emit addedChildren( this, index, indexTo );
}
@@ -46,8 +46,8 @@ QgsBrowserModel::QgsBrowserModel( QObject *parent )
, mFavorites( nullptr )
, mProjectHome( nullptr )
{
connect( QgsProject::instance(), SIGNAL( readProject( const QDomDocument & ) ), this, SLOT( updateProjectHome() ) );
connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument & ) ), this, SLOT( updateProjectHome() ) );
connect( QgsProject::instance(), &QgsProject::readProject, this, &QgsBrowserModel::updateProjectHome );
connect( QgsProject::instance(), &QgsProject::writeProject, this, &QgsBrowserModel::updateProjectHome );
addRootItems();
}

@@ -413,18 +413,18 @@ void QgsBrowserModel::itemStateChanged( QgsDataItem *item, QgsDataItem::State ol
}
void QgsBrowserModel::connectItem( QgsDataItem *item )
{
connect( item, SIGNAL( beginInsertItems( QgsDataItem *, int, int ) ),
this, SLOT( beginInsertItems( QgsDataItem *, int, int ) ) );
connect( item, SIGNAL( endInsertItems() ),
this, SLOT( endInsertItems() ) );
connect( item, SIGNAL( beginRemoveItems( QgsDataItem *, int, int ) ),
this, SLOT( beginRemoveItems( QgsDataItem *, int, int ) ) );
connect( item, SIGNAL( endRemoveItems() ),
this, SLOT( endRemoveItems() ) );
connect( item, SIGNAL( dataChanged( QgsDataItem * ) ),
this, SLOT( itemDataChanged( QgsDataItem * ) ) );
connect( item, SIGNAL( stateChanged( QgsDataItem *, QgsDataItem::State ) ),
this, SLOT( itemStateChanged( QgsDataItem *, QgsDataItem::State ) ) );
connect( item, &QgsDataItem::beginInsertItems,
this, &QgsBrowserModel::beginInsertItems );
connect( item, &QgsDataItem::endInsertItems,
this, &QgsBrowserModel::endInsertItems );
connect( item, &QgsDataItem::beginRemoveItems,
this, &QgsBrowserModel::beginRemoveItems );
connect( item, &QgsDataItem::endRemoveItems,
this, &QgsBrowserModel::endRemoveItems );
connect( item, &QgsDataItem::dataChanged,
this, &QgsBrowserModel::itemDataChanged );
connect( item, &QgsDataItem::stateChanged,
this, &QgsBrowserModel::itemStateChanged );
}

QStringList QgsBrowserModel::mimeTypes() const
@@ -58,9 +58,9 @@ QProcess *QgsContextHelp::start()
QProcess *process = new QProcess;

// Delete this object if the process terminates
connect( process, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( processExited() ) );
connect( process, static_cast < void ( QProcess::* )( int ) >( &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() )
@@ -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 );
}
@@ -354,7 +354,7 @@ void QgsGeometryValidator::addError( const QgsGeometry::Error &e )
void QgsGeometryValidator::validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &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();
}
@@ -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();
}

@@ -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<QgsLayerTreeModelLegendNode *> QgsDefaultVectorLayerLegend::createLayerTreeModelLegendNodes( QgsLayerTreeLayer *nodeLayer )
@@ -229,7 +229,7 @@ QList<QgsLayerTreeModelLegendNode *> QgsDefaultVectorLayerLegend::createLayerTre
QgsDefaultRasterLayerLegend::QgsDefaultRasterLayerLegend( QgsRasterLayer *rl )
: mLayer( rl )
{
connect( mLayer, SIGNAL( rendererChanged() ), this, SIGNAL( itemsChanged() ) );
connect( mLayer, &QgsMapLayer::rendererChanged, this, &QgsMapLayerLegend::itemsChanged );
}

QList<QgsLayerTreeModelLegendNode *> QgsDefaultRasterLayerLegend::createLayerTreeModelLegendNodes( QgsLayerTreeLayer *nodeLayer )
@@ -29,7 +29,7 @@ QgsMapLayerModel::QgsMapLayerModel( const QList<QgsMapLayer *> &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<QgsMapLayer *> ) ), this, SLOT( addLayers( QList<QgsMapLayer *> ) ) );
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() );
}

@@ -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();
}

0 comments on commit a8e8eec

Please sign in to comment.