Showing with 31 additions and 14 deletions.
  1. +1 −0 .gitignore
  2. +30 −13 src/core/symbology-ng/qgsstylev2.cpp
  3. +0 −1 src/core/symbology-ng/qgssymbollayerv2utils.cpp
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ i18n/*.qm
.idea
/python/plugins/sextante/resources_rc.py
/python/plugins/sextante/about/ui_aboutdialogbase.py
scripts/qgisstyle
43 changes: 30 additions & 13 deletions src/core/symbology-ng/qgsstylev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include <sqlite3.h>

#define STYLE_CURRENT_VERSION "0"
#define STYLE_CURRENT_VERSION "1"

QgsStyleV2 *QgsStyleV2::mDefaultStyle = 0;

Expand Down Expand Up @@ -1343,30 +1343,47 @@ bool QgsStyleV2::importXML( QString filename )
}

QString version = docEl.attribute( "version" );
if ( version != STYLE_CURRENT_VERSION )
if ( version != STYLE_CURRENT_VERSION && version != "0" )
{
mErrorString = "Unknown style file version: " + version;
return false;
}

// load symbols
QgsSymbolV2Map symbols;

QDomElement symbolsElement = docEl.firstChildElement( "symbols" );
QDomElement e = symbolsElement.firstChildElement();
while ( !e.isNull() )

if ( version == STYLE_CURRENT_VERSION )
{
if ( e.tagName() == "symbol" )
// For the new style, load symbols individualy
while ( !e.isNull() )
{
QgsSymbolV2* symbol = QgsSymbolLayerV2Utils::loadSymbol( e );
if ( symbol )
if ( e.tagName() == "symbol" )
{
addSymbol( e.attribute( "name" ), symbol );
QgsSymbolV2* symbol = QgsSymbolLayerV2Utils::loadSymbol( e );
if ( symbol )
{
symbols.insert( e.attribute( "name" ), symbol );
}
}
else
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
else
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
else
{
// for the old version, use the utility function to solve @symbol@layer subsymbols
symbols = QgsSymbolLayerV2Utils::loadSymbols( symbolsElement );
}

// save the symbols with proper name
for ( QMap<QString, QgsSymbolV2*>::iterator it = symbols.begin(); it != symbols.end(); it++ )
{
addSymbol( it.key(), it.value() );
}

// load color ramps
Expand Down
1 change: 0 additions & 1 deletion src/core/symbology-ng/qgssymbollayerv2utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2305,7 +2305,6 @@ void QgsSymbolLayerV2Utils::saveProperties( QgsStringMap props, QDomDocument& do
}
}

// XXX Not used by QgStyleV2 anymore, But renderers use it still
QgsSymbolV2Map QgsSymbolLayerV2Utils::loadSymbols( QDomElement& element )
{
// go through symbols one-by-one and load them
Expand Down