Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv18306

Modified Files:
        Internat.cpp Internat.h Dependencies.cpp Dependencies.h 
Log Message:
Fix for include space display in Dependencies dialog

Index: Dependencies.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Dependencies.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Dependencies.cpp    25 Sep 2006 00:16:57 -0000      1.4
+++ Dependencies.cpp    30 Sep 2006 03:25:09 -0000      1.5
@@ -23,6 +23,7 @@
 #include "BlockFile.h"
 #include "Dependencies.h"
 #include "DirManager.h"
+#include "Internat.h"
 #include "Project.h"
 #include "ShuttleGui.h"
 #include "Prefs.h"
@@ -288,7 +289,7 @@
          mFileList = S.Id(FileListID).AddListControlReportMode();
          mFileList->InsertColumn(0, _("Audio file"));
          mFileList->SetColumnWidth(0, 220);
-         mFileList->InsertColumn(1, _("Disk space (MB)"));
+         mFileList->InsertColumn(1, _("Disk space"));
          mFileList->SetColumnWidth(1, 120);
          PopulateList();
 
@@ -343,13 +344,11 @@
    unsigned int i;
    for(i=0; i<mAliasedFiles->GetCount(); i++) {
       wxFileName fileName = mAliasedFiles->Item(i).fileName;
-      int bytes = mAliasedFiles->Item(i).bytes;
-
+      double bytes = mAliasedFiles->Item(i).bytes;
       double overhead = 1.24;
-      double MB = bytes * overhead / 1048576.0;
 
       mFileList->InsertItem(i, fileName.GetFullPath());
-      mFileList->SetItem(i, 1, wxString::Format(_("%.1f MB"), MB));
+      mFileList->SetItem(i, 1, Internat::FormatSize(bytes * overhead));
       mFileList->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
    }
 }

Index: Internat.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Internat.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Internat.h  23 Sep 2006 02:28:04 -0000      1.11
+++ Internat.h  30 Sep 2006 03:25:09 -0000      1.12
@@ -13,7 +13,7 @@
 #define __AUDACITY_INTERNAT__
 
 #include <wx/string.h>
-
+#include <wx/longlong.h>
 
 class Internat
 {
@@ -43,6 +43,10 @@
    static wxString ToDisplayString(double numberToConvert,
                      int digitsAfterDecimalPoint = -1);
 
+   // Convert a number to a string while formatting it byte, KB, MB, GB
+   static wxString FormatSize(wxLongLong size);
+   static wxString FormatSize(double size);
+
    // Convert strings to and from UTF-8 (used for XML files).
    static wxString UTF8ToLocal(const wxString &s);
    static wxString LocalToUTF8(const wxString &s);

Index: Internat.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Internat.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Internat.cpp        23 Sep 2006 02:28:04 -0000      1.14
+++ Internat.cpp        30 Sep 2006 03:25:09 -0000      1.15
@@ -158,6 +158,39 @@
    return result;
 }
 
+wxString Internat::FormatSize(wxLongLong size)
+{
+   /* wxLongLong contains no built-in conversion to double */
+   double dSize = size.GetHi() * pow(2.0, 32);  // 2 ^ 32
+   dSize += size.GetLo();
+
+   return FormatSize(dSize);
+}
+
+wxString Internat::FormatSize(double size)
+{
+   wxString sizeStr;
+
+   if (size == -1)
+      sizeStr = _("Unable to determine");
+   else {
+      /* make it look nice, by formatting into k, MB, etc */
+      if (size < 1024.0)
+         sizeStr = ToDisplayString(size) + _(" bytes");
+      else if (size < 1024.0 * 1024.0) {
+         sizeStr = ToDisplayString(size / 1024.0, 1) + _(" KB");
+      }
+      else if (size < 1024.0 * 1024.0 * 1024.0) {
+         sizeStr = ToDisplayString(size / (1024.0 * 1024.0), 1) + _(" MB");
+      }
+      else {
+         sizeStr = ToDisplayString(size / (1024.0 * 1024.0 * 1024.0), 1) + _(" 
GB");
+      }
+   }
+
+   return sizeStr;
+}
+
 #ifdef __WXMAC__IGNORE
 
 // wxMac 2.4.x doesn't support converting to/from Mac encodings yet,

Index: Dependencies.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Dependencies.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Dependencies.h      20 Jul 2006 09:09:24 -0000      1.1
+++ Dependencies.h      30 Sep 2006 03:25:09 -0000      1.2
@@ -24,12 +24,12 @@
 
 class AliasedFile {
  public:
-  AliasedFile(wxFileName fileName, int bytes) {
+  AliasedFile(wxFileName fileName, double bytes) {
     this->fileName = fileName;
     this->bytes = bytes;
   }
   wxFileName  fileName;
-  int         bytes; // if stored as current default sample format
+  double      bytes; // if stored as current default sample format
 };
 
 class AudacityProject;


-------------------------------------------------------------------------
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
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to