[QGIS Commit] r11016 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jul 4 04:18:59 EDT 2009


Author: mhugent
Date: 2009-07-04 04:18:58 -0400 (Sat, 04 Jul 2009)
New Revision: 11016

Modified:
   trunk/qgis/src/app/qgscontinuouscolordialog.cpp
   trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp
Log:
Better formatting of classification strings for legend. Fixes bug #1397

Modified: trunk/qgis/src/app/qgscontinuouscolordialog.cpp
===================================================================
--- trunk/qgis/src/app/qgscontinuouscolordialog.cpp	2009-07-03 16:58:53 UTC (rev 11015)
+++ trunk/qgis/src/app/qgscontinuouscolordialog.cpp	2009-07-04 08:18:58 UTC (rev 11016)
@@ -25,7 +25,6 @@
 #include "qgsvectordataprovider.h"
 #include "qgsvectorlayer.h"
 #include "qgslogger.h"
-#include <cmath>
 
 #include <QColorDialog>
 
@@ -139,16 +138,7 @@
 
 
   //create the render items for minimum and maximum value
-  QString minimumString;
-  if ( minimum - floor( minimum ) > 0 )
-  {
-    minimumString = QString::number( minimum, 'f' );
-  }
-  else
-  {
-    minimumString = QString::number( minimum, 'f', 0 );
-  }
-  QgsSymbol* minsymbol = new QgsSymbol( mVectorLayer->geometryType(), minimumString, "", "" );
+  QgsSymbol* minsymbol = new QgsSymbol( mVectorLayer->geometryType(), QVariant( minimum ).toString(), "", "" );
   QPen minPen;
   minPen.setColor( btnMinValue->color() );
   minPen.setWidthF( outlinewidthspinbox->value() );
@@ -162,16 +152,7 @@
     minsymbol->setPen( minPen );
   }
 
-  QString maximumString;
-  if ( maximum - floor( maximum ) > 0 )
-  {
-    maximumString = QString::number( maximum, 'f' );
-  }
-  else
-  {
-    maximumString = QString::number( maximum, 'f', 0 );
-  }
-  QgsSymbol* maxsymbol = new QgsSymbol( mVectorLayer->geometryType(), maximumString, "", "" );
+  QgsSymbol* maxsymbol = new QgsSymbol( mVectorLayer->geometryType(), QVariant( maximum ).toString(), "", "" );
   QPen maxPen;
   maxPen.setColor( btnMaxValue->color() );
   maxPen.setWidthF( outlinewidthspinbox->value() );

Modified: trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp	2009-07-03 16:58:53 UTC (rev 11015)
+++ trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp	2009-07-04 08:18:58 UTC (rev 11016)
@@ -345,24 +345,9 @@
     {
       if ( last_it != quantileBorders.end() )
       {
-        if ( *last_it - floor( *last_it ) > 0 )
-        {
-          lowerString = QString::number( *last_it, 'f' );
-        }
-        else
-        {
-          lowerString = QString::number( *last_it, 'f', 0 );
-        }
+        lowerString = QVariant( *last_it ).toString();
+        upperString = QVariant( *it ).toString();
         ( *symbol_it )->setLowerValue( lowerString );
-
-        if ( *it - floor( *it ) > 0 )
-        {
-          upperString = QString::number( *it, 'f' );
-        }
-        else
-        {
-          upperString = QString::number( *it, 'f', 0 );
-        }
         ( *symbol_it )->setUpperValue( upperString );
 
 
@@ -384,29 +369,9 @@
       //switch if attribute is int or double
       double lower = minimum + ( maximum - minimum ) / numberofclassesspinbox->value() * i;
       double upper = minimum + ( maximum - minimum ) / numberofclassesspinbox->value() * ( i + 1 );
-
-      QString lowerString;
-      if ( lower - floor( lower ) > 0 )
-      {
-        lowerString = QString::number( lower, 'f' );
-      }
-      else
-      {
-        lowerString = QString::number( lower, 'f', 0 );
-      }
-
+      lowerString = QVariant( lower ).toString();
+      upperString = QVariant( upper ).toString();
       ( *symbol_it )->setLowerValue( lowerString );
-
-      QString upperString;
-      if ( upper - floor( upper ) > 0 )
-      {
-        upperString = QString::number( upper, 'f' );
-      }
-      else
-      {
-        upperString = QString::number( upper, 'f', 0 );
-      }
-
       ( *symbol_it )->setUpperValue( upperString );
       listBoxText = lowerString + " - " + upperString;
 



More information about the QGIS-commit mailing list