merge creating a new partition table with previous ops if they target the

device; i.e., if there are ops that target the device where the partition table
is created, delete those ops.

this needs a lot of testing still. also, if the user undoes the creating of the
partition table, the deletes ops don't just magically reappear. this could
probably be solved by not deleting them but moving them to some qlist in the
create partition table op...?

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1129812
This commit is contained in:
Volker Lanz 2010-05-23 20:15:51 +00:00
parent ea4031b645
commit bd5accaa16
2 changed files with 24 additions and 1 deletions

View File

@ -31,6 +31,7 @@
#include "ops/createfilesystemoperation.h"
#include "ops/setpartflagsoperation.h"
#include "ops/setfilesystemlabeloperation.h"
#include "ops/createpartitiontableoperation.h"
#include "jobs/setfilesystemlabeljob.h"
@ -99,7 +100,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
CopyOperation* pushedCopyOp = dynamic_cast<CopyOperation*>(pushedOp);
SetFileSystemLabelOperation* pushedLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(pushedOp);
CreateFileSystemOperation* pushedCreateFileSystemOp = dynamic_cast<CreateFileSystemOperation*>(pushedOp);
// -- 1 --
if (pushedDeleteOp && &newOp->newPartition() == &pushedDeleteOp->deletedPartition() && !pushedDeleteOp->deletedPartition().roles().has(PartitionRole::Extended))
{
@ -368,6 +369,24 @@ bool OperationStack::mergePartLabelOperation(Operation*& currentOp, Operation*&
return false;
}
bool OperationStack::mergeCreatePartitionTableOperation(Operation*& currentOp, Operation*& pushedOp)
{
CreatePartitionTableOperation* pushedCreatePartitionTableOp = dynamic_cast<CreatePartitionTableOperation*>(pushedOp);
if (pushedCreatePartitionTableOp)
{
if (currentOp->targets(pushedCreatePartitionTableOp->targetDevice()))
{
Log() << i18nc("@info/plain", "Creating new partition table, discarding previous operation on device.");
currentOp->undo();
delete operations().takeAt(operations().indexOf(currentOp));
return true;
}
}
return false;
}
/** Pushes a new Operation on the OperationStack.
This method will call all methods that try to merge the new Operation with the
@ -397,6 +416,9 @@ void OperationStack::push(Operation* o)
if (mergePartLabelOperation(currentOp, o))
break;
if (mergeCreatePartitionTableOperation(currentOp, o))
break;
}
if (o != NULL)

View File

@ -84,6 +84,7 @@ class OperationStack : public QObject
bool mergeRestoreOperation(Operation*& currentOp, Operation*& pushedOp);
bool mergePartFlagsOperation(Operation*& currentOp, Operation*& pushedOp);
bool mergePartLabelOperation(Operation*& currentOp, Operation*& pushedOp);
bool mergeCreatePartitionTableOperation(Operation*& currentOp, Operation*& pushedOp);
private:
Operations m_Operations;