[PC-BSD Commits] r5131 - pcbsd/trunk/SysInstaller
svn at pcbsd.org
svn at pcbsd.org
Tue Nov 24 09:13:10 PST 2009
Author: kris
Date: 2009-11-24 09:13:10 -0800 (Tue, 24 Nov 2009)
New Revision: 5131
Modified:
pcbsd/trunk/SysInstaller/dialogFileSystem.cpp
pcbsd/trunk/SysInstaller/dialogFileSystem.h
pcbsd/trunk/SysInstaller/sys-diskwidget.cpp
pcbsd/trunk/SysInstaller/sysinstaller.cpp
Log:
The disk partition / filesystem creation dialog should be complete now, can add, edit and remove partitions,
and mirrors , will be doing extensive testing during the course of other development on this feature
Modified: pcbsd/trunk/SysInstaller/dialogFileSystem.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/dialogFileSystem.cpp 2009-11-24 16:19:30 UTC (rev 5130)
+++ pcbsd/trunk/SysInstaller/dialogFileSystem.cpp 2009-11-24 17:13:10 UTC (rev 5131)
@@ -12,6 +12,9 @@
void dialogFileSystem::dialogInit(QList<QStringList> disks, QList<QStringList> disklayout)
{
+ // Set that we aren't editing right now
+ isEditing = false;
+ editIndex = -1;
// Connnect our slots
connect(pushCancel, SIGNAL(clicked()), this, SLOT(slotPushCancel()));
@@ -117,9 +120,105 @@
}
// Public slot which lets us set if we are editing a partition, or creating a new one
-void dialogFileSystem::setEditing(int id )
+void dialogFileSystem::setEditing( int id )
{
+ QString searchDev, cText, tmp;
+ int size;
+ bool ok;
+ isEditing = true;
+ editIndex = id;
+
+
+ // Lets figure out which slice / disk to show in our combo box before disabling it
+ if ( sysFinalDiskLayout.at(id).at(1) == "ALL" )
+ searchDev = sysFinalDiskLayout.at(id).at(0);
+ else
+ searchDev = sysFinalDiskLayout.at(id).at(0) + sysFinalDiskLayout.at(id).at(1);
+
+ for ( int i = 0; i <= comboDiskSelection->count(); i++ )
+ {
+ cText = comboDiskSelection->itemText(i);
+ cText.truncate(cText.indexOf(" -"));
+ if ( cText == searchDev) {
+ comboDiskSelection->setCurrentIndex(i);
+ break;
+ }
+ }
+ comboDiskSelection->setEnabled(false);
+
+
+ // Figure out the filesystem
+ tmp = sysFinalDiskLayout.at(id).at(3);
+ if ( tmp == "load" || tmp == "prefer" || tmp == "round-robin" || tmp == "split" )
+ {
+ // We are editing a mirror
+ for ( int i = 0; i <= comboMirrorTypes->count(); i++ )
+ {
+ if ( comboMirrorTypes->itemText(i) == tmp) {
+ comboMirrorTypes->setCurrentIndex(i);
+ break;
+ }
+ }
+ for ( int i = 0; i <= comboDiskType->count(); i++ )
+ {
+ if ( comboDiskType->itemText(i) == "MIRROR") {
+ comboDiskType->setCurrentIndex(i);
+ break;
+ }
+ }
+ } else {
+ // Check for encryption
+ if ( tmp.indexOf(".eli") != -1 )
+ {
+ checkEncryption->setChecked(true);
+ tmp.truncate(tmp.indexOf(".eli"));
+ }
+ for ( int i = 0; i <= comboDiskType->count(); i++ )
+ {
+ if ( comboDiskType->itemText(i) == tmp) {
+ comboDiskType->setCurrentIndex(i);
+ break;
+ }
+ }
+ }
+
+ // Now figure out the size
+ // We already have the available size in our slider, add the editing size
+ tmp = sysFinalDiskLayout.at(id).at(4);
+ size = tmp.toInt(&ok);
+ if ( ok )
+ {
+ int maxsize = calculateFreeSpace(getSysIndexFromCombo(comboDiskSelection->currentIndex())) + size;
+ horizontalSizeSlider->setMinimum(0);
+ horizontalSizeSlider->setMaximum(maxsize);
+ horizontalSizeSlider->setValue(size);
+ spinSize->setRange(0, maxsize);
+ spinSize->setValue(size);
+ }
+
+ // Figure out the mnt
+ tmp = sysFinalDiskLayout.at(id).at(2);
+ if ( tmp.indexOf("MIRROR") != -1 )
+ {
+ stackedWidgetOptions->setCurrentIndex(1);
+ tmp = tmp.remove(0, tmp.indexOf("(") + 1);
+ tmp.truncate(tmp.indexOf(")"));
+ // Set the right mirror name
+ for ( int i = 0; i <= comboMirrorDisk->count(); i++ )
+ {
+ if ( comboMirrorDisk->itemText(i).indexOf(tmp + " -") != -1 ) {
+ comboMirrorDisk->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ } else {
+ if ( tmp == "none" )
+ tmp = "";
+ lineEditMount->setText(tmp);
+ }
+
}
// Slot for checking the current type
@@ -157,7 +256,26 @@
if ( sysDisks.at(sysIndex).at(0) == "DRIVE" )
{
- comboDiskType->addItem("MIRROR");
+ // Check if we have any available disks to mirror with
+ comboMirrorDisk->clear();
+ bool found;
+ found = false;
+ QString availSize, desc;
+ // Update the mirror list
+ for (int i=0; i < sysDisks.count(); ++i) {
+ if ( sysDisks.at(i).at(0) == "DRIVE" && i != sysIndex) {
+ availSize.setNum(calculateFreeSpace(i));
+ desc = sysDisks.at(i).at(3);
+ desc = desc.remove(0, 1);
+ desc.truncate(desc.size() -1);
+ desc.truncate(20);
+ comboMirrorDisk->addItem(sysDisks.at(i).at(1) + " - " + sysDisks.at(i).at(2) + "MB " + sysDisks.at(i).at(3));
+ found = true;
+ }
+ }
+
+ if (found)
+ comboDiskType->addItem("MIRROR");
}
if ( typeIndex <= comboDiskType->count() )
@@ -260,19 +378,24 @@
if ( comboDiskType->currentText() != "MIRROR" ) {
if ( spinSize->value() <= 0)
ready = false;
- if ( lineEditMount->text().isEmpty() || lineEditMount->text().indexOf("/") != 0 )
+ if ( (lineEditMount->text().isEmpty() || lineEditMount->text().indexOf("/") != 0) \
+ && comboDiskType->currentText() != "SWAP" )
ready = false;
- // Make sure we don't have a duplicate mount point
+ // Make sure we don't have a duplicate mount point and not editing
for (int i=0; i < sysFinalDiskLayout.count(); ++i) {
// Check if this mount is on the target partition / drive
- if ( sysFinalDiskLayout.at(i).at(2) == lineEditMount->text() )
+ if ( sysFinalDiskLayout.at(i).at(2) == lineEditMount->text() && ! isEditing )
ready = false;
}
} else {
+ QString selDev = comboDiskSelection->currentText();
+ QString mirrorDev = comboMirrorDisk->currentText();
+ selDev.truncate(selDev.indexOf(" -") );
+ mirrorDev.truncate(mirrorDev.indexOf(" -") );
// Using a mirror, make sure we don't have the same disk selected as target as source
- if ( comboDiskSelection->currentText() == comboMirrorDisk->currentText() )
+ if ( selDev == mirrorDev )
ready = false;
}
@@ -280,13 +403,6 @@
}
-// Slot for closing the dialog
-void dialogFileSystem::slotPushCancel()
-{
- close();
-}
-
-
// add the new FS to our list, and emit it back to the parent
void dialogFileSystem::addEmit()
{
@@ -308,8 +424,10 @@
if ( comboDiskType->currentText() == "MIRROR" ) {
Size = "0";
- Mount = "MIRROR";
- fsType = "MIRROR";
+ tmp = comboMirrorDisk->currentText();
+ tmp.truncate(tmp.indexOf(" -"));
+ Mount = "MIRROR(" + tmp + ")";
+ fsType = comboMirrorTypes->currentText();
} else if ( comboDiskType->currentText() == "SWAP" ) {
Size = tmp.setNum(spinSize->value());
Mount = "none";
@@ -325,17 +443,33 @@
}
+ // If we are editing an existing device, update it
+ if ( isEditing )
+ {
+ sysFinalDiskLayout[editIndex][0] = Disk;
+ sysFinalDiskLayout[editIndex][1] = Slice;
+ sysFinalDiskLayout[editIndex][2] = Mount;
+ sysFinalDiskLayout[editIndex][3] = fsType;
+ sysFinalDiskLayout[editIndex][4] = Size;
+ } else {
+ // Add a new Device
+ fileSystem << Disk << Slice << Mount << fsType << Size;
+ sysFinalDiskLayout << fileSystem;
+ }
- fileSystem << Disk << Slice << Mount << fsType << Size;
- sysFinalDiskLayout << fileSystem;
-
emit updated(sysFinalDiskLayout);
}
+
+// Slot for closing the dialog
+void dialogFileSystem::slotPushCancel()
+{
+ close();
+}
+
// Slot for saving the dialog
void dialogFileSystem::slotPushSave()
{
addEmit();
close();
}
-
Modified: pcbsd/trunk/SysInstaller/dialogFileSystem.h
===================================================================
--- pcbsd/trunk/SysInstaller/dialogFileSystem.h 2009-11-24 16:19:30 UTC (rev 5130)
+++ pcbsd/trunk/SysInstaller/dialogFileSystem.h 2009-11-24 17:13:10 UTC (rev 5131)
@@ -39,6 +39,8 @@
bool diskNoExistingPartition(QString Device);
bool sliceNoExistingDiskPartition(QString Device);
void addDisksSane();
+ bool isEditing;
+ int editIndex;
int calculateFreeSpace(int diskIndex);
QList<QStringList> sysDisks; // Our lists which contains disk info
QList<QStringList> sysFinalDiskLayout; // Our lists which contains the final disk layout
Modified: pcbsd/trunk/SysInstaller/sys-diskwidget.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sys-diskwidget.cpp 2009-11-24 16:19:30 UTC (rev 5130)
+++ pcbsd/trunk/SysInstaller/sys-diskwidget.cpp 2009-11-24 17:13:10 UTC (rev 5131)
@@ -201,10 +201,10 @@
// Function which will add a new filesystem in our custom dialog
void SysInstaller::slotAddNewFileSystem()
{
- dialogFileSystem *dls = new dialogFileSystem();
- dls->dialogInit(sysDisks, sysFinalDiskLayout);
- connect(dls, SIGNAL(updated(QList <QStringList>)), this, SLOT(slotUpdateFileSystemLayout(QList<QStringList>)));
- dls->show();
+ dfs = new dialogFileSystem();
+ dfs->dialogInit(sysDisks, sysFinalDiskLayout);
+ connect(dfs, SIGNAL(updated(QList <QStringList>)), this, SLOT(slotUpdateFileSystemLayout(QList<QStringList>)));
+ dfs->show();
}
void SysInstaller::slotUpdateFileSystemLayout(QList<QStringList> newFileSystemLayout)
@@ -216,16 +216,44 @@
// Function which will edit a filesystem the user has selected
void SysInstaller::slotEditFileSystem()
{
- dialogFileSystem *dls = new dialogFileSystem();
- dls->dialogInit(sysDisks, sysFinalDiskLayout);
- //dls->setEditing(id);
- dls->show();
+ QString tmp;
+ int editItem;
+ bool ok;
+
+ if ( ! treeWidgetCustomPartition->currentItem() )
+ return;
+
+ tmp = treeWidgetCustomPartition->currentItem()->text(0);
+ editItem = tmp.toInt(&ok);
+ if (!ok)
+ return;
+
+ dfs = new dialogFileSystem();
+ dfs->dialogInit(sysDisks, sysFinalDiskLayout);
+ connect(dfs, SIGNAL(updated(QList <QStringList>)), this, SLOT(slotUpdateFileSystemLayout(QList<QStringList>)));
+ dfs->setEditing(editItem);
+ dfs->show();
}
// Function which will delete a filesystem
void SysInstaller::slotRemoveFileSystem()
{
+ QString tmp;
+ int rmItem;
+ bool ok;
+ if ( ! treeWidgetCustomPartition->currentItem() )
+ return;
+
+ tmp = treeWidgetCustomPartition->currentItem()->text(0);
+ rmItem = tmp.toInt(&ok);
+ if (!ok)
+ return;
+
+ sysFinalDiskLayout.removeAt(rmItem);
+
+ // Refresh the display
+ slotRefreshCustomPartitionWidget();
}
Modified: pcbsd/trunk/SysInstaller/sysinstaller.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sysinstaller.cpp 2009-11-24 16:19:30 UTC (rev 5130)
+++ pcbsd/trunk/SysInstaller/sysinstaller.cpp 2009-11-24 17:13:10 UTC (rev 5131)
@@ -117,8 +117,8 @@
connect(radioAutoPartition,SIGNAL(toggled(bool)), this, SLOT(slotChangeRadioCustomDisk()));
connect(pushAutoMount,SIGNAL(clicked()), this, SLOT(slotPushAutoMountClicked()));
connect(pushAddMount,SIGNAL(clicked()), this, SLOT(slotAddNewFileSystem()));
- connect(pushEditMount,SIGNAL(clicked()), this, SLOT(slotPushAutoMountClicked()));
- connect(pushRemoveMount,SIGNAL(clicked()), this, SLOT(slotPushAutoMountClicked()));
+ connect(pushEditMount,SIGNAL(clicked()), this, SLOT(slotEditFileSystem()));
+ connect(pushRemoveMount,SIGNAL(clicked()), this, SLOT(slotRemoveFileSystem()));
// Hide the ID part of our custom treeWidget
More information about the Commits
mailing list