2020-09-30 23:28:47 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de>
|
|
|
|
SPDX-FileCopyrightText: 2014-2018 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk>
|
|
|
|
SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
|
2020-10-01 00:33:19 +01:00
|
|
|
SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
|
2020-09-30 23:28:47 +01:00
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2020-09-30 23:28:47 +01:00
|
|
|
#ifndef KPMCORE_DELETEOPERATION_H
|
2017-09-10 20:12:52 +01:00
|
|
|
#define KPMCORE_DELETEOPERATION_H
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-05-06 22:36:24 +01:00
|
|
|
#include "util/libpartitionmanagerexport.h"
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-05-06 22:36:24 +01:00
|
|
|
#include "ops/operation.h"
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
class Device;
|
|
|
|
class OperationStack;
|
|
|
|
class Partition;
|
|
|
|
|
|
|
|
class Job;
|
|
|
|
class DeletePartitionJob;
|
|
|
|
|
|
|
|
/** Delete a Partition.
|
2015-07-13 15:16:36 +01:00
|
|
|
@author Volker Lanz <vl@fidra.de>
|
2015-06-04 01:29:22 +01:00
|
|
|
*/
|
|
|
|
class LIBKPMCORE_EXPORT DeleteOperation : public Operation
|
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
friend class OperationStack;
|
|
|
|
|
|
|
|
Q_DISABLE_COPY(DeleteOperation)
|
|
|
|
|
|
|
|
public:
|
2018-04-09 15:14:34 +01:00
|
|
|
enum class ShredAction {
|
|
|
|
NoShred,
|
2015-07-13 15:16:36 +01:00
|
|
|
ZeroShred,
|
|
|
|
RandomShred
|
|
|
|
};
|
|
|
|
|
2018-04-09 15:14:34 +01:00
|
|
|
DeleteOperation(Device& d, Partition* p, ShredAction shred = ShredAction::NoShred);
|
2015-07-13 15:16:36 +01:00
|
|
|
~DeleteOperation();
|
|
|
|
|
|
|
|
public:
|
2016-04-27 21:54:02 +01:00
|
|
|
QString iconName() const override {
|
2018-04-09 15:14:34 +01:00
|
|
|
return shredAction() == ShredAction::NoShred ?
|
2015-07-13 15:16:36 +01:00
|
|
|
QStringLiteral("edit-delete") :
|
|
|
|
QStringLiteral("edit-delete-shred");
|
|
|
|
}
|
2016-04-27 21:54:02 +01:00
|
|
|
QString description() const override;
|
|
|
|
void preview() override;
|
|
|
|
void undo() override;
|
2015-07-13 15:16:36 +01:00
|
|
|
ShredAction shredAction() const {
|
|
|
|
return m_ShredAction;
|
|
|
|
}
|
|
|
|
|
2016-05-17 18:01:31 +01:00
|
|
|
bool targets(const Device& d) const override;
|
|
|
|
bool targets(const Partition& p) const override;
|
2015-07-13 15:16:36 +01:00
|
|
|
|
2018-07-15 23:41:44 +01:00
|
|
|
static bool canDelete(const Partition* p);
|
2015-07-13 15:16:36 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Device& targetDevice() {
|
|
|
|
return m_TargetDevice;
|
|
|
|
}
|
|
|
|
const Device& targetDevice() const {
|
|
|
|
return m_TargetDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
Partition& deletedPartition() {
|
|
|
|
return *m_DeletedPartition;
|
|
|
|
}
|
|
|
|
const Partition& deletedPartition() const {
|
|
|
|
return *m_DeletedPartition;
|
|
|
|
}
|
|
|
|
|
|
|
|
void checkAdjustLogicalNumbers(Partition& p, bool undo);
|
|
|
|
|
|
|
|
void setDeletedPartition(Partition* p) {
|
|
|
|
m_DeletedPartition = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
Job* deleteFileSystemJob() {
|
|
|
|
return m_DeleteFileSystemJob;
|
|
|
|
}
|
|
|
|
DeletePartitionJob* deletePartitionJob() {
|
|
|
|
return m_DeletePartitionJob;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Device& m_TargetDevice;
|
|
|
|
Partition* m_DeletedPartition;
|
|
|
|
ShredAction m_ShredAction;
|
|
|
|
Job* m_DeleteFileSystemJob;
|
|
|
|
DeletePartitionJob* m_DeletePartitionJob;
|
2015-06-04 01:29:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|