@@ -6799,21 +6799,12 @@ void QgisApp::copyStyle( QgsMapLayer * sourceLayer )
6799
6799
6800
6800
if ( selectionLayer )
6801
6801
{
6802
- QDomImplementation DomImplementation;
6803
- QDomDocumentType documentType =
6804
- DomImplementation.createDocumentType(
6805
- "qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" );
6806
- QDomDocument doc( documentType );
6807
- QDomElement rootNode = doc.createElement( "qgis" );
6808
- rootNode.setAttribute( "version", QString( "%1" ).arg( QGis::QGIS_VERSION ) );
6809
- doc.appendChild( rootNode );
6810
-
6811
- rootNode.setAttribute( "hasScaleBasedVisibilityFlag", selectionLayer->hasScaleBasedVisibility() ? 1 : 0 );
6812
- rootNode.setAttribute( "minimumScale", QString::number( selectionLayer->minimumScale() ) );
6813
- rootNode.setAttribute( "maximumScale", QString::number( selectionLayer->maximumScale() ) );
6814
-
6815
6802
QString errorMsg;
6816
- if ( !selectionLayer->writeSymbology( rootNode, doc, errorMsg ) )
6803
+ QDomDocument doc( "qgis" );
6804
+ selectionLayer->exportNamedStyle( doc, errorMsg );
6805
+
6806
+
6807
+ if ( !errorMsg.isEmpty() )
6817
6808
{
6818
6809
messageBar()->pushMessage( errorMsg,
6819
6810
tr( "Cannot copy style: %1" ),
@@ -6827,7 +6818,7 @@ void QgisApp::copyStyle( QgsMapLayer * sourceLayer )
6827
6818
}
6828
6819
}
6829
6820
/**
6830
- \param destinatioLayer The layer that the clipboard will be pasted to
6821
+ \param destinationLayer The layer that the clipboard will be pasted to
6831
6822
(defaults to the active layer on the legend)
6832
6823
*/
6833
6824
@@ -6851,20 +6842,14 @@ void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
6851
6842
return;
6852
6843
}
6853
6844
6854
- QDomElement rootNode = doc.firstChildElement( "qgis" );
6855
-
6856
- if ( !selectionLayer->readSymbology( rootNode, errorMsg ) )
6845
+ if ( !selectionLayer->importNamedStyle( doc, errorMsg ) )
6857
6846
{
6858
6847
messageBar()->pushMessage( errorMsg,
6859
- tr( "Cannot read style: %1" ),
6848
+ tr( "Cannot paste style: %1" ),
6860
6849
QgsMessageBar::CRITICAL, messageTimeout() );
6861
6850
return;
6862
6851
}
6863
6852
6864
- selectionLayer->setScaleBasedVisibility( rootNode.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 );
6865
- selectionLayer->setMinimumScale( rootNode.attribute( "minimumScale" ).toFloat() );
6866
- selectionLayer->setMaximumScale( rootNode.attribute( "maximumScale" ).toFloat() );
6867
-
6868
6853
mLayerTreeView->refreshLayerSymbology( selectionLayer->id() );
6869
6854
mMapCanvas->clearCache();
6870
6855
mMapCanvas->refresh();
0 commit comments