26 QDomElement root = doc.createElement( QStringLiteral(
"qgsScales" ) );
27 root.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0" ) );
28 doc.appendChild( root );
30 for (
int i = 0; i < scales.count(); ++i )
32 QDomElement el = doc.createElement( QStringLiteral(
"scale" ) );
33 el.setAttribute( QStringLiteral(
"value" ), scales.at( i ) );
34 root.appendChild( el );
37 QFile file( fileName );
38 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
40 errorMessage = QStringLiteral(
"Cannot write file %1:\n%2." ).arg( fileName, file.errorString() );
44 QTextStream out( &file );
51 QFile file( fileName );
52 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
54 errorMessage = QStringLiteral(
"Cannot read file %1:\n%2." ).arg( fileName, file.errorString() );
63 if ( !doc.setContent( &file,
true, &errorStr, &errorLine, &errorColumn ) )
65 errorMessage = QStringLiteral(
"Parse error at line %1, column %2:\n%3" )
72 const QDomElement root = doc.documentElement();
73 if ( root.tagName() != QLatin1String(
"qgsScales" ) )
75 errorMessage = QStringLiteral(
"The file is not an scales exchange file." );
79 QDomElement child = root.firstChildElement();
80 while ( !child.isNull() )
82 scales.append( child.attribute( QStringLiteral(
"value" ) ) );
83 child = child.nextSiblingElement();
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)