[PC-BSD Commits] r5128 - pcbsd/trunk/SysInstaller

svn at pcbsd.org svn at pcbsd.org
Tue Nov 24 07:17:39 PST 2009


Author: kris
Date: 2009-11-24 07:17:38 -0800 (Tue, 24 Nov 2009)
New Revision: 5128

Modified:
   pcbsd/trunk/SysInstaller/dialogFileSystem.cpp
   pcbsd/trunk/SysInstaller/dialogFileSystem.h
Log:

Fixed a slew of bugs when adding new partitions in our custom file system tool, improved description,
now show available MB on selection combo, fixed adding swap / mirror and encryption options



Modified: pcbsd/trunk/SysInstaller/dialogFileSystem.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/dialogFileSystem.cpp	2009-11-24 10:02:49 UTC (rev 5127)
+++ pcbsd/trunk/SysInstaller/dialogFileSystem.cpp	2009-11-24 15:17:38 UTC (rev 5128)
@@ -87,15 +87,30 @@
 // Function which adds our disks / slices to the combo boxes in a sane manner
 void dialogFileSystem::addDisksSane()
 {
+  QString availSize, desc;
+
   comboDiskSelection->clear();
+
   // Start adding / listing our disks / partitions available
   for (int i=0; i < sysDisks.count(); ++i) {
     // Make sure to only add the drives to the comboDiskList
     if ( sysDisks.at(i).at(0) == "DRIVE" && diskNoExistingPartition(sysDisks.at(i).at(1)) ) {
-      comboDiskSelection->addItem(sysDisks.at(i).at(1) + " - " + sysDisks.at(i).at(2) + "MB " + sysDisks.at(i).at(3));
+      availSize.setNum(calculateFreeSpace(i));
+      desc = sysDisks.at(i).at(3);
+      desc = desc.remove(0, 1);
+      desc.truncate(desc.size() -1);
+      desc.truncate(20);
+      comboDiskSelection->addItem(sysDisks.at(i).at(1) + " - " + sysDisks.at(i).at(2) + "MB (" + availSize + " Avail) " + desc);
       comboMirrorDisk->addItem(sysDisks.at(i).at(1) + " - " + sysDisks.at(i).at(2) + "MB " + sysDisks.at(i).at(3));
     } else if ( sysDisks.at(i).at(0) == "SLICE" && sliceNoExistingDiskPartition(sysDisks.at(i).at(2) ) ) {
-      comboDiskSelection->addItem(sysDisks.at(i).at(2) + " - " + sysDisks.at(i).at(3) + "MB " + sysDisks.at(i).at(4));
+      availSize.setNum(calculateFreeSpace(i));
+      desc = sysDisks.at(i).at(4);
+      if ( desc != "Unused Space") {
+        desc = desc.remove(0, 1);
+        desc.truncate(desc.size() -1);
+        desc.truncate(20);
+      }
+      comboDiskSelection->addItem(sysDisks.at(i).at(2) + " - " + sysDisks.at(i).at(3) + "MB (" + availSize + " Avail) " + desc);
     }
   }
 
@@ -112,8 +127,13 @@
 {
   if ( comboDiskType->itemText(index) == "MIRROR" )
     stackedWidgetOptions->setCurrentIndex(1); 
-  else
+  else if (comboDiskType->itemText(index) == "SWAP" ) {
     stackedWidgetOptions->setCurrentIndex(0); 
+    lineEditMount->setEnabled(false); 
+  } else {
+    stackedWidgetOptions->setCurrentIndex(0); 
+    lineEditMount->setEnabled(true); 
+  }
 
   slotCheckSanity();
 }
@@ -133,7 +153,9 @@
       comboDiskType->removeItem(i);
   }
 
-  if ( sysDisks.at(index).at(0) == "DRIVE" )
+  int sysIndex = getSysIndexFromCombo(index);
+
+  if ( sysDisks.at(sysIndex).at(0) == "DRIVE" )
   {
     comboDiskType->addItem("MIRROR");
   } 
@@ -144,7 +166,7 @@
      comboDiskType->setCurrentIndex(0);
 
   // Now figure out how much disk space to show
-  int maxsize = calculateFreeSpace(index);
+  int maxsize = calculateFreeSpace(getSysIndexFromCombo(index));
   horizontalSizeSlider->setMinimum(0);
   horizontalSizeSlider->setMaximum(maxsize);
   horizontalSizeSlider->setValue(maxsize);
