d-pointerize NewOperation class.
This commit is contained in:
parent
0ee1e958a0
commit
82566e63e7
|
@ -31,37 +31,56 @@
|
|||
|
||||
#include <KLocalizedString>
|
||||
|
||||
struct NewOperationPrivate
|
||||
{
|
||||
NewOperationPrivate(Device& d, Partition* p) :
|
||||
m_TargetDevice(d),
|
||||
m_NewPartition(p),
|
||||
m_CreatePartitionJob(new CreatePartitionJob(d, *p)),
|
||||
m_SetPartitionLabelJob(nullptr),
|
||||
m_SetPartitionUUIDJob(nullptr),
|
||||
m_SetPartitionAttributesJob(nullptr),
|
||||
m_CreateFileSystemJob(nullptr),
|
||||
m_SetPartFlagsJob(nullptr),
|
||||
m_SetFileSystemLabelJob(nullptr),
|
||||
m_CheckFileSystemJob(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Device& m_TargetDevice;
|
||||
Partition* m_NewPartition;
|
||||
CreatePartitionJob* m_CreatePartitionJob;
|
||||
SetPartitionLabelJob* m_SetPartitionLabelJob;
|
||||
SetPartitionUUIDJob* m_SetPartitionUUIDJob;
|
||||
SetPartitionAttributesJob* m_SetPartitionAttributesJob;
|
||||
CreateFileSystemJob* m_CreateFileSystemJob;
|
||||
SetPartFlagsJob* m_SetPartFlagsJob;
|
||||
SetFileSystemLabelJob* m_SetFileSystemLabelJob;
|
||||
CheckFileSystemJob* m_CheckFileSystemJob;
|
||||
};
|
||||
|
||||
/** Creates a new NewOperation.
|
||||
@param d the Device to create a new Partition on
|
||||
@param p pointer to the new Partition to create. May not be nullptr.
|
||||
*/
|
||||
NewOperation::NewOperation(Device& d, Partition* p) :
|
||||
Operation(),
|
||||
m_TargetDevice(d),
|
||||
m_NewPartition(p),
|
||||
m_CreatePartitionJob(new CreatePartitionJob(targetDevice(), newPartition())),
|
||||
m_SetPartitionLabelJob(nullptr),
|
||||
m_SetPartitionUUIDJob(nullptr),
|
||||
m_SetPartitionAttributesJob(nullptr),
|
||||
m_CreateFileSystemJob(nullptr),
|
||||
m_SetPartFlagsJob(nullptr),
|
||||
m_SetFileSystemLabelJob(nullptr),
|
||||
m_CheckFileSystemJob(nullptr)
|
||||
d(std::make_unique<NewOperationPrivate>(d, p))
|
||||
{
|
||||
addJob(createPartitionJob());
|
||||
|
||||
if (!p->label().isEmpty()) {
|
||||
m_SetPartitionLabelJob = new SetPartitionLabelJob(targetDevice(), newPartition(), p->label());
|
||||
this->d->m_SetPartitionLabelJob = new SetPartitionLabelJob(targetDevice(), newPartition(), p->label());
|
||||
addJob(setPartitionLabelJob());
|
||||
}
|
||||
|
||||
if (!p->uuid().isEmpty()) {
|
||||
m_SetPartitionUUIDJob = new SetPartitionUUIDJob(targetDevice(), newPartition(), p->uuid());
|
||||
this->d->m_SetPartitionUUIDJob = new SetPartitionUUIDJob(targetDevice(), newPartition(), p->uuid());
|
||||
addJob(setPartitionUUIDJob());
|
||||
}
|
||||
|
||||
if (p->attributes()) {
|
||||
m_SetPartitionAttributesJob = new SetPartitionAttributesJob(targetDevice(), newPartition(), p->attributes());
|
||||
this->d->m_SetPartitionAttributesJob = new SetPartitionAttributesJob(targetDevice(), newPartition(), p->attributes());
|
||||
addJob(setPartitionAttributesJob());
|
||||
}
|
||||
|
||||
|
@ -74,18 +93,18 @@ NewOperation::NewOperation(Device& d, Partition* p) :
|
|||
// label. The operation stack will merge these operations with this one here
|
||||
// and if the jobs don't exist things will break.
|
||||
|
||||
m_CreateFileSystemJob = new CreateFileSystemJob(targetDevice(), newPartition(), fs.label());
|
||||
this->d->m_CreateFileSystemJob = new CreateFileSystemJob(targetDevice(), newPartition(), fs.label());
|
||||
addJob(createFileSystemJob());
|
||||
|
||||
if (fs.type() == FileSystem::Type::Lvm2_PV) {
|
||||
m_SetPartFlagsJob = new SetPartFlagsJob(targetDevice(), newPartition(), PartitionTable::Flag::Lvm);
|
||||
this->d->m_SetPartFlagsJob = new SetPartFlagsJob(targetDevice(), newPartition(), PartitionTable::Flag::Lvm);
|
||||
addJob(setPartFlagsJob());
|
||||
}
|
||||
|
||||
m_SetFileSystemLabelJob = new SetFileSystemLabelJob(newPartition(), fs.label());
|
||||
this->d->m_SetFileSystemLabelJob = new SetFileSystemLabelJob(newPartition(), fs.label());
|
||||
addJob(setLabelJob());
|
||||
|
||||
m_CheckFileSystemJob = new CheckFileSystemJob(newPartition());
|
||||
this->d->m_CheckFileSystemJob = new CheckFileSystemJob(newPartition());
|
||||
addJob(checkJob());
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +112,67 @@ NewOperation::NewOperation(Device& d, Partition* p) :
|
|||
NewOperation::~NewOperation()
|
||||
{
|
||||
if (status() == StatusPending)
|
||||
delete m_NewPartition;
|
||||
delete d->m_NewPartition;
|
||||
}
|
||||
|
||||
Partition& NewOperation::newPartition()
|
||||
{
|
||||
return *d->m_NewPartition;
|
||||
}
|
||||
|
||||
const Partition& NewOperation::newPartition() const
|
||||
{
|
||||
return *d->m_NewPartition;
|
||||
}
|
||||
|
||||
Device& NewOperation::targetDevice()
|
||||
{
|
||||
return d->m_TargetDevice;
|
||||
}
|
||||
|
||||
const Device& NewOperation::targetDevice() const
|
||||
{
|
||||
return d->m_TargetDevice;
|
||||
}
|
||||
|
||||
CreatePartitionJob* NewOperation::createPartitionJob()
|
||||
{
|
||||
return d->m_CreatePartitionJob;
|
||||
}
|
||||
|
||||
SetPartitionLabelJob* NewOperation::setPartitionLabelJob()
|
||||
{
|
||||
return d->m_SetPartitionLabelJob;
|
||||
}
|
||||
|
||||
SetPartitionUUIDJob* NewOperation::setPartitionUUIDJob()
|
||||
{
|
||||
return d->m_SetPartitionUUIDJob;
|
||||
}
|
||||
|
||||
SetPartitionAttributesJob* NewOperation::setPartitionAttributesJob()
|
||||
{
|
||||
return d->m_SetPartitionAttributesJob;
|
||||
}
|
||||
|
||||
CreateFileSystemJob* NewOperation::createFileSystemJob()
|
||||
{
|
||||
return d->m_CreateFileSystemJob;
|
||||
}
|
||||
|
||||
SetPartFlagsJob* NewOperation::setPartFlagsJob()
|
||||
{
|
||||
return d->m_SetPartFlagsJob;
|
||||
}
|
||||
|
||||
SetFileSystemLabelJob* NewOperation::setLabelJob()
|
||||
{
|
||||
return d->m_SetFileSystemLabelJob;
|
||||
}
|
||||
|
||||
CheckFileSystemJob* NewOperation::checkJob()
|
||||
{
|
||||
return d->m_CheckFileSystemJob;
|
||||
}
|
||||
|
||||
bool NewOperation::targets(const Device& d) const
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <QString>
|
||||
|
||||
struct NewOperationPrivate;
|
||||
class Device;
|
||||
class OperationStack;
|
||||
|
||||
|
@ -60,56 +61,23 @@ public:
|
|||
static Partition* createNew(const Partition& cloneFrom, FileSystem::Type type);
|
||||
|
||||
protected:
|
||||
Partition& newPartition() {
|
||||
return *m_NewPartition;
|
||||
}
|
||||
const Partition& newPartition() const {
|
||||
return *m_NewPartition;
|
||||
}
|
||||
Partition& newPartition();
|
||||
const Partition& newPartition() const;
|
||||
|
||||
Device& targetDevice() {
|
||||
return m_TargetDevice;
|
||||
}
|
||||
const Device& targetDevice() const {
|
||||
return m_TargetDevice;
|
||||
}
|
||||
Device& targetDevice();
|
||||
const Device& targetDevice() const;
|
||||
|
||||
CreatePartitionJob* createPartitionJob() {
|
||||
return m_CreatePartitionJob;
|
||||
}
|
||||
SetPartitionLabelJob* setPartitionLabelJob() {
|
||||
return m_SetPartitionLabelJob;
|
||||
}
|
||||
SetPartitionUUIDJob* setPartitionUUIDJob() {
|
||||
return m_SetPartitionUUIDJob;
|
||||
}
|
||||
SetPartitionAttributesJob* setPartitionAttributesJob() {
|
||||
return m_SetPartitionAttributesJob;
|
||||
}
|
||||
CreateFileSystemJob* createFileSystemJob() {
|
||||
return m_CreateFileSystemJob;
|
||||
}
|
||||
SetPartFlagsJob* setPartFlagsJob() {
|
||||
return m_SetPartFlagsJob;
|
||||
}
|
||||
SetFileSystemLabelJob* setLabelJob() {
|
||||
return m_SetFileSystemLabelJob;
|
||||
}
|
||||
CheckFileSystemJob* checkJob() {
|
||||
return m_CheckFileSystemJob;
|
||||
}
|
||||
CreatePartitionJob* createPartitionJob();
|
||||
SetPartitionLabelJob* setPartitionLabelJob();
|
||||
SetPartitionUUIDJob* setPartitionUUIDJob();
|
||||
SetPartitionAttributesJob* setPartitionAttributesJob();
|
||||
CreateFileSystemJob* createFileSystemJob();
|
||||
SetPartFlagsJob* setPartFlagsJob();
|
||||
SetFileSystemLabelJob* setLabelJob();
|
||||
CheckFileSystemJob* checkJob();
|
||||
|
||||
private:
|
||||
Device& m_TargetDevice;
|
||||
Partition* m_NewPartition;
|
||||
CreatePartitionJob* m_CreatePartitionJob;
|
||||
SetPartitionLabelJob* m_SetPartitionLabelJob;
|
||||
SetPartitionUUIDJob* m_SetPartitionUUIDJob;
|
||||
SetPartitionAttributesJob* m_SetPartitionAttributesJob;
|
||||
CreateFileSystemJob* m_CreateFileSystemJob;
|
||||
SetPartFlagsJob* m_SetPartFlagsJob;
|
||||
SetFileSystemLabelJob* m_SetFileSystemLabelJob;
|
||||
CheckFileSystemJob* m_CheckFileSystemJob;
|
||||
std::unique_ptr<NewOperationPrivate> d;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue