SVN commit 564221 by eva: copied over better formatNumber functions from kdelibs M +34 -1 kio/global.cpp M +5 -2 klocale.h --- trunk/kdenox/konq-embed/dropin/kio/global.cpp #564220:564221 @@ -27,7 +27,40 @@ //The original version converts to GB, MB etc. Maybe it is useful, we'll see. QString KIO::convertSize( KIO::filesize_t size ) { - return number(size); + double fsize = size; + QString s; + // Giga-byte + if ( size >= 1073741824 ) + { + fsize /= 1073741824.0; + if ( fsize > 1024 ) // Tera-byte + s = i18n( "%1 TB" ).arg( KGlobal::locale()->formatNumber(fsize / 1024.0, 1)); + else + s = i18n( "%1 GB" ).arg( KGlobal::locale()->formatNumber(fsize, 1)); + } + // Mega-byte + else if ( size >= 1048576 ) + { + fsize /= 1048576.0; + s = i18n( "%1 MB" ).arg( KGlobal::locale()->formatNumber(fsize, 1)); + } + // Kilo-byte + else if ( size >= 1024 ) + { + fsize /= 1024.0; + s = i18n( "%1 KB" ).arg( KGlobal::locale()->formatNumber(fsize, 1)); + } + // Just byte + else if ( size > 0 ) + { + s = i18n( "%1 B" ).arg( KGlobal::locale()->formatNumber(fsize, 0)); + } + // Nothing + else + { + s = i18n( "0 B" ); + } + return s; } KIO_EXPORT unsigned int KIO::calculateRemainingSeconds( KIO::filesize_t totalSize, --- trunk/kdenox/konq-embed/dropin/klocale.h #564220:564221 @@ -79,8 +79,11 @@ { return dt.date().toString() + " " + dt.time().toString(); } // ### - QString formatNumber( double num, int precision = 6 ) const - { return QString::number( num, 'g', precision ); } + QString formatNumber( double num, int precision = 2 ) const + { + if (precision == -1) precision = 2; + return QString::number(num, 'f', precision); + } }; #endif