Skip to content
Permalink
Browse files

Use QString::number with QDomElement::setAttribute with double/float (f…

…ixes #5749)
  • Loading branch information
jef-n committed Jun 8, 2012
1 parent dbe8853 commit ee2f1bdbaf20c37bb8ba5026b5de73f58a0b6ad0
@@ -284,8 +284,8 @@ void QgsComposerArrow::adaptItemSceneRect()
bool QgsComposerArrow::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
QDomElement composerArrowElem = doc.createElement( "ComposerArrow" );
composerArrowElem.setAttribute( "outlineWidth", outlineWidth() );
composerArrowElem.setAttribute( "arrowHeadWidth", mArrowHeadWidth );
composerArrowElem.setAttribute( "outlineWidth", QString::number( outlineWidth() ) );
composerArrowElem.setAttribute( "arrowHeadWidth", QString::number( mArrowHeadWidth ) );
composerArrowElem.setAttribute( "markerMode", mMarkerMode );
composerArrowElem.setAttribute( "startMarkerFile", mStartMarkerFile );
composerArrowElem.setAttribute( "endMarkerFile", mEndMarkerFile );
@@ -300,14 +300,14 @@ bool QgsComposerArrow::writeXML( QDomElement& elem, QDomDocument & doc ) const

//start point
QDomElement startPointElem = doc.createElement( "StartPoint" );
startPointElem.setAttribute( "x", mStartPoint.x() );
startPointElem.setAttribute( "y", mStartPoint.y() );
startPointElem.setAttribute( "x", QString::number( mStartPoint.x() ) );
startPointElem.setAttribute( "y", QString::number( mStartPoint.y() ) );
composerArrowElem.appendChild( startPointElem );

//stop point
QDomElement stopPointElem = doc.createElement( "StopPoint" );
stopPointElem.setAttribute( "x", mStopPoint.x() );
stopPointElem.setAttribute( "y", mStopPoint.y() );
stopPointElem.setAttribute( "x", QString::number( mStopPoint.x() ) );
stopPointElem.setAttribute( "y", QString::number( mStopPoint.y() ) );
composerArrowElem.appendChild( stopPointElem );

elem.appendChild( composerArrowElem );
@@ -124,13 +124,13 @@ bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) cons
}

//scene rect
composerItemElem.setAttribute( "x", transform().dx() );
composerItemElem.setAttribute( "y", transform().dy() );
composerItemElem.setAttribute( "width", rect().width() );
composerItemElem.setAttribute( "height", rect().height() );
composerItemElem.setAttribute( "x", QString::number( transform().dx() ) );
composerItemElem.setAttribute( "y", QString::number( transform().dy() ) );
composerItemElem.setAttribute( "width", QString::number( rect().width() ) );
composerItemElem.setAttribute( "height", QString::number( rect().height() ) );
composerItemElem.setAttribute( "zValue", QString::number( zValue() ) );
composerItemElem.setAttribute( "outlineWidth", QString::number( pen().widthF() ) );
composerItemElem.setAttribute( "rotation", mRotation );
composerItemElem.setAttribute( "rotation", QString::number( mRotation ) );
composerItemElem.setAttribute( "id", mId );
//position lock for mouse moves/resizes
if ( mItemPositionLocked )
@@ -142,7 +142,7 @@ bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) cons
composerItemElem.setAttribute( "positionLock", "false" );
}

composerItemElem.setAttribute( "lastValidViewScaleFactor", mLastValidViewScaleFactor );
composerItemElem.setAttribute( "lastValidViewScaleFactor", QString::number( mLastValidViewScaleFactor ) );


//frame color
@@ -681,8 +681,8 @@ bool QgsComposerLegend::writeXML( QDomElement& elem, QDomDocument & doc ) const
composerLegendElem.setAttribute( "layerSpace", QString::number( mLayerSpace ) );
composerLegendElem.setAttribute( "symbolSpace", QString::number( mSymbolSpace ) );
composerLegendElem.setAttribute( "iconLabelSpace", QString::number( mIconLabelSpace ) );
composerLegendElem.setAttribute( "symbolWidth", mSymbolWidth );
composerLegendElem.setAttribute( "symbolHeight", mSymbolHeight );
composerLegendElem.setAttribute( "symbolWidth", QString::number( mSymbolWidth ) );
composerLegendElem.setAttribute( "symbolHeight", QString::number( mSymbolHeight ) );
composerLegendElem.setAttribute( "wrapChar", mWrapChar );

