Skip to content

Commit

Permalink
Better formatting of classification strings for legend. Fixes bug #1397
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@11016 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jul 4, 2009
1 parent 17de1b0 commit dff7910
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 60 deletions.
23 changes: 2 additions & 21 deletions src/app/qgscontinuouscolordialog.cpp
Expand Up @@ -25,7 +25,6 @@
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include "qgslogger.h"
#include <cmath>

#include <QColorDialog>

Expand Down Expand Up @@ -139,16 +138,7 @@ void QgsContinuousColorDialog::apply()


//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() );
Expand All @@ -162,16 +152,7 @@ void QgsContinuousColorDialog::apply()
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() );
Expand Down
43 changes: 4 additions & 39 deletions src/app/qgsgraduatedsymboldialog.cpp
Expand Up @@ -345,24 +345,9 @@ void QgsGraduatedSymbolDialog::adjustClassification()
{
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 );


Expand All @@ -384,29 +369,9 @@ void QgsGraduatedSymbolDialog::adjustClassification()
//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;

Expand Down

0 comments on commit dff7910

Please sign in to comment.