[haiku-webkit-commits] r382 - webkit/trunk/WebKit/haiku/WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Sat, 03 Apr 2010 19:49:12 +0000

Author: stippi
Date: Sat Apr  3 19:49:12 2010
New Revision: 382
URL: http://mmlr.dyndns.org/changeset/382

Log:
Don't display the unit of the current size if it's the same as the unit of the
expected size in the download progress view.

Modified:
   webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.cpp

Modified: webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.cpp      Sat Apr 
 3 19:32:47 2010        (r381)
+++ webkit/trunk/WebKit/haiku/WebPositive/DownloadProgressView.cpp      Sat Apr 
 3 19:49:12 2010        (r382)
@@ -110,7 +110,7 @@
                        Invalidate();
                }
        }
-       
+
        bool IsIconDimmed() const
        {
                return fDimmedIcon;
@@ -307,7 +307,7 @@
                fDownload->SetProgressListener(BMessenger(this));
        fTopButton->SetTarget(this);
        fBottomButton->SetTarget(this);
-       
+
        BEntry entry(fPath.Path());
        if (entry.Exists())
                _StartNodeMonitor(entry);
@@ -604,11 +604,23 @@
                // Draw speed info
                char sizeBuffer[128];
                buffer = "(";
-               buffer << string_for_size((double)fCurrentSize, sizeBuffer,
+               // Get strings for current and expected size and remove the unit
+               // from the current size string if it's the same as the expected
+               // size unit.
+               BString currentSize = string_for_size((double)fCurrentSize, 
sizeBuffer,
                        sizeof(sizeBuffer));
-               buffer << " of ";
-               buffer << string_for_size((double)fExpectedSize, sizeBuffer,
+               BString expectedSize = string_for_size((double)fExpectedSize, 
sizeBuffer,
                        sizeof(sizeBuffer));
+               int currentSizeUnitPos = currentSize.FindLast(' ');
+               int expectedSizeUnitPos = expectedSize.FindLast(' ');
+               if (currentSizeUnitPos >= 0 && expectedSizeUnitPos >= 0
+                       && strcmp(currentSize.String() + currentSizeUnitPos,
+                               expectedSize.String() + expectedSizeUnitPos) == 
0) {
+                       currentSize.Truncate(currentSizeUnitPos);
+               }
+               buffer << currentSize;
+               buffer << " of ";
+               buffer << expectedSize;
                buffer << ", ";
                buffer << string_for_size(fBytesPerSecond, sizeBuffer,
                        sizeof(sizeBuffer));

Other related posts:

  • » [haiku-webkit-commits] r382 - webkit/trunk/WebKit/haiku/WebPositive - webkit