@@ -166,26 +188,43 @@
   horizontalSizeSlider->setValue(newVal);
 }
 
+// Function which takes a combo index, and returns the associated sysDisk index
+int dialogFileSystem::getSysIndexFromCombo(int cIndex)
+{
+  QString cText = comboDiskSelection->itemText(cIndex);
+
+  cText.truncate(cText.indexOf(" -"));
+
+  for (int i=0; i < sysDisks.count(); ++i) {
+    if ( sysDisks.at(i).at(1) == cText || sysDisks.at(i).at(2) == cText )
+     return i;
+  }
+
+  return -1; 
+}
+
 // function which calculates the free space available for a disk / partition that we can show the user
 int dialogFileSystem::calculateFreeSpace(int diskIndex)
 {
   QString Disk, Slice, tmp;
-  int fullSize, workingSize, availSize;
+  int fullSize, workingSize, availSize, sysIndex;
   bool ok;
    
   availSize = 0;
 
+  sysIndex = diskIndex;
+
   // Set our vars with Disk / Slice info, size, etc
-  if ( sysDisks.at(diskIndex).at(0) == "DRIVE") {
-     Disk = sysDisks.at(diskIndex).at(1);
+  if ( sysDisks.at(sysIndex).at(0) == "DRIVE") {
+     Disk = sysDisks.at(sysIndex).at(1);
      Slice = "ALL";
-     tmp = sysDisks.at(diskIndex).at(2);
+     tmp = sysDisks.at(sysIndex).at(2);
      fullSize = tmp.toInt(&ok);
   } else {
-     Disk = sysDisks.at(diskIndex).at(1);
-     Slice = sysDisks.at(diskIndex).at(2);
+     Disk = sysDisks.at(sysIndex).at(1);
+     Slice = sysDisks.at(sysIndex).at(2);
      Slice = Slice.remove(0, Slice.size() -2);
-     tmp = sysDisks.at(diskIndex).at(3);
+     tmp = sysDisks.at(sysIndex).at(3);
      fullSize = tmp.toInt(&ok);
   }
 
@@ -255,15 +294,15 @@
   QString Disk, Slice, Size, Mount, fsType, tmp;
 
   // Get the index
-  int diskIndex = comboDiskSelection->currentIndex();
+  int sysIndex = getSysIndexFromCombo(comboDiskSelection->currentIndex());
 
   // Set our vars with Disk / Slice info, size, etc
-  if ( sysDisks.at(diskIndex).at(0) == "DRIVE") {
-     Disk = sysDisks.at(diskIndex).at(1);
+  if ( sysDisks.at(sysIndex).at(0) == "DRIVE") {
+     Disk = sysDisks.at(sysIndex).at(1);
      Slice = "ALL";
   } else {
-     Disk = sysDisks.at(diskIndex).at(1);
-     Slice = sysDisks.at(diskIndex).at(2);
+     Disk = sysDisks.at(sysIndex).at(1);
+     Slice = sysDisks.at(sysIndex).at(2);
      Slice = Slice.remove(0, Slice.size() -2);
   }
 
@@ -271,10 +310,18 @@
      Size = "0";
      Mount = "MIRROR";
      fsType = "MIRROR";
+  } else if ( comboDiskType->currentText() == "SWAP" ) {
+     Size = tmp.setNum(spinSize->value());
+     Mount = "none";
+     fsType = comboDiskType->currentText();
+     if ( checkEncryption->isChecked() )
+        fsType = fsType + ".eli";
   } else {
      Size = tmp.setNum(spinSize->value());
      Mount = lineEditMount->text();
      fsType = comboDiskType->currentText();
+     if ( checkEncryption->isChecked() )
+        fsType = fsType + ".eli";
   }
 
 

Modified: pcbsd/trunk/SysInstaller/dialogFileSystem.h
===================================================================
--- pcbsd/trunk/SysInstaller/dialogFileSystem.h	2009-11-24 10:02:49 UTC (rev 5127)
+++ pcbsd/trunk/SysInstaller/dialogFileSystem.h	2009-11-24 15:17:38 UTC (rev 5128)
@@ -34,6 +34,7 @@
     void slotCheckSanity();
 
 private:
+    int getSysIndexFromCombo(int cIndex);
     void addEmit();
     bool diskNoExistingPartition(QString Device);
     bool sliceNoExistingDiskPartition(QString Device);



More information about the Commits mailing list