コード例 #1
0
void RestoreOperation::undo()
{
	removePreviewPartition(targetDevice(), restorePartition());

	if (overwrittenPartition())
		insertPreviewPartition(targetDevice(), *overwrittenPartition());
}
コード例 #2
0
/** Creates a new RestoreOperation.
	@param d the Device to restore the Partition to
	@param p pointer to the Partition that will be restored. May not be NULL.
	@param filename name of the image file to restore from
*/
RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filename) :
	Operation(),
	m_TargetDevice(d),
	m_RestorePartition(p),
	m_FileName(filename),
	m_OverwrittenPartition(NULL),
	m_MustDeleteOverwritten(false),
	m_ImageLength(QFileInfo(filename).size() / 512), // 512 being the "sector size" of an image file.
	m_CreatePartitionJob(NULL),
	m_RestoreJob(NULL),
	m_CheckTargetJob(NULL),
	m_MaximizeJob(NULL)
{
	restorePartition().setState(Partition::StateRestore);

	Q_ASSERT(targetDevice().partitionTable());

	Partition* dest = targetDevice().partitionTable()->findPartitionBySector(restorePartition().firstSector(), PartitionRole(PartitionRole::Primary | PartitionRole::Logical | PartitionRole::Unallocated));

	Q_ASSERT(dest);

	if (dest == NULL)
		qWarning() << "destination partition not found at sector " << restorePartition().firstSector();

	if (dest && !dest->roles().has(PartitionRole::Unallocated))
	{
		restorePartition().setLastSector(dest->lastSector());
		setOverwrittenPartition(dest);
		removePreviewPartition(targetDevice(), *dest);
	}

	if (!overwrittenPartition())
		addJob(m_CreatePartitionJob = new CreatePartitionJob(targetDevice(), restorePartition()));

	addJob(m_RestoreJob = new RestoreFileSystemJob(targetDevice(), restorePartition(), fileName()));
	addJob(m_CheckTargetJob = new CheckFileSystemJob(restorePartition()));
	addJob(m_MaximizeJob = new ResizeFileSystemJob(targetDevice(), restorePartition()));
}
コード例 #3
0
ファイル: newoperation.cpp プロジェクト: KDE/kpmcore
void NewOperation::undo()
{
    removePreviewPartition(targetDevice(), newPartition());
}
コード例 #4
0
ファイル: deleteoperation.cpp プロジェクト: shainer/kpmcore
void DeleteOperation::preview()
{
    removePreviewPartition(targetDevice(), deletedPartition());
    checkAdjustLogicalNumbers(deletedPartition(), false);
}