add methods to each operation to return if the op targets a given device or
partition svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1129811
This commit is contained in:
parent
b8d25fa809
commit
ea4031b645
|
@ -20,6 +20,7 @@
|
|||
#include "ops/backupoperation.h"
|
||||
|
||||
#include "core/partition.h"
|
||||
#include "core/device.h"
|
||||
|
||||
#include "jobs/backupfilesystemjob.h"
|
||||
|
||||
|
@ -45,6 +46,16 @@ BackupOperation::BackupOperation(Device& d, Partition& p, const QString& filenam
|
|||
addJob(backupJob());
|
||||
}
|
||||
|
||||
bool BackupOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
bool BackupOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == backupPartition();
|
||||
}
|
||||
|
||||
QString BackupOperation::description() const
|
||||
{
|
||||
return QString(i18nc("@info/plain", "Backup partition <filename>%1</filename> (%2, %3) to <filename>%4</filename>", backupPartition().deviceNode(), Capacity(backupPartition()).toString(), backupPartition().fileSystem().name(), fileName()));
|
||||
|
|
|
@ -46,6 +46,9 @@ class BackupOperation : public Operation
|
|||
void preview() {}
|
||||
void undo() {}
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
static bool canBackup(const Partition* p);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "ops/checkoperation.h"
|
||||
|
||||
#include "core/partition.h"
|
||||
#include "core/device.h"
|
||||
|
||||
#include "jobs/checkfilesystemjob.h"
|
||||
#include "jobs/resizefilesystemjob.h"
|
||||
|
@ -46,6 +47,16 @@ CheckOperation::CheckOperation(Device& d, Partition& p) :
|
|||
addJob(maximizeJob());
|
||||
}
|
||||
|
||||
bool CheckOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
bool CheckOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == checkedPartition();
|
||||
}
|
||||
|
||||
QString CheckOperation::description() const
|
||||
{
|
||||
return QString(i18nc("@info/plain", "Check and repair partition <filename>%1</filename> (%2, %3)", checkedPartition().deviceNode(), Capacity(checkedPartition()).toString(), checkedPartition().fileSystem().name()));
|
||||
|
|
|
@ -47,6 +47,9 @@ class CheckOperation : public Operation
|
|||
void preview() {}
|
||||
void undo() {}
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
static bool canCheck(const Partition* p);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -92,6 +92,16 @@ CopyOperation::~CopyOperation()
|
|||
cleanupOverwrittenPartition();
|
||||
}
|
||||
|
||||
bool CopyOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
bool CopyOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == copiedPartition();
|
||||
}
|
||||
|
||||
void CopyOperation::preview()
|
||||
{
|
||||
if (overwrittenPartition())
|
||||
|
|
|
@ -61,6 +61,9 @@ class CopyOperation : public Operation
|
|||
void preview();
|
||||
void undo();
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
static bool canCopy(const Partition* p);
|
||||
static bool canPaste(const Partition* p, const Partition* source);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "ops/createfilesystemoperation.h"
|
||||
|
||||
#include "core/partition.h"
|
||||
#include "core/device.h"
|
||||
|
||||
#include "jobs/deletefilesystemjob.h"
|
||||
#include "jobs/createfilesystemjob.h"
|
||||
|
@ -64,6 +65,16 @@ CreateFileSystemOperation::~CreateFileSystemOperation()
|
|||
delete newFileSystem();
|
||||
}
|
||||
|
||||
bool CreateFileSystemOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
bool CreateFileSystemOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == partition();
|
||||
}
|
||||
|
||||
void CreateFileSystemOperation::preview()
|
||||
{
|
||||
partition().setFileSystem(newFileSystem());
|
||||
|
|
|
@ -58,6 +58,9 @@ class CreateFileSystemOperation : public Operation
|
|||
void undo();
|
||||
bool execute(Report& parent);
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
protected:
|
||||
Device& targetDevice() { return m_TargetDevice; }
|
||||
const Device& targetDevice() const { return m_TargetDevice; }
|
||||
|
|
|
@ -64,6 +64,11 @@ CreatePartitionTableOperation::~CreatePartitionTableOperation()
|
|||
delete m_PartitionTable;
|
||||
}
|
||||
|
||||
bool CreatePartitionTableOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
void CreatePartitionTableOperation::preview()
|
||||
{
|
||||
targetDevice().setPartitionTable(partitionTable());
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
class Device;
|
||||
class CreatePartitionTableJob;
|
||||
class PartitionTable;
|
||||
class OperationStack;
|
||||
|
||||
/** Create a PartitionTable.
|
||||
@author Volker Lanz <vl@fidra.de>
|
||||
|
@ -39,6 +40,8 @@ class CreatePartitionTableOperation : public Operation
|
|||
Q_OBJECT
|
||||
Q_DISABLE_COPY(CreatePartitionTableOperation)
|
||||
|
||||
friend class OperationStack;
|
||||
|
||||
public:
|
||||
CreatePartitionTableOperation(Device& d, PartitionTable::TableType t);
|
||||
CreatePartitionTableOperation(Device& d, PartitionTable* ptable);
|
||||
|
@ -51,6 +54,9 @@ class CreatePartitionTableOperation : public Operation
|
|||
void undo();
|
||||
bool execute(Report& parent);
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition&) const { return false; }
|
||||
|
||||
static bool canCreate(const Device* device);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -58,6 +58,16 @@ DeleteOperation::~DeleteOperation()
|
|||
delete m_DeletedPartition;
|
||||
}
|
||||
|
||||
bool DeleteOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
bool DeleteOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == deletedPartition();
|
||||
}
|
||||
|
||||
void DeleteOperation::preview()
|
||||
{
|
||||
removePreviewPartition(targetDevice(), deletedPartition());
|
||||
|
|
|
@ -53,6 +53,9 @@ class DeleteOperation : public Operation
|
|||
void undo();
|
||||
bool isSecure() const { return m_Secure; }
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
static bool canDelete(const Partition* p);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -80,6 +80,16 @@ NewOperation::~NewOperation()
|
|||
delete m_NewPartition;
|
||||
}
|
||||
|
||||
bool NewOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
bool NewOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == newPartition();
|
||||
}
|
||||
|
||||
void NewOperation::preview()
|
||||
{
|
||||
insertPreviewPartition(targetDevice(), newPartition());
|
||||
|
|
|
@ -56,6 +56,9 @@ class NewOperation : public Operation
|
|||
void preview();
|
||||
void undo();
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
static bool canCreateNew(const Partition* p);
|
||||
static Partition* createNew(const Partition& cloneFrom);
|
||||
|
||||
|
|
|
@ -106,6 +106,9 @@ class Operation : public QObject
|
|||
virtual void undo() = 0; /**< Undo applying the Operation to the current preview */
|
||||
virtual bool execute(Report& parent);
|
||||
|
||||
virtual bool targets(const Device&) const = 0;
|
||||
virtual bool targets(const Partition&) const = 0;
|
||||
|
||||
virtual OperationStatus status() const { return m_Status; } /**< @return the current status */
|
||||
virtual QString statusText() const;
|
||||
virtual QIcon statusIcon() const;
|
||||
|
|
|
@ -108,6 +108,16 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6
|
|||
}
|
||||
}
|
||||
|
||||
bool ResizeOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
bool ResizeOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == partition();
|
||||
}
|
||||
|
||||
void ResizeOperation::preview()
|
||||
{
|
||||
// If the operation has already been executed, the partition will of course have newFirstSector and
|
||||
|
|
|
@ -81,6 +81,9 @@ class ResizeOperation : public Operation
|
|||
void preview();
|
||||
void undo();
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
static bool canGrow(const Partition* p);
|
||||
static bool canShrink(const Partition* p);
|
||||
static bool canMove(const Partition* p);
|
||||
|
|
|
@ -95,6 +95,16 @@ RestoreOperation::~RestoreOperation()
|
|||
cleanupOverwrittenPartition();
|
||||
}
|
||||
|
||||
bool RestoreOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
bool RestoreOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == restorePartition();
|
||||
}
|
||||
|
||||
void RestoreOperation::preview()
|
||||
{
|
||||
insertPreviewPartition(targetDevice(), restorePartition());
|
||||
|
|
|
@ -62,6 +62,9 @@ class RestoreOperation : public Operation
|
|||
|
||||
void preview();
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
static bool canRestore(const Partition* p);
|
||||
static Partition* createRestorePartition(const Device& device, PartitionNode& parent, qint64 start, const QString& fileName);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "ops/setfilesystemlabeloperation.h"
|
||||
|
||||
#include "core/partition.h"
|
||||
#include "core/device.h"
|
||||
|
||||
#include "jobs/setfilesystemlabeljob.h"
|
||||
|
||||
|
@ -44,6 +45,16 @@ SetFileSystemLabelOperation::SetFileSystemLabelOperation(Partition& p, const QSt
|
|||
addJob(labelJob());
|
||||
}
|
||||
|
||||
bool SetFileSystemLabelOperation::targets(const Device& d) const
|
||||
{
|
||||
return labeledPartition().parent() == d.partitionTable();
|
||||
}
|
||||
|
||||
bool SetFileSystemLabelOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == labeledPartition();
|
||||
}
|
||||
|
||||
void SetFileSystemLabelOperation::preview()
|
||||
{
|
||||
labeledPartition().fileSystem().setLabel(newLabel());
|
||||
|
|
|
@ -52,6 +52,9 @@ class SetFileSystemLabelOperation : public Operation
|
|||
void preview();
|
||||
void undo();
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
protected:
|
||||
Partition& labeledPartition() { return m_LabeledPartition; }
|
||||
const Partition& labeledPartition() const { return m_LabeledPartition; }
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "core/partition.h"
|
||||
#include "core/partitionnode.h"
|
||||
#include "core/partitiontable.h"
|
||||
#include "core/device.h"
|
||||
|
||||
#include "jobs/setpartflagsjob.h"
|
||||
|
||||
|
@ -48,6 +49,16 @@ SetPartFlagsOperation::SetPartFlagsOperation(Device& d, Partition& p, const Part
|
|||
addJob(flagsJob());
|
||||
}
|
||||
|
||||
bool SetPartFlagsOperation::targets(const Device& d) const
|
||||
{
|
||||
return d == targetDevice();
|
||||
}
|
||||
|
||||
bool SetPartFlagsOperation::targets(const Partition& p) const
|
||||
{
|
||||
return p == flagPartition();
|
||||
}
|
||||
|
||||
void SetPartFlagsOperation::preview()
|
||||
{
|
||||
flagPartition().setFlags(newFlags());
|
||||
|
|
|
@ -55,6 +55,9 @@ class SetPartFlagsOperation : public Operation
|
|||
void preview();
|
||||
void undo();
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
|
||||
protected:
|
||||
Partition& flagPartition() { return m_FlagPartition; }
|
||||
const Partition& flagPartition() const { return m_FlagPartition; }
|
||||
|
|
Loading…
Reference in New Issue