Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #9371 from m-kuhn/preserve-layer-visibility-in-off…
Browse files Browse the repository at this point in the history
…line-editing

[offline editing] Preserve layer visibility in offline editing
  • Loading branch information
m-kuhn committed Mar 5, 2019
2 parents 5fca18c + 62dc945 commit 2046450
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -851,6 +851,7 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
QgsLayerTreeNode *newLayerTreeLayerClone = newLayerTreeLayer->clone();
//copy the showFeatureCount property to the new node
newLayerTreeLayerClone->setCustomProperty( CUSTOM_SHOW_FEATURE_COUNT, layerTreeLayer->customProperty( CUSTOM_SHOW_FEATURE_COUNT ) );
newLayerTreeLayerClone->setItemVisibilityChecked( layerTreeLayer->isVisible() );
QgsLayerTreeGroup *grp = qobject_cast<QgsLayerTreeGroup *>( newLayerTreeLayer->parent() );
parentTreeGroup->insertChildNode( index, newLayerTreeLayerClone );
if ( grp )
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsofflineediting.cpp
Expand Up @@ -152,6 +152,7 @@ void TestQgsOfflineEditing::createGeopackageAndSynchronizeBack()
//set on LayerTreeNode showFeatureCount property
QgsLayerTreeLayer *layerTreelayer = QgsProject::instance()->layerTreeRoot()->findLayer( mpLayer->id() );
layerTreelayer->setCustomProperty( QStringLiteral( "showFeatureCount" ), 1 );
layerTreelayer->setItemVisibilityChecked( false );

//convert
mOfflineEditing->convertToOfflineProject( offlineDataPath, offlineDbFile, layerIds, false, QgsOfflineEditing::GPKG );
Expand All @@ -164,6 +165,7 @@ void TestQgsOfflineEditing::createGeopackageAndSynchronizeBack()
//check LayerTreeNode showFeatureCount property
layerTreelayer = QgsProject::instance()->layerTreeRoot()->findLayer( mpLayer->id() );
QCOMPARE( layerTreelayer->customProperty( QStringLiteral( "showFeatureCount" ), 0 ).toInt(), 1 );
QCOMPARE( layerTreelayer->isVisible(), false );

QgsFeature firstFeatureInAction;
it = mpLayer->getFeatures();
Expand Down

0 comments on commit 2046450

Please sign in to comment.