Revision: 7185
          http://svn.sourceforge.net/mahogany/?rev=7185&view=rev
Author:   vadz
Date:     2006-12-25 07:51:29 -0800 (Mon, 25 Dec 2006)

Log Message:
-----------
added SizeInBytesToString() wrapper; added SizeToString_Terse/Medium flags; 
fixed bug with not honouring flags with MessageSize_Automatic/Autobytes

Modified Paths:
--------------
    trunk/M/include/MFui.h
    trunk/M/src/mail/MFui.cpp

Modified: trunk/M/include/MFui.h
===================================================================
--- trunk/M/include/MFui.h      2006-12-24 16:04:10 UTC (rev 7184)
+++ trunk/M/include/MFui.h      2006-12-25 15:51:29 UTC (rev 7185)
@@ -42,11 +42,17 @@
 /// SizeToString() flags
 enum
 {
-   /// terse size string by default
-   SizeToString_Default,
+   /// terse size strings: indicate Kb/Mb but omit "bytes"
+   SizeToString_Terse,
 
-   /// verbose size string
-   SizeToString_Verbose
+   /// use bytes/Kb/Mb
+   SizeToString_Medium,
+
+   /// verbose size string: use full strings (bytes/kilobytes/megabytes/...)
+   SizeToString_Verbose,
+
+   /// tersest possible size string by default
+   SizeToString_Default = SizeToString_Terse
 };
 
 // ----------------------------------------------------------------------------
@@ -72,14 +78,26 @@
  @param sizeBytes the size of the message in bytes
  @param sizeLines the size of message in lines (only if text)
  @param show how should we show the size?
- @param verbose returns verbose string if equal to SizeToString_Verbose
+ @param flags returns verbose string if equal to SizeToString_Verbose
  @return string containing the text for display
 */
 extern String SizeToString(unsigned long sizeBytes,
                            unsigned long sizeLines = 0,
                            MessageSizeShow show = MessageSize_Automatic,
-                           int verbose = SizeToString_Default);
+                           int flags = SizeToString_Default);
+/**
+   Wrapper for SizeToString() returning the size in bytes alwats.
 
+   @param sizeBytes the size of the message in bytes
+   @param flags returns verbose string if equal to SizeToString_Verbose
+   @return string containing the text for display
+ */
+inline String
+SizeInBytesToString(unsigned long sizeBytes, int flags = SizeToString_Default)
+{
+   return SizeToString(sizeBytes, 0, MessageSize_AutoBytes, flags);
+}
+
 //@}
 
 #endif // _MFUI_H_

Modified: trunk/M/src/mail/MFui.cpp
===================================================================
--- trunk/M/src/mail/MFui.cpp   2006-12-24 16:04:10 UTC (rev 7184)
+++ trunk/M/src/mail/MFui.cpp   2006-12-25 15:51:29 UTC (rev 7185)
@@ -41,7 +41,8 @@
              MessageSizeShow show,
              int flags)
 {
-   const bool verbose = (flags & SizeToString_Verbose) != 0;
+   const bool terse = flags == SizeToString_Terse;
+   const bool verbose = flags == SizeToString_Verbose;
 
    String s;
 
@@ -66,20 +67,20 @@
          }
          else if ( sizeBytes < 10*1024 )
          {
-            s = SizeToString(sizeBytes, 0, MessageSize_Bytes);
+            s = SizeToString(sizeBytes, 0, MessageSize_Bytes, flags);
          }
          else if ( sizeBytes < 10*1024*1024 )
          {
-            s = SizeToString(sizeBytes, 0, MessageSize_KBytes);
+            s = SizeToString(sizeBytes, 0, MessageSize_KBytes, flags);
          }
          else // Mb
          {
-            s = SizeToString(sizeBytes, 0, MessageSize_MBytes);
+            s = SizeToString(sizeBytes, 0, MessageSize_MBytes, flags);
          }
          break;
 
       case MessageSize_Bytes:
-         s.Printf(_("%lu%s"), sizeBytes, verbose ? _(" bytes") : 
wxEmptyString);
+         s.Printf(_("%lu%s"), sizeBytes, terse ? wxEmptyString : _(" bytes"));
          break;
 
       case MessageSize_KBytes:


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to