if ( mComposerMap )
@@ -659,10 +659,10 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const

//extent
QDomElement extentElem = doc.createElement( "Extent" );
extentElem.setAttribute( "xmin", mExtent.xMinimum() );
extentElem.setAttribute( "xmax", mExtent.xMaximum() );
extentElem.setAttribute( "ymin", mExtent.yMinimum() );
extentElem.setAttribute( "ymax", mExtent.yMaximum() );
extentElem.setAttribute( "xmin", QString::number( mExtent.xMinimum() ) );
extentElem.setAttribute( "xmax", QString::number( mExtent.xMaximum() ) );
extentElem.setAttribute( "ymin", QString::number( mExtent.yMinimum() ) );
extentElem.setAttribute( "ymax", QString::number( mExtent.yMaximum() ) );
composerMapElem.appendChild( extentElem );

//layer set
@@ -681,21 +681,21 @@ bool QgsComposerMap::writeXML( QDomElement& elem, QDomDocument & doc ) const
QDomElement gridElem = doc.createElement( "Grid" );
gridElem.setAttribute( "show", mGridEnabled );
gridElem.setAttribute( "gridStyle", mGridStyle );
gridElem.setAttribute( "intervalX", mGridIntervalX );
gridElem.setAttribute( "intervalY", mGridIntervalY );
gridElem.setAttribute( "offsetX", mGridOffsetX );
gridElem.setAttribute( "offsetY", mGridOffsetY );
gridElem.setAttribute( "penWidth", mGridPen.widthF() );
gridElem.setAttribute( "intervalX", QString::number( mGridIntervalX ) );
gridElem.setAttribute( "intervalY", QString::number( mGridIntervalY ) );
gridElem.setAttribute( "offsetX", QString::number( mGridOffsetX ) );
gridElem.setAttribute( "offsetY", QString::number( mGridOffsetY ) );
gridElem.setAttribute( "penWidth", QString::number( mGridPen.widthF() ) );
gridElem.setAttribute( "penColorRed", mGridPen.color().red() );
gridElem.setAttribute( "penColorGreen", mGridPen.color().green() );
gridElem.setAttribute( "penColorBlue", mGridPen.color().blue() );
gridElem.setAttribute( "crossLength", mCrossLength );
gridElem.setAttribute( "crossLength", QString::number( mCrossLength ) );

//grid annotation
QDomElement annotationElem = doc.createElement( "Annotation" );
annotationElem.setAttribute( "show", mShowGridAnnotation );
annotationElem.setAttribute( "position", mGridAnnotationPosition );
annotationElem.setAttribute( "frameDistance", mAnnotationFrameDistance );
annotationElem.setAttribute( "frameDistance", QString::number( mAnnotationFrameDistance ) );
annotationElem.setAttribute( "direction", mGridAnnotationDirection );
annotationElem.setAttribute( "font", mGridAnnotationFont.toString() );
annotationElem.setAttribute( "precision", mGridAnnotationPrecision );
@@ -268,8 +268,8 @@ bool QgsComposerPicture::writeXML( QDomElement& elem, QDomDocument & doc ) const
}
QDomElement composerPictureElem = doc.createElement( "ComposerPicture" );
composerPictureElem.setAttribute( "file", QgsProject::instance()->writePath( mSourceFile.fileName() ) );
composerPictureElem.setAttribute( "pictureWidth", mPictureWidth );
composerPictureElem.setAttribute( "pictureHeight", mPictureHeight );
composerPictureElem.setAttribute( "pictureWidth", QString::number( mPictureWidth ) );
composerPictureElem.setAttribute( "pictureHeight", QString::number( mPictureHeight ) );
if ( !mRotationMap )
{
composerPictureElem.setAttribute( "mapId", -1 );
@@ -347,16 +347,16 @@ bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc ) cons
}

