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