diff --git a/src/jobs/CMakeLists.txt b/src/jobs/CMakeLists.txt index b82a801..569454b 100644 --- a/src/jobs/CMakeLists.txt +++ b/src/jobs/CMakeLists.txt @@ -1,23 +1,24 @@ set(JOBS_SRC jobs/resizefilesystemjob.cpp jobs/createfilesystemjob.cpp jobs/job.cpp jobs/checkfilesystemjob.cpp jobs/shredfilesystemjob.cpp jobs/createpartitionjob.cpp jobs/createpartitiontablejob.cpp jobs/createvolumegroupjob.cpp + jobs/removevolumegroupjob.cpp jobs/setfilesystemlabeljob.cpp jobs/deletepartitionjob.cpp jobs/restorefilesystemjob.cpp jobs/setpartgeometryjob.cpp jobs/deletefilesystemjob.cpp jobs/backupfilesystemjob.cpp jobs/setpartflagsjob.cpp jobs/copyfilesystemjob.cpp jobs/movefilesystemjob.cpp ) set(JOBS_LIB_HDRS jobs/job.h ) diff --git a/src/jobs/removevolumegroupjob.cpp b/src/jobs/removevolumegroupjob.cpp new file mode 100644 index 0000000..516aa77 --- /dev/null +++ b/src/jobs/removevolumegroupjob.cpp @@ -0,0 +1,54 @@ +/************************************************************************* + * Copyright (C) 2016 by Chantara Tith * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 3 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see .* + *************************************************************************/ + +#include "jobs/removevolumegroupjob.h" + +#include "core/lvmdevice.h" + +#include "util/report.h" + +#include + +/** Creates a new RemoveVolumeGroupJob + @param vgname + @parem pvList +*/ +RemoveVolumeGroupJob::RemoveVolumeGroupJob(VolumeManagerDevice& dev) : + Job(), + m_Device(dev) +{ +} + +bool RemoveVolumeGroupJob::run(Report& parent) +{ + bool rval = false; + + Report* report = jobStarted(parent); + + if (device().type() == Device::LVM_Device) { + rval = LvmDevice::removeVG(*report, dynamic_cast(device())); + } + + jobFinished(*report, rval); + + return rval; +} + +QString RemoveVolumeGroupJob::description() const +{ + return xi18nc("@info/plain", "Remove Volume Group: %1", device().name()); +} diff --git a/src/jobs/removevolumegroupjob.h b/src/jobs/removevolumegroupjob.h new file mode 100644 index 0000000..a7e771e --- /dev/null +++ b/src/jobs/removevolumegroupjob.h @@ -0,0 +1,51 @@ +/************************************************************************* + * Copyright (C) 2016 by Chantara Tith * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 3 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see .* + *************************************************************************/ + +#if !defined(REMOVEVOLUMEGROUPJOB_H) + +#define REMOVEVOLUMEGROUPJOB_H + +#include "jobs/job.h" + +class VolumeManagerDevice; +class Partition; +class Report; + +class QString; + +class RemoveVolumeGroupJob : public Job +{ +public: + RemoveVolumeGroupJob(VolumeManagerDevice& dev); + +public: + bool run(Report& parent) override; + QString description() const override; + +protected: + VolumeManagerDevice& device() { + return m_Device; + } + const VolumeManagerDevice& device() const { + return m_Device; + } + +private: + VolumeManagerDevice& m_Device; +}; + +#endif diff --git a/src/ops/CMakeLists.txt b/src/ops/CMakeLists.txt index 9df401a..75bdaff 100644 --- a/src/ops/CMakeLists.txt +++ b/src/ops/CMakeLists.txt @@ -1,31 +1,33 @@ set(OPS_SRC ops/operation.cpp ops/deleteoperation.cpp ops/restoreoperation.cpp ops/resizeoperation.cpp ops/newoperation.cpp ops/createfilesystemoperation.cpp ops/createpartitiontableoperation.cpp ops/createvolumegroupoperation.cpp + ops/removevolumegroupoperation.cpp ops/setfilesystemlabeloperation.cpp ops/setpartflagsoperation.cpp ops/checkoperation.cpp ops/backupoperation.cpp ops/copyoperation.cpp ) set(OPS_LIB_HDRS ops/backupoperation.h ops/checkoperation.h ops/copyoperation.h ops/createfilesystemoperation.h ops/createpartitiontableoperation.h ops/createvolumegroupoperation.h + ops/removevolumegroupoperation.h ops/deleteoperation.h ops/newoperation.h ops/operation.h ops/resizeoperation.h ops/restoreoperation.h ops/setfilesystemlabeloperation.h ops/setpartflagsoperation.h ) diff --git a/src/ops/removevolumegroupoperation.cpp b/src/ops/removevolumegroupoperation.cpp new file mode 100644 index 0000000..1bd9540 --- /dev/null +++ b/src/ops/removevolumegroupoperation.cpp @@ -0,0 +1,54 @@ +/************************************************************************* + * Copyright (C) 2016 by Chantara Tith * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 3 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see .* + *************************************************************************/ + +#include "ops/removevolumegroupoperation.h" +#include "jobs/removevolumegroupjob.h" + +#include "core/volumemanagerdevice.h" + +#include + +#include + +/** Creates a new RemoveVolumeGroupOperation. + @param d the Device to create the new PartitionTable on + @param t the type for the new PartitionTable +*/ +RemoveVolumeGroupOperation::RemoveVolumeGroupOperation(VolumeManagerDevice& dev) : + Operation(), + m_RemoveVolumeGroupJob(new RemoveVolumeGroupJob(dev)) +{ + addJob(removeVolumeGroupJob()); +} + +QString RemoveVolumeGroupOperation::description() const +{ + return xi18nc("@info/plain", "Remove a new LVM volume group."); +} + +void RemoveVolumeGroupOperation::preview() +{ +} + +void RemoveVolumeGroupOperation::undo() +{ +} + +bool RemoveVolumeGroupOperation::canRemove() +{ + return true; +} diff --git a/src/ops/removevolumegroupoperation.h b/src/ops/removevolumegroupoperation.h new file mode 100644 index 0000000..9ac1e3c --- /dev/null +++ b/src/ops/removevolumegroupoperation.h @@ -0,0 +1,69 @@ +/************************************************************************* + * Copyright (C) 2016 by Chantara Tith * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 3 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see .* + *************************************************************************/ + +#if !defined(REMOVEVOLUMEOPERATION_H) + +#define REMOVEVOLUMEGROUPOPERATION_H + +#include "util/libpartitionmanagerexport.h" + +#include "ops/operation.h" + +#include + +class RemoveVolumeGroupJob; +class VolumeManagerDevice; +class OperationStack; + +class LIBKPMCORE_EXPORT RemoveVolumeGroupOperation : public Operation +{ + Q_DISABLE_COPY(RemoveVolumeGroupOperation) + + friend class OperationStack; + +public: + RemoveVolumeGroupOperation(VolumeManagerDevice& dev); + +public: + QString iconName() const override { + return QStringLiteral("edit-delete"); + } + + QString description() const override; + + virtual bool targets(const Device&) const override { + return true; + } + virtual bool targets(const Partition&) const override { + return false; + } + + virtual void preview() override; + virtual void undo() override; + + static bool canRemove(); + +protected: + RemoveVolumeGroupJob* removeVolumeGroupJob() { + return m_RemoveVolumeGroupJob; + } + +private: + RemoveVolumeGroupJob* m_RemoveVolumeGroupJob; +}; + +#endif