QDomElement composerScaleBarElem = doc.createElement( "ComposerScaleBar" );
composerScaleBarElem.setAttribute( "height", mHeight );
composerScaleBarElem.setAttribute( "labelBarSpace", mLabelBarSpace );
composerScaleBarElem.setAttribute( "boxContentSpace", mBoxContentSpace );
composerScaleBarElem.setAttribute( "height", QString::number( mHeight ) );
composerScaleBarElem.setAttribute( "labelBarSpace", QString::number( mLabelBarSpace ) );
composerScaleBarElem.setAttribute( "boxContentSpace", QString::number( mBoxContentSpace ) );
composerScaleBarElem.setAttribute( "numSegments", mNumSegments );
composerScaleBarElem.setAttribute( "numSegmentsLeft", mNumSegmentsLeft );
composerScaleBarElem.setAttribute( "numUnitsPerSegment", mNumUnitsPerSegment );
composerScaleBarElem.setAttribute( "segmentMillimeters", mSegmentMillimeters );
composerScaleBarElem.setAttribute( "numMapUnitsPerScaleBarUnit", mNumMapUnitsPerScaleBarUnit );
composerScaleBarElem.setAttribute( "numUnitsPerSegment", QString::number( mNumUnitsPerSegment ) );
composerScaleBarElem.setAttribute( "segmentMillimeters", QString::number( mSegmentMillimeters ) );
composerScaleBarElem.setAttribute( "numMapUnitsPerScaleBarUnit", QString::number( mNumMapUnitsPerScaleBarUnit ) );
composerScaleBarElem.setAttribute( "font", mFont.toString() );
composerScaleBarElem.setAttribute( "outlineWidth", mPen.widthF() );
composerScaleBarElem.setAttribute( "outlineWidth", QString::number( mPen.widthF() ) );
composerScaleBarElem.setAttribute( "unitLabel", mUnitLabeling );

//style
@@ -87,10 +87,10 @@ bool QgsComposerShape::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
QDomElement composerShapeElem = doc.createElement( "ComposerShape" );
composerShapeElem.setAttribute( "shapeType", mShape );
composerShapeElem.setAttribute( "outlineWidth", mPen.widthF() );
composerShapeElem.setAttribute( "outlineWidth", QString::number( mPen.widthF() ) );
composerShapeElem.setAttribute( "transparentFill", mBrush.style() == Qt::NoBrush );
composerShapeElem.setAttribute( "shapeWidth", mShapeWidth );
composerShapeElem.setAttribute( "shapeHeight", mShapeHeight );
composerShapeElem.setAttribute( "shapeWidth", QString::number( mShapeWidth ) );
composerShapeElem.setAttribute( "shapeHeight", QString::number( mShapeHeight ) );
QDomElement outlineColorElem = doc.createElement( "OutlineColor" );
outlineColorElem.setAttribute( "red", mPen.color().red() );
outlineColorElem.setAttribute( "green", mPen.color().green() );
@@ -134,10 +134,10 @@ void QgsComposerTable::adjustFrameToSize()

