Created
June 7, 2012 07:42
-
-
Save jef-n/2887218 to your computer and use it in GitHub Desktop.
don't use QString::number with QDomElement::setAttribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/core/composer/qgscomposerattributetable.cpp b/src/core/composer/qgscomposerattributetable.cpp | |
| index 9770078..ef15b4e 100644 | |
| --- a/src/core/composer/qgscomposerattributetable.cpp | |
| +++ b/src/core/composer/qgscomposerattributetable.cpp | |
| @@ -264,7 +264,7 @@ bool QgsComposerAttributeTable::writeXML( QDomElement& elem, QDomDocument & doc | |
| for ( ; sortIt != mSortInformation.constEnd(); ++sortIt ) | |
| { | |
| QDomElement columnElem = doc.createElement( "column" ); | |
| - columnElem.setAttribute( "index", QString::number( sortIt->first ) ); | |
| + columnElem.setAttribute( "index", sortIt->first ); | |
| columnElem.setAttribute( "ascending", sortIt->second == true ? "true" : "false" ); | |
| sortColumnsElem.appendChild( columnElem ); | |
| } | |
| diff --git a/src/core/composer/qgscomposeritem.cpp b/src/core/composer/qgscomposeritem.cpp | |
| index 5b66b2e..b6cacbc 100644 | |
| --- a/src/core/composer/qgscomposeritem.cpp | |
| +++ b/src/core/composer/qgscomposeritem.cpp | |
| @@ -128,8 +128,8 @@ bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) cons | |
| composerItemElem.setAttribute( "y", transform().dy() ); | |
| composerItemElem.setAttribute( "width", rect().width() ); | |
| composerItemElem.setAttribute( "height", rect().height() ); | |
| - composerItemElem.setAttribute( "zValue", QString::number( zValue() ) ); | |
| - composerItemElem.setAttribute( "outlineWidth", QString::number( pen().widthF() ) ); | |
| + composerItemElem.setAttribute( "zValue", zValue() ); | |
| + composerItemElem.setAttribute( "outlineWidth", pen().widthF() ); | |
| composerItemElem.setAttribute( "rotation", mRotation ); | |
| composerItemElem.setAttribute( "id", mId ); | |
| //position lock for mouse moves/resizes | |
| @@ -148,19 +148,19 @@ bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) cons | |
| //frame color | |
| QDomElement frameColorElem = doc.createElement( "FrameColor" ); | |
| QColor frameColor = pen().color(); | |
| - frameColorElem.setAttribute( "red", QString::number( frameColor.red() ) ); | |
| - frameColorElem.setAttribute( "green", QString::number( frameColor.green() ) ); | |
| - frameColorElem.setAttribute( "blue", QString::number( frameColor.blue() ) ); | |
| - frameColorElem.setAttribute( "alpha", QString::number( frameColor.alpha() ) ); | |
| + frameColorElem.setAttribute( "red", frameColor.red() ); | |
| + frameColorElem.setAttribute( "green", frameColor.green() ); | |
| + frameColorElem.setAttribute( "blue", frameColor.blue() ); | |
| + frameColorElem.setAttribute( "alpha", frameColor.alpha() ); | |
| composerItemElem.appendChild( frameColorElem ); | |
| //background color | |
| QDomElement bgColorElem = doc.createElement( "BackgroundColor" ); | |
| QColor bgColor = brush().color(); | |
| - bgColorElem.setAttribute( "red", QString::number( bgColor.red() ) ); | |
| - bgColorElem.setAttribute( "green", QString::number( bgColor.green() ) ); | |
| - bgColorElem.setAttribute( "blue", QString::number( bgColor.blue() ) ); | |
| - bgColorElem.setAttribute( "alpha", QString::number( bgColor.alpha() ) ); | |
| + bgColorElem.setAttribute( "red", bgColor.red() ); | |
| + bgColorElem.setAttribute( "green", bgColor.green() ); | |
| + bgColorElem.setAttribute( "blue", bgColor.blue() ); | |
| + bgColorElem.setAttribute( "alpha", bgColor.alpha() ); | |
| composerItemElem.appendChild( bgColorElem ); | |
| itemElem.appendChild( composerItemElem ); | |
| diff --git a/src/core/composer/qgscomposerlabel.cpp b/src/core/composer/qgscomposerlabel.cpp | |
| index 2032237..5774fc9 100644 | |
| --- a/src/core/composer/qgscomposerlabel.cpp | |
| +++ b/src/core/composer/qgscomposerlabel.cpp | |
| @@ -125,7 +125,7 @@ bool QgsComposerLabel::writeXML( QDomElement& elem, QDomDocument & doc ) const | |
| QDomElement composerLabelElem = doc.createElement( "ComposerLabel" ); | |
| composerLabelElem.setAttribute( "labelText", mText ); | |
| - composerLabelElem.setAttribute( "margin", QString::number( mMargin ) ); | |
| + composerLabelElem.setAttribute( "margin", mMargin ); | |
| composerLabelElem.setAttribute( "halign", mHAlignment ); | |
| composerLabelElem.setAttribute( "valign", mVAlignment ); | |
| diff --git a/src/core/composer/qgscomposerlegend.cpp b/src/core/composer/qgscomposerlegend.cpp | |
| index a222ea4..2b843b7 100644 | |
| --- a/src/core/composer/qgscomposerlegend.cpp | |
| +++ b/src/core/composer/qgscomposerlegend.cpp | |
| @@ -676,11 +676,11 @@ bool QgsComposerLegend::writeXML( QDomElement& elem, QDomDocument & doc ) const | |
| composerLegendElem.setAttribute( "groupFont", mGroupFont.toString() ); | |
| composerLegendElem.setAttribute( "layerFont", mLayerFont.toString() ); | |
| composerLegendElem.setAttribute( "itemFont", mItemFont.toString() ); | |
| - composerLegendElem.setAttribute( "boxSpace", QString::number( mBoxSpace ) ); | |
| - composerLegendElem.setAttribute( "groupSpace", QString::number( mGroupSpace ) ); | |
| - composerLegendElem.setAttribute( "layerSpace", QString::number( mLayerSpace ) ); | |
| - composerLegendElem.setAttribute( "symbolSpace", QString::number( mSymbolSpace ) ); | |
| - composerLegendElem.setAttribute( "iconLabelSpace", QString::number( mIconLabelSpace ) ); | |
| + composerLegendElem.setAttribute( "boxSpace", mBoxSpace ); | |
| + composerLegendElem.setAttribute( "groupSpace", mGroupSpace ); | |
| + composerLegendElem.setAttribute( "layerSpace", mLayerSpace ); | |
| + composerLegendElem.setAttribute( "symbolSpace", mSymbolSpace ); | |
| + composerLegendElem.setAttribute( "iconLabelSpace", mIconLabelSpace ); | |
| composerLegendElem.setAttribute( "symbolWidth", mSymbolWidth ); | |
| composerLegendElem.setAttribute( "symbolHeight", mSymbolHeight ); | |
| composerLegendElem.setAttribute( "wrapChar", mWrapChar ); | |
| diff --git a/src/core/composer/qgscomposerscalebar.cpp b/src/core/composer/qgscomposerscalebar.cpp | |
| index 46c2766..0d009f0 100644 | |
| --- a/src/core/composer/qgscomposerscalebar.cpp | |
| +++ b/src/core/composer/qgscomposerscalebar.cpp | |
| @@ -380,7 +380,7 @@ bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc ) cons | |
| composerScaleBarElem.appendChild( colorElem ); | |
| //alignment | |
| - composerScaleBarElem.setAttribute( "alignment", QString::number(( int ) mAlignment ) ); | |
| + composerScaleBarElem.setAttribute( "alignment", ( int ) mAlignment ); | |
| elem.appendChild( composerScaleBarElem ); | |
| return _writeXML( composerScaleBarElem, doc ); | |
| diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp | |
| index de919fa..d10d9c9 100644 | |
| --- a/src/core/raster/qgsrasterlayer.cpp | |
| +++ b/src/core/raster/qgsrasterlayer.cpp | |
| @@ -3576,8 +3576,8 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum | |
| for ( it = myPixelList.begin(); it != myPixelList.end(); ++it ) | |
| { | |
| QDomElement pixelListElement = document.createElement( "pixelListEntry" ); | |
| - pixelListElement.setAttribute( "pixelValue", QString::number( it->pixelValue, 'f' ) ); | |
| - pixelListElement.setAttribute( "percentTransparent", QString::number( it->percentTransparent ) ); | |
| + pixelListElement.setAttribute( "pixelValue", it->pixelValue ); | |
| + pixelListElement.setAttribute( "percentTransparent", it->percentTransparent ); | |
| singleValuePixelListElement.appendChild( pixelListElement ); | |
| } | |
| @@ -3594,10 +3594,10 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum | |
| for ( it = myPixelList.begin(); it != myPixelList.end(); ++it ) | |
| { | |
| QDomElement pixelListElement = document.createElement( "pixelListEntry" ); | |
| - pixelListElement.setAttribute( "red", QString::number( it->red, 'f' ) ); | |
| - pixelListElement.setAttribute( "green", QString::number( it->green, 'f' ) ); | |
| - pixelListElement.setAttribute( "blue", QString::number( it->blue, 'f' ) ); | |
| - pixelListElement.setAttribute( "percentTransparent", QString::number( it->percentTransparent ) ); | |
| + pixelListElement.setAttribute( "red", it->red ); | |
| + pixelListElement.setAttribute( "green", it->green ); | |
| + pixelListElement.setAttribute( "blue", it->blue ); | |
| + pixelListElement.setAttribute( "percentTransparent", it->percentTransparent ); | |
| threeValuePixelListElement.appendChild( pixelListElement ); | |
| } | |
| @@ -3622,10 +3622,10 @@ bool QgsRasterLayer::writeSymbology( QDomNode & layer_node, QDomDocument & docum | |
| for ( it = myColorRampItemList.begin(); it != myColorRampItemList.end(); ++it ) | |
| { | |
| QDomElement colorRampEntryElement = document.createElement( "colorRampEntry" ); | |
| - colorRampEntryElement.setAttribute( "red", QString::number( it->color.red() ) ); | |
| - colorRampEntryElement.setAttribute( "green", QString::number( it->color.green() ) ); | |
| - colorRampEntryElement.setAttribute( "blue", QString::number( it->color.blue() ) ); | |
| - colorRampEntryElement.setAttribute( "value", QString::number( it->value, 'f' ) ); | |
| + colorRampEntryElement.setAttribute( "red", it->color.red() ); | |
| + colorRampEntryElement.setAttribute( "green", it->color.green() ); | |
| + colorRampEntryElement.setAttribute( "blue", it->color.blue() ); | |
| + colorRampEntryElement.setAttribute( "value", it->value ); | |
| colorRampEntryElement.setAttribute( "label", it->label ); | |
| customColorRampElement.appendChild( colorRampEntryElement ); | |
| diff --git a/src/core/symbology-ng/qgssvgcache.cpp b/src/core/symbology-ng/qgssvgcache.cpp | |
| index 73bd07b..c457e82 100644 | |
| --- a/src/core/symbology-ng/qgssvgcache.cpp | |
| +++ b/src/core/symbology-ng/qgssvgcache.cpp | |
| @@ -363,7 +363,7 @@ void QgsSvgCache::replaceElemParams( QDomElement& elem, const QColor& fill, cons | |
| } | |
| else if ( value.startsWith( "param(outline-width)" ) ) | |
| { | |
| - elem.setAttribute( attribute.name(), QString::number( outlineWidth ) ); | |
| + elem.setAttribute( attribute.name(), outlineWidth ); | |
| } | |
| } | |
| } | |
| diff --git a/src/core/symbology/qgssymbol.cpp b/src/core/symbology/qgssymbol.cpp | |
| index 4beccb4..833e05e 100644 | |
| --- a/src/core/symbology/qgssymbol.cpp | |
| +++ b/src/core/symbology/qgssymbol.cpp | |
| @@ -540,18 +540,18 @@ bool QgsSymbol::writeXML( QDomNode & item, QDomDocument & document, const QgsVec | |
| } | |
| QDomElement outlinecolor = document.createElement( "outlinecolor" ); | |
| - outlinecolor.setAttribute( "red", QString::number( mPen.color().red() ) ); | |
| - outlinecolor.setAttribute( "green", QString::number( mPen.color().green() ) ); | |
| - outlinecolor.setAttribute( "blue", QString::number( mPen.color().blue() ) ); | |
| + outlinecolor.setAttribute( "red", mPen.color().red() ); | |
| + outlinecolor.setAttribute( "green", mPen.color().green() ); | |
| + outlinecolor.setAttribute( "blue", mPen.color().blue() ); | |
| symbol.appendChild( outlinecolor ); | |
| appendText( symbol, document, "outlinestyle", QgsSymbologyUtils::penStyle2QString( mPen.style() ) ); | |
| appendText( symbol, document, "outlinewidth", QString::number( mPen.widthF() ) ); | |
| QDomElement fillcolor = document.createElement( "fillcolor" ); | |
| - fillcolor.setAttribute( "red", QString::number( mBrush.color().red() ) ); | |
| - fillcolor.setAttribute( "green", QString::number( mBrush.color().green() ) ); | |
| - fillcolor.setAttribute( "blue", QString::number( mBrush.color().blue() ) ); | |
| + fillcolor.setAttribute( "red", mBrush.color().red() ); | |
| + fillcolor.setAttribute( "green", mBrush.color().green() ); | |
| + fillcolor.setAttribute( "blue", mBrush.color().blue() ); | |
| symbol.appendChild( fillcolor ); | |
| appendText( symbol, document, "fillpattern", QgsSymbologyUtils::brushStyle2QString( mBrush.style() ) ); | |
| diff --git a/src/mapserver/qgsconfigparser.cpp b/src/mapserver/qgsconfigparser.cpp | |
| index 3209ad8..5559421 100644 | |
| --- a/src/mapserver/qgsconfigparser.cpp | |
| +++ b/src/mapserver/qgsconfigparser.cpp | |
| @@ -112,10 +112,10 @@ void QgsConfigParser::appendLayerBoundingBoxes( QDomElement& layerElem, | |
| if ( version == "1.1.1" ) // WMS Version 1.1.1 | |
| { | |
| ExGeoBBoxElement = doc.createElement( "LatLonBoundingBox" ); | |
| - ExGeoBBoxElement.setAttribute( "minx", QString::number( wgs84BoundingRect.xMinimum() ) ); | |
| - ExGeoBBoxElement.setAttribute( "maxx", QString::number( wgs84BoundingRect.xMaximum() ) ); | |
| - ExGeoBBoxElement.setAttribute( "miny", QString::number( wgs84BoundingRect.yMinimum() ) ); | |
| - ExGeoBBoxElement.setAttribute( "maxy", QString::number( wgs84BoundingRect.yMaximum() ) ); | |
| + ExGeoBBoxElement.setAttribute( "minx", wgs84BoundingRect.xMinimum() ); | |
| + ExGeoBBoxElement.setAttribute( "maxx", wgs84BoundingRect.xMaximum() ); | |
| + ExGeoBBoxElement.setAttribute( "miny", wgs84BoundingRect.yMinimum() ); | |
| + ExGeoBBoxElement.setAttribute( "maxy", wgs84BoundingRect.yMaximum() ); | |
| } | |
| else // WMS Version 1.3.0 | |
| { | |
| diff --git a/src/mapserver/qgsprojectparser.cpp b/src/mapserver/qgsprojectparser.cpp | |
| index 5bd1080..e8f24a4 100644 | |
| --- a/src/mapserver/qgsprojectparser.cpp | |
| +++ b/src/mapserver/qgsprojectparser.cpp | |
| @@ -199,10 +199,10 @@ void QgsProjectParser::featureTypeList( QDomElement& parentElement, QDomDocument | |
| QgsRectangle layerExtent = layer->extent(); | |
| QDomElement bBoxElement = doc.createElement( "LatLongBoundingBox" ); | |
| - bBoxElement.setAttribute( "minx", QString::number( layerExtent.xMinimum() ) ); | |
| - bBoxElement.setAttribute( "miny", QString::number( layerExtent.yMinimum() ) ); | |
| - bBoxElement.setAttribute( "maxx", QString::number( layerExtent.xMaximum() ) ); | |
| - bBoxElement.setAttribute( "maxy", QString::number( layerExtent.yMaximum() ) ); | |
| + bBoxElement.setAttribute( "minx", layerExtent.xMinimum() ); | |
| + bBoxElement.setAttribute( "miny", layerExtent.yMinimum() ); | |
| + bBoxElement.setAttribute( "maxx", layerExtent.xMaximum() ); | |
| + bBoxElement.setAttribute( "maxy", layerExtent.yMaximum() ); | |
| layerElem.appendChild( bBoxElement ); | |
| parentElement.appendChild( layerElem ); | |
| diff --git a/src/mapserver/qgswfsserver.cpp b/src/mapserver/qgswfsserver.cpp | |
| index bf36527..9241959 100644 | |
| --- a/src/mapserver/qgswfsserver.cpp | |
| +++ b/src/mapserver/qgswfsserver.cpp | |
| @@ -754,7 +754,7 @@ QDomElement QgsWFSServer::createFeatureElem( QgsFeature* feat, QDomDocument& doc | |
| //qgs:%TYPENAME% | |
| QDomElement typeNameElement = doc.createElement( "qgs:" + mTypeName.replace( QString( " " ), QString( "_" ) )/*qgs:%TYPENAME%*/ ); | |
| - typeNameElement.setAttribute( "fid", QString::number( feat->id() ) ); | |
| + typeNameElement.setAttribute( "fid", feat->id() ); | |
| featureElement.appendChild( typeNameElement ); | |
| if ( mWithGeom ) | |
| diff --git a/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp b/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp | |
| index 25c670e..72d9315 100644 | |
| --- a/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp | |
| +++ b/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp | |
| @@ -74,22 +74,22 @@ bool QgsWKNDiagramFactory::writeXML( QDomNode& overlay_node, QDomDocument& doc ) | |
| for ( ; c_it != mCategories.constEnd(); ++c_it ) | |
| { | |
| QDomElement currentCategoryElem = doc.createElement( "category" ); | |
| - currentCategoryElem.setAttribute( "gap", QString::number( c_it->gap() ) ); | |
| - currentCategoryElem.setAttribute( "attribute", QString::number( c_it->propertyIndex() ) ) ; | |
| + currentCategoryElem.setAttribute( "gap", c_it->gap() ); | |
| + currentCategoryElem.setAttribute( "attribute", c_it->propertyIndex() ); | |
| //brush | |
| QDomElement currentBrushElem = doc.createElement( "brush" ); | |
| - currentBrushElem.setAttribute( "red", QString::number( c_it->brush().color().red() ) ); | |
| - currentBrushElem.setAttribute( "green", QString::number( c_it->brush().color().green() ) ); | |
| - currentBrushElem.setAttribute( "blue", QString::number( c_it->brush().color().blue() ) ); | |
| + currentBrushElem.setAttribute( "red", c_it->brush().color().red() ); | |
| + currentBrushElem.setAttribute( "green", c_it->brush().color().green() ); | |
| + currentBrushElem.setAttribute( "blue", c_it->brush().color().blue() ); | |
| currentBrushElem.setAttribute( "style", QgsSymbologyUtils::brushStyle2QString( c_it->brush().style() ) ); | |
| //pen | |
| QDomElement currentPenElem = doc.createElement( "pen" ); | |
| - currentPenElem.setAttribute( "red", QString::number( c_it->pen().color().red() ) ); | |
| - currentPenElem.setAttribute( "green", QString::number( c_it->pen().color().green() ) ); | |
| - currentPenElem.setAttribute( "blue", QString::number( c_it->pen().color().blue() ) ); | |
| - currentPenElem.setAttribute( "width", QString::number( c_it->pen().width() ) ); | |
| + currentPenElem.setAttribute( "red", c_it->pen().color().red() ); | |
| + currentPenElem.setAttribute( "green", c_it->pen().color().green() ); | |
| + currentPenElem.setAttribute( "blue", c_it->pen().color().blue() ); | |
| + currentPenElem.setAttribute( "width", c_it->pen().width() ); | |
| currentPenElem.setAttribute( "style", QgsSymbologyUtils::penStyle2QString( c_it->pen().style() ) ); | |
| currentCategoryElem.appendChild( currentBrushElem ); | |
| diff --git a/src/plugins/raster_terrain_analysis/qgsrasterterrainanalysisdialog.cpp b/src/plugins/raster_terrain_analysis/qgsrasterterrainanalysisdialog.cpp | |
| index 77db354..e80dc9a 100644 | |
| --- a/src/plugins/raster_terrain_analysis/qgsrasterterrainanalysisdialog.cpp | |
| +++ b/src/plugins/raster_terrain_analysis/qgsrasterterrainanalysisdialog.cpp | |
| @@ -242,9 +242,9 @@ void QgsRasterTerrainAnalysisDialog::on_mExportColorsButton_clicked() | |
| QDomElement classElem = doc.createElement( "ReliefColor" ); | |
| classElem.setAttribute( "MinElevation", rColorsIt->minElevation ); | |
| classElem.setAttribute( "MaxElevation", rColorsIt->maxElevation ); | |
| - classElem.setAttribute( "red", QString::number( rColorsIt->color.red() ) ); | |
| - classElem.setAttribute( "green", QString::number( rColorsIt->color.green() ) ); | |
| - classElem.setAttribute( "blue", QString::number( rColorsIt->color.blue() ) ); | |
| + classElem.setAttribute( "red", rColorsIt->color.red() ); | |
| + classElem.setAttribute( "green", rColorsIt->color.green() ); | |
| + classElem.setAttribute( "blue", rColorsIt->color.blue() ); | |
| reliefColorsElem.appendChild( classElem ); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment