Skip to content

Commit 723f7be

Browse files
committedJan 21, 2015
Remove duplicated code and add some documentation
1 parent b843f81 commit 723f7be

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed
 

‎src/core/qgsvectorlayer.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3822,35 +3822,12 @@ QString QgsVectorLayer::loadNamedStyle( const QString &theURI, bool &theResultFl
38223822
return QgsMapLayer::loadNamedStyle( theURI, theResultFlag );
38233823
}
38243824

3825-
bool QgsVectorLayer::applyNamedStyle( QString namedStyle, QString errorMsg )
3825+
bool QgsVectorLayer::applyNamedStyle( QString namedStyle, QString& errorMsg )
38263826
{
38273827
QDomDocument myDocument( "qgis" );
38283828
myDocument.setContent( namedStyle );
38293829

3830-
QDomElement myRoot = myDocument.firstChildElement( "qgis" );
3831-
3832-
if ( myRoot.isNull() )
3833-
{
3834-
errorMsg = tr( "Error: qgis element could not be found" );
3835-
return false;
3836-
}
3837-
setScaleBasedVisibility( myRoot.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 );
3838-
setMinimumScale( myRoot.attribute( "minimumScale" ).toFloat() );
3839-
setMaximumScale( myRoot.attribute( "maximumScale" ).toFloat() );
3840-
3841-
#if 0
3842-
//read transparency level
3843-
QDomNode transparencyNode = myRoot.namedItem( "transparencyLevelInt" );
3844-
if ( ! transparencyNode.isNull() )
3845-
{
3846-
// set transparency level only if it's in project
3847-
// (otherwise it sets the layer transparent)
3848-
QDomElement myElement = transparencyNode.toElement();
3849-
setTransparency( myElement.text().toInt() );
3850-
}
3851-
#endif
3852-
3853-
return readSymbology( myRoot, errorMsg );
3830+
return importNamedStyle( myDocument, errorMsg );
38543831
}
38553832

38563833

‎src/core/qgsvectorlayer.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,17 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
836836
*/
837837
virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag ) override;
838838

839-
virtual bool applyNamedStyle( QString namedStyle, QString errorMsg );
839+
/**
840+
* Will load a named style from a provided QML string.
841+
*
842+
* @param namedStyle A QML string
843+
* @param errorMsg An error message indicating problems if any
844+
*
845+
* @return true on success
846+
*
847+
* @deprecated Will be removed for QGIS 3 in favor of importNamedStyle
848+
*/
849+
virtual bool applyNamedStyle( QString namedStyle, QString &errorMsg );
840850

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

0 commit comments

Comments
 (0)
Please sign in to comment.