25 QDomElement root = doc.createElement( QStringLiteral(
"qgsScales" ) );
26 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
27 doc.appendChild( root );
29 for (
int i = 0; i < scales.count(); ++i )
31 QDomElement el = doc.createElement( QStringLiteral(
"scale" ) );
32 el.setAttribute( QStringLiteral(
"value" ), scales.at( i ) );
33 root.appendChild( el );
36 QFile file( fileName );
37 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
39 errorMessage = QStringLiteral(
"Cannot write file %1:\n%2." ).arg( fileName, file.errorString() );
43 QTextStream out( &file );
50 QFile file( fileName );
51 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
53 errorMessage = QStringLiteral(
"Cannot read file %1:\n%2." ).arg( fileName, file.errorString() );
62 if ( !doc.setContent( &file,
true, &errorStr, &errorLine, &errorColumn ) )
64 errorMessage = QStringLiteral(
"Parse error at line %1, column %2:\n%3" )
71 const QDomElement root = doc.documentElement();
72 if ( root.tagName() != QLatin1String(
"qgsScales" ) )
74 errorMessage = QStringLiteral(
"The file is not an scales exchange file." );
78 QDomElement child = root.firstChildElement();
79 while ( !child.isNull() )
81 scales.append( child.attribute( QStringLiteral(
"value" ) ) );
82 child = child.nextSiblingElement();