[Kstars-devel] kdeedu/kstars/kstars/tools
Jason Harris
kstars at 30doradus.org
Tue Feb 1 08:03:38 CET 2005
CVS commit by harris:
Custom fix for localizing axis-label numbers in KStarsPlotWidget. Can't
use KLocale::formatNumber(), because that has fixed-precision. For the
axis labels I need the variable precision provided by the 'g' format
specifier (i.e., it only shows as many decimal places as are required,
up to a maximum number).
To localize the numbers, I search for '.' in the number string and
replace it with KLocale::decimalSymbol().
Please test by examining the axis labels in the solar system viewer or
the jupiter moons tool.
CCMAIL: kstars-devel at kde.org
BUG: 98273
M +18 -0 kstarsplotwidget.cpp 1.7
--- kdeedu/kstars/kstars/tools/kstarsplotwidget.cpp #1.6:1.7
@@ -18,4 +18,6 @@
#include <math.h> //for log10(), pow(), modf()
#include <kdebug.h>
+#include <kglobal.h>
+#include <klocale.h>
#include <qcolor.h>
#include <qpainter.h>
@@ -358,4 +360,8 @@ void KStarsPlotWidget::drawBox( QPainter
{
QString str = QString( "%1" ).arg( lab, 0, 'g', 2 );
+ int idot = str.find( '.' );
+ if ( idot >= 0 )
+ str = str.replace( idot, 1, KGlobal::locale()->decimalSymbol() );
+
if ( px > 0 && px < pW ) {
QRect r( px - BIGTICKSIZE, pH+BIGTICKSIZE, 2*BIGTICKSIZE, BIGTICKSIZE );
@@ -422,4 +428,8 @@ void KStarsPlotWidget::drawBox( QPainter
{
QString str = QString( "%1" ).arg( lab, 0, 'g', 2 );
+ int idot = str.find( '.' );
+ if ( idot >= 0 )
+ str = str.replace( idot, 1, KGlobal::locale()->decimalSymbol() );
+
if ( py > 0 && py < pH ) {
QRect r( -2*BIGTICKSIZE, py-SMALLTICKSIZE, 2*BIGTICKSIZE, 2*SMALLTICKSIZE );
@@ -484,4 +494,8 @@ void KStarsPlotWidget::drawBox( QPainter
{
QString str = QString( "%1" ).arg( lab, 0, 'g', 2 );
+ int idot = str.find( '.' );
+ if ( idot >= 0 )
+ str = str.replace( idot, 1, KGlobal::locale()->decimalSymbol() );
+
if ( px > 0 && px < pW ) {
QRect r( px - BIGTICKSIZE, -2*BIGTICKSIZE, 2*BIGTICKSIZE, BIGTICKSIZE );
@@ -544,4 +558,8 @@ void KStarsPlotWidget::drawBox( QPainter
{
QString str = QString( "%1" ).arg( lab, 0, 'g', 2 );
+ int idot = str.find( '.' );
+ if ( idot >= 0 )
+ str = str.replace( idot, 1, KGlobal::locale()->decimalSymbol() );
+
if ( py > 0 && py < pH ) {
QRect r( pW + 2*BIGTICKSIZE, py-SMALLTICKSIZE, 2*BIGTICKSIZE, 2*SMALLTICKSIZE );
More information about the Kstars-devel
mailing list