Skip to content

Commit

Permalink
Add full test suite for QgsMapLayerRegistry, also don't emit
Browse files Browse the repository at this point in the history
any layer removed signals when no layers will actually be
removed
  • Loading branch information
nyalldawson committed Jul 4, 2016
1 parent 6b3cb24 commit 1a08f0a
Show file tree
Hide file tree
Showing 4 changed files with 452 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/core/qgsmaplayerregistry.sip
Expand Up @@ -35,7 +35,7 @@ class QgsMapLayerRegistry : QObject
*/
QList<QgsMapLayer *> mapLayersByName( const QString& layerName ) const;

/** Returns a list of all registered layers.
/** Returns a map of all registered layers by layer ID.
* @see mapLayer()
* @see mapLayersByName()
* @see layers()
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsmaplayerregistry.cpp
Expand Up @@ -130,6 +130,9 @@ void QgsMapLayerRegistry::removeMapLayers( const QList<QgsMapLayer*>& layers )
layerIds << layer->id();
}

if ( layerIds.isEmpty() )
return;

emit layersWillBeRemoved( layerIds );
emit layersWillBeRemoved( layers );

Expand Down
5 changes: 3 additions & 2 deletions src/core/qgsmaplayerregistry.h
Expand Up @@ -62,14 +62,14 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
*/
QList<QgsMapLayer *> mapLayersByName( const QString& layerName ) const;

/** Returns a list of all registered layers.
/** Returns a map of all registered layers by layer ID.
* @see mapLayer()
* @see mapLayersByName()
* @see layers()
*/
QMap<QString, QgsMapLayer*> mapLayers() const;

/** Rerturns a list of registered map layers with a specified layer type.
/** Returns a list of registered map layers with a specified layer type.
*
* Example:
*
Expand Down Expand Up @@ -183,6 +183,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
* @see removeMapLayer()
* @see removeAllMapLayers()
*/
//TODO QGIS 3.0 - add PyName alias to avoid list type conversion error
void removeMapLayers( const QList<QgsMapLayer*>& layers );

/**
Expand Down

0 comments on commit 1a08f0a

Please sign in to comment.