Add support of number of decimals to unit system

This commit is contained in:
wmayer
2012-06-08 15:19:53 +02:00
parent 68ac7f303f
commit 445e8d4c05
5 changed files with 49 additions and 11 deletions

View File

@@ -85,6 +85,7 @@ UnitsSchema *UnitsApi::UserPrefSystem = new UnitsSchemaInternal();
double UnitsApi::UserPrefFactor [50];
QString UnitsApi::UserPrefUnit [50];
int UnitsApi::UserPrefDecimals = 2;
UnitsApi::UnitsApi(const char* filter)
{
@@ -196,6 +197,16 @@ const double UnitsApi::getPrefFactorOf(QuantityType t)
return UserPrefFactor[t];
}
void UnitsApi::setDecimals(int prec)
{
UserPrefDecimals = prec;
}
int UnitsApi::getDecimals()
{
return UserPrefDecimals;
}
void UnitsApi::setDefaults(void)
{
setPrefOf( Length ,"mm" );

View File

@@ -101,6 +101,10 @@ public:
static const QString getQuantityName(QuantityType t);
/// get the translation factor for the default unit of a quantity
static const double getPrefFactorOf(QuantityType t);
// set the number of decimals
static void setDecimals(int);
// fet the number of decimals
static int getDecimals();
/// set the application defaults
static void setDefaults(void);
//@}
@@ -119,6 +123,8 @@ protected:
static double UserPrefFactor [50] ;
/// name of the unit the user wants to use as quantities
static QString UserPrefUnit [50] ;
/// number of decimals for floats
static int UserPrefDecimals;
// do the real work
static double parse(const char*,bool &UsedUnit);