Skip to content
Permalink
Browse files

Add support for copy/pasting blend modes for layers

  • Loading branch information
nyalldawson committed Mar 23, 2013
1 parent 3bb405f commit 4ba3690ff6d6d10c659100feed6a8c4eac5491d5
Showing with 28 additions and 15 deletions.
  1. +0 −15 src/core/qgsmaplayer.cpp
  2. +14 −0 src/core/qgsvectorlayer.cpp
  3. +14 −0 src/core/raster/qgsrasterlayer.cpp
@@ -411,15 +411,6 @@ bool QgsMapLayer::readXML( const QDomNode& layer_node )
setTransparency( myElement.text().toInt() );
}

//read blend mode
QDomNode blendModeNode = layer_node.namedItem( "blendMode" );
if ( ! blendModeNode.isNull() )
{
// set blend mode if it's specified in project
QDomElement myElement = blendModeNode.toElement();
setBlendMode(( QgsMapLayer::BlendMode )myElement.text().toInt() );
}

readCustomProperties( layer_node );

return true;
@@ -536,12 +527,6 @@ bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )
transparencyLevelIntElement.appendChild( transparencyLevelIntText );
maplayer.appendChild( transparencyLevelIntElement );

// <blendMode>
QDomElement blendModeElement = document.createElement( "blendMode" );
QDomText blendModeText = document.createTextNode( QString::number( blendMode() ) );
blendModeElement.appendChild( blendModeText );
maplayer.appendChild( blendModeElement );

// now append layer node to map layer node

layer_node.appendChild( maplayer );
@@ -2260,6 +2260,14 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
setDisplayField( e.text() );
}

// get and set the blend mode if it exists
QDomNode blendModeNode = node.namedItem( "blendMode" );
if ( !blendModeNode.isNull() )
{
QDomElement e = blendModeNode.toElement();
setBlendMode(( QgsMapLayer::BlendMode ) e.text().toInt() );
}

// use scale dependent visibility flag
QDomElement e = node.toElement();
mLabel->setScaleBasedVisibility( e.attribute( "scaleBasedLabelVisibilityFlag", "0" ) == "1" );
@@ -2605,6 +2613,12 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
//save customproperties (for labeling ng)
writeCustomProperties( node, doc );

// add the blend mode field
QDomElement blendModeElem = doc.createElement( "blendMode" );
QDomText blendModeText = doc.createTextNode( QString::number( blendMode() ) );
blendModeElem.appendChild( blendModeText );
node.appendChild( blendModeElem );

// add the display field
QDomElement dField = doc.createElement( "displayfield" );
QDomText dFieldText = doc.createTextNode( displayField() );
@@ -2312,6 +2312,14 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
resampleFilter->readXML( resampleElem );
}

// get and set the blend mode if it exists
QDomNode blendModeNode = layer_node.namedItem( "blendMode" );
if ( !blendModeNode.isNull() )
{
QDomElement e = blendModeNode.toElement();
setBlendMode(( QgsMapLayer::BlendMode ) e.text().toInt() );
}

return true;
} //readSymbology

@@ -2499,6 +2507,12 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum
resampleFilter->writeXML( document, layerElem );
}

// add blend mode node
QDomElement blendModeElement = document.createElement( "blendMode" );
QDomText blendModeText = document.createTextNode( QString::number( blendMode() ) );
blendModeElement.appendChild( blendModeText );
layer_node.appendChild( blendModeElement );

return true;
} // bool QgsRasterLayer::writeSymbology

0 comments on commit 4ba3690

Please sign in to comment.
You can’t perform that action at this time.