bool QgsComposerTable::tableWriteXML( QDomElement& elem, QDomDocument & doc ) const
{
elem.setAttribute( "lineTextDist", mLineTextDistance );
elem.setAttribute( "lineTextDist", QString::number( mLineTextDistance ) );
elem.setAttribute( "headerFont", mHeaderFont.toString() );
elem.setAttribute( "contentFont", mContentFont.toString() );
elem.setAttribute( "gridStrokeWidth", mGridStrokeWidth );
elem.setAttribute( "gridStrokeWidth", QString::number( mGridStrokeWidth ) );
elem.setAttribute( "gridColorRed", mGridColor.red() );
elem.setAttribute( "gridColorGreen", mGridColor.green() );
elem.setAttribute( "gridColorBlue", mGridColor.blue() );
@@ -189,8 +189,8 @@ bool QgsComposition::writeXML( QDomElement& composerElem, QDomDocument& doc )
QDomElement compositionElem = doc.createElement( "Composition" );
if ( mPaperItem )
{
compositionElem.setAttribute( "paperWidth", mPaperItem->rect().width() );
compositionElem.setAttribute( "paperHeight", mPaperItem->rect().height() );
compositionElem.setAttribute( "paperWidth", QString::number( mPaperItem->rect().width() ) );
compositionElem.setAttribute( "paperHeight", QString::number( mPaperItem->rect().height() ) );
}

//snapping
@@ -202,9 +202,9 @@ bool QgsComposition::writeXML( QDomElement& composerElem, QDomDocument& doc )
{
compositionElem.setAttribute( "snapping", "0" );
}
compositionElem.setAttribute( "snapGridResolution", mSnapGridResolution );
compositionElem.setAttribute( "snapGridOffsetX", mSnapGridOffsetX );
compositionElem.setAttribute( "snapGridOffsetY", mSnapGridOffsetY );
compositionElem.setAttribute( "snapGridResolution", QString::number( mSnapGridResolution ) );
compositionElem.setAttribute( "snapGridOffsetX", QString::number( mSnapGridOffsetX ) );
compositionElem.setAttribute( "snapGridOffsetY", QString::number( mSnapGridOffsetY ) );

compositionElem.setAttribute( "printResolution", mPrintResolution );
compositionElem.setAttribute( "printAsRaster", mPrintAsRaster );
@@ -37,7 +37,7 @@ void QgsDiagramLayerSettings::writeXML( QDomElement& layerElem, QDomDocument& do
diagramLayerElem.setAttribute( "linePlacementFlags", placementFlags );
diagramLayerElem.setAttribute( "priority", priority );
diagramLayerElem.setAttribute( "obstacle", obstacle );
diagramLayerElem.setAttribute( "dist", dist );
diagramLayerElem.setAttribute( "dist", QString::number( dist ) );
diagramLayerElem.setAttribute( "xPosColumn", xPosColumn );
diagramLayerElem.setAttribute( "yPosColumn", yPosColumn );
layerElem.appendChild( diagramLayerElem );
@@ -90,12 +90,12 @@ void QgsDiagramSettings::writeXML( QDomElement& rendererElem, QDomDocument& doc
categoryElem.setAttribute( "font", font.toString() );
categoryElem.setAttribute( "backgroundColor", backgroundColor.name() );
categoryElem.setAttribute( "backgroundAlpha", backgroundColor.alpha() );
categoryElem.setAttribute( "width", size.width() );
categoryElem.setAttribute( "height", size.height() );
categoryElem.setAttribute( "width", QString::number( size.width() ) );
categoryElem.setAttribute( "height", QString::number( size.height() ) );
categoryElem.setAttribute( "penColor", penColor.name() );
categoryElem.setAttribute( "penWidth", penWidth );
categoryElem.setAttribute( "minScaleDenominator", minScaleDenominator );
categoryElem.setAttribute( "maxScaleDenominator", maxScaleDenominator );
categoryElem.setAttribute( "penWidth", QString::number( penWidth ) );
categoryElem.setAttribute( "minScaleDenominator", QString::number( minScaleDenominator ) );
categoryElem.setAttribute( "maxScaleDenominator", QString::number( maxScaleDenominator ) );
if ( sizeType == MM )
{
categoryElem.setAttribute( "sizeType", "MM" );
@@ -346,12 +346,12 @@ void QgsLinearlyInterpolatedDiagramRenderer::readXML( const QDomElement& elem )
void QgsLinearlyInterpolatedDiagramRenderer::writeXML( QDomElement& layerElem, QDomDocument& doc ) const
{
QDomElement rendererElem = doc.createElement( "LinearlyInterpolatedDiagramRenderer" );
rendererElem.setAttribute( "lowerValue", mLowerValue );
rendererElem.setAttribute( "upperValue", mUpperValue );
rendererElem.setAttribute( "lowerWidth", mLowerSize.width() );
rendererElem.setAttribute( "lowerHeight", mLowerSize.height() );
rendererElem.setAttribute( "upperWidth", mUpperSize.width() );
rendererElem.setAttribute( "upperHeight", mUpperSize.height() );
rendererElem.setAttribute( "lowerValue", QString::number( mLowerValue ) );
rendererElem.setAttribute( "upperValue", QString::number( mUpperValue ) );
rendererElem.setAttribute( "lowerWidth", QString::number( mLowerSize.width() ) );
rendererElem.setAttribute( "lowerHeight", QString::number( mLowerSize.height() ) );
rendererElem.setAttribute( "upperWidth", QString::number( mUpperSize.width() ) );
rendererElem.setAttribute( "upperHeight", QString::number( mUpperSize.height() ) );
rendererElem.setAttribute( "classificationAttribute", mClassificationAttribute );
mSettings.writeXML( rendererElem, doc );
_writeXML( rendererElem, doc );
@@ -1077,7 +1077,7 @@ void QgsLabel::writeXML( QDomNode & layer_node, QDomDocument & document ) const

// size and units
QDomElement size = document.createElement( "size" );
size.setAttribute( "value", mLabelAttributes->size() );
size.setAttribute( "value", QString::number( mLabelAttributes->size() ) );
if ( mLabelAttributes->sizeIsSet() )
{
if ( mLabelFieldIdx[Size] != -1 )
@@ -1244,9 +1244,9 @@ void QgsLabel::writeXML( QDomNode & layer_node, QDomDocument & document ) const
{
QDomElement offset = document.createElement( "offset" );
offset.setAttribute( "units", QgsLabelAttributes::unitsName( mLabelAttributes->offsetType() ) );
offset.setAttribute( "x", mLabelAttributes->xOffset() );
offset.setAttribute( "x", QString::number( mLabelAttributes->xOffset() ) );
offset.setAttribute( "xfieldname", labelField( XOffset ) );
offset.setAttribute( "y", mLabelAttributes->yOffset() );
offset.setAttribute( "y", QString::number( mLabelAttributes->yOffset() ) );
offset.setAttribute( "yfieldname", labelField( YOffset ) );
labelattributes.appendChild( offset );
}
@@ -1255,7 +1255,7 @@ void QgsLabel::writeXML( QDomNode & layer_node, QDomDocument & document ) const
QDomElement angle = document.createElement( "angle" );
if ( mLabelAttributes->angleIsSet() )
{
angle.setAttribute( "value", mLabelAttributes->angle() );
angle.setAttribute( "value", QString::number( mLabelAttributes->angle() ) );
if ( mLabelFieldIdx[Angle] != -1 )
{
angle.setAttribute( "fieldname", labelField( Angle ) );
@@ -1311,7 +1311,7 @@ void QgsLabel::writeXML( QDomNode & layer_node, QDomDocument & document ) const
QDomElement buffersize = document.createElement( "buffersize" );
if ( mLabelAttributes->bufferSizeIsSet() )
{
buffersize.setAttribute( "value", mLabelAttributes->bufferSize() );
buffersize.setAttribute( "value", QString::number( mLabelAttributes->bufferSize() ) );
buffersize.setAttribute( "units", QgsLabelAttributes::unitsName( mLabelAttributes->bufferSizeType() ) );
if ( mLabelFieldIdx[BufferSize] != -1 )
{
@@ -302,8 +302,8 @@ bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )

// use scale dependent visibility flag
maplayer.setAttribute( "hasScaleBasedVisibilityFlag", hasScaleBasedVisibility() ? 1 : 0 );
maplayer.setAttribute( "minimumScale", minimumScale() );
maplayer.setAttribute( "maximumScale", maximumScale() );
maplayer.setAttribute( "minimumScale", QString::number( minimumScale() ) );
maplayer.setAttribute( "maximumScale", QString::number( maximumScale() ) );

// ID
QDomElement layerId = document.createElement( "id" );
@@ -745,8 +745,8 @@ QString QgsMapLayer::saveNamedStyle( const QString theURI, bool & theResultFlag

// use scale dependent visibility flag
myRootNode.setAttribute( "hasScaleBasedVisibilityFlag", hasScaleBasedVisibility() ? 1 : 0 );
myRootNode.setAttribute( "minimumScale", minimumScale() );
myRootNode.setAttribute( "maximumScale", maximumScale() );
myRootNode.setAttribute( "minimumScale", QString::number( minimumScale() ) );
myRootNode.setAttribute( "maximumScale", QString::number( maximumScale() ) );

// <transparencyLevelInt>
QDomElement transparencyLevelIntElement = myDocument.createElement( "transparencyLevelInt" );
@@ -3219,8 +3219,8 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
{
// use scale dependent visibility flag
mapLayerNode.setAttribute( "scaleBasedLabelVisibilityFlag", mLabel->scaleBasedVisibility() ? 1 : 0 );
mapLayerNode.setAttribute( "minLabelScale", mLabel->minScale() );
mapLayerNode.setAttribute( "maxLabelScale", mLabel->maxScale() );
mapLayerNode.setAttribute( "minLabelScale", QString::number( mLabel->minScale() ) );
mapLayerNode.setAttribute( "maxLabelScale", QString::number( mLabel->maxScale() ) );

//classification field(s)
QgsAttributeList attributes = mRenderer->classificationAttributes();
@@ -948,8 +948,8 @@ QDomElement QgsGraduatedSymbolRendererV2::save( QDomDocument& doc )
symbols.insert( symbolName, range.symbol() );

QDomElement rangeElem = doc.createElement( "range" );
rangeElem.setAttribute( "lower", range.lowerValue() );
rangeElem.setAttribute( "upper", range.upperValue() );
rangeElem.setAttribute( "lower", QString::number( range.lowerValue() ) );
rangeElem.setAttribute( "upper", QString::number( range.upperValue() ) );
rangeElem.setAttribute( "symbol", symbolName );
rangeElem.setAttribute( "label", range.label() );
rangesElem.appendChild( rangeElem );

0 comments on commit ee2f1bd

Please sign in to comment.
You can’t perform that action at this time.