Skip to content

Commit

Permalink
Remove duplicated code and add some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 21, 2015
1 parent b843f81 commit 723f7be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
27 changes: 2 additions & 25 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3822,35 +3822,12 @@ QString QgsVectorLayer::loadNamedStyle( const QString &theURI, bool &theResultFl
return QgsMapLayer::loadNamedStyle( theURI, theResultFlag );
}

bool QgsVectorLayer::applyNamedStyle( QString namedStyle, QString errorMsg )
bool QgsVectorLayer::applyNamedStyle( QString namedStyle, QString& errorMsg )
{
QDomDocument myDocument( "qgis" );
myDocument.setContent( namedStyle );

QDomElement myRoot = myDocument.firstChildElement( "qgis" );

if ( myRoot.isNull() )
{
errorMsg = tr( "Error: qgis element could not be found" );
return false;
}
setScaleBasedVisibility( myRoot.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 );
setMinimumScale( myRoot.attribute( "minimumScale" ).toFloat() );
setMaximumScale( myRoot.attribute( "maximumScale" ).toFloat() );

#if 0
//read transparency level
QDomNode transparencyNode = myRoot.namedItem( "transparencyLevelInt" );
if ( ! transparencyNode.isNull() )
{
// set transparency level only if it's in project
// (otherwise it sets the layer transparent)
QDomElement myElement = transparencyNode.toElement();
setTransparency( myElement.text().toInt() );
}
#endif

return readSymbology( myRoot, errorMsg );
return importNamedStyle( myDocument, errorMsg );
}


Expand Down
12 changes: 11 additions & 1 deletion src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,17 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag ) override;

virtual bool applyNamedStyle( QString namedStyle, QString errorMsg );
/**
* Will load a named style from a provided QML string.
*
* @param namedStyle A QML string
* @param errorMsg An error message indicating problems if any
*
* @return true on success
*
* @deprecated Will be removed for QGIS 3 in favor of importNamedStyle
*/
virtual bool applyNamedStyle( QString namedStyle, QString &errorMsg );

/** convert a saved attribute editor element into a AttributeEditor structure as it's used internally.
* @param elem the DOM element
Expand Down

0 comments on commit 723f7be

Please sign in to comment.