Bug #251204 --> Folder/message size could be expressed in max. 3 digits to save space

minor UI optimization

Patch by aceman <acelists@atlas.sk>

r=mscott
sr=bienvenu
a=asa
This commit is contained in:
scott%scott-macgregor.org 2005-06-17 20:45:11 +00:00
parent 130ce61907
commit b686df9406

View File

@ -1910,6 +1910,8 @@ nsMsgFolderDataSource::GetNumMessagesNode(PRInt32 aNumMessages, nsIRDFNode **nod
return NS_OK;
}
#define DIVISIONWITHCEIL(num, div) (num/div+((num%div>0)?1:0))
nsresult
nsMsgFolderDataSource::GetFolderSizeNode(PRInt32 aFolderSize, nsIRDFNode **aNode)
{
@ -1921,15 +1923,15 @@ nsMsgFolderDataSource::GetFolderSizeNode(PRInt32 aFolderSize, nsIRDFNode **aNode
else
{
nsAutoString sizeString;
if (folderSize < 1024)
folderSize = 1024; // make at least 1 k;
folderSize /= 1024; // normalize into k;
PRBool sizeInMB = (folderSize > 1024);
// use Round or Ceil - bug #251202
folderSize = DIVISIONWITHCEIL(folderSize, 1024); // normalize into k;
PRBool sizeInMB = (folderSize > 999); // 999, not 1024 - bug #251204
// kKiloByteString/kMegaByteString are localized strings that we use
// to get the right format to add on the "KB"/"MB" or equivalent
nsTextFormatter::ssprintf(sizeString,
(sizeInMB) ? kMegaByteString : kKiloByteString,
(sizeInMB) ? folderSize / 1024 : folderSize);
(sizeInMB) ? DIVISIONWITHCEIL(folderSize, 1024) : folderSize);
createNode(sizeString.get(), aNode, getRDFService());
}
return NS_OK;