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