From cb0b497952438ca8ddd066ae673d8692e66864e7 Mon Sep 17 00:00:00 2001 From: stippi Date: Sat, 3 Apr 2010 19:49:12 +0000 Subject: [PATCH] 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. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@382 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/DownloadProgressView.cpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/apps/webpositive/DownloadProgressView.cpp b/src/apps/webpositive/DownloadProgressView.cpp index 7ae7dc04e8..ddee6317c5 100644 --- a/src/apps/webpositive/DownloadProgressView.cpp +++ b/src/apps/webpositive/DownloadProgressView.cpp @@ -110,7 +110,7 @@ public: Invalidate(); } } - + bool IsIconDimmed() const { return fDimmedIcon; @@ -307,7 +307,7 @@ DownloadProgressView::AttachedToWindow() fDownload->SetProgressListener(BMessenger(this)); fTopButton->SetTarget(this); fBottomButton->SetTarget(this); - + BEntry entry(fPath.Path()); if (entry.Exists()) _StartNodeMonitor(entry); @@ -604,11 +604,23 @@ DownloadProgressView::_UpdateStatusText() // 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)); + 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 << string_for_size((double)fExpectedSize, sizeBuffer, - sizeof(sizeBuffer)); + buffer << expectedSize; buffer << ", "; buffer << string_for_size(fBytesPerSecond, sizeBuffer, sizeof(sizeBuffer));