|
|
|
@ -19,13 +19,17 @@
|
|
|
|
|
#include <PartitionCoreModule.h>
|
|
|
|
|
|
|
|
|
|
#include <CreatePartitionJob.h>
|
|
|
|
|
#include <DeletePartitionJob.h>
|
|
|
|
|
#include <DeviceModel.h>
|
|
|
|
|
#include <JobQueue.h>
|
|
|
|
|
#include <PartitionModel.h>
|
|
|
|
|
#include <Typedefs.h>
|
|
|
|
|
#include <utils/Logger.h>
|
|
|
|
|
|
|
|
|
|
// CalaPM
|
|
|
|
|
#include <CalaPM.h>
|
|
|
|
|
#include <core/device.h>
|
|
|
|
|
#include <core/partition.h>
|
|
|
|
|
#include <backend/corebackend.h>
|
|
|
|
|
#include <backend/corebackendmanager.h>
|
|
|
|
|
|
|
|
|
@ -95,7 +99,9 @@ PartitionCoreModule::createPartition( CreatePartitionJob* job )
|
|
|
|
|
Q_ASSERT( info );
|
|
|
|
|
job->updatePreview();
|
|
|
|
|
info->partitionModel->reload();
|
|
|
|
|
Calamares::JobQueue::instance()->enqueue( Calamares::job_ptr( job ) );
|
|
|
|
|
m_jobs << Calamares::job_ptr( job );
|
|
|
|
|
|
|
|
|
|
dumpQueue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PartitionCoreModule::DeviceInfo*
|
|
|
|
@ -110,3 +116,55 @@ PartitionCoreModule::deviceInfoForDevice( Device* device ) const
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
PartitionCoreModule::deletePartition( Device* device, Partition* partition )
|
|
|
|
|
{
|
|
|
|
|
if ( partition->state() == Partition::StateNew )
|
|
|
|
|
{
|
|
|
|
|
// Find matching CreatePartitionJob
|
|
|
|
|
auto it = std::find_if( m_jobs.begin(), m_jobs.end(), [ partition ]( Calamares::job_ptr job )
|
|
|
|
|
{
|
|
|
|
|
CreatePartitionJob* createJob = qobject_cast< CreatePartitionJob* >( job.data() );
|
|
|
|
|
return createJob && createJob->partition() == partition;
|
|
|
|
|
} );
|
|
|
|
|
if ( it == m_jobs.end() )
|
|
|
|
|
{
|
|
|
|
|
cDebug() << "Failed to find a CreatePartitionJob matching the partition to remove";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Remove it
|
|
|
|
|
if ( ! partition->parent()->remove( partition ) )
|
|
|
|
|
{
|
|
|
|
|
cDebug() << "Failed to remove partition from preview";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
device->partitionTable()->updateUnallocated( *device );
|
|
|
|
|
m_jobs.erase( it );
|
|
|
|
|
// The partition is no longer referenced by either a job or the device
|
|
|
|
|
// partition list, so we have to delete it
|
|
|
|
|
delete partition;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DeletePartitionJob* job = new DeletePartitionJob( device, partition );
|
|
|
|
|
job->updatePreview();
|
|
|
|
|
Calamares::JobQueue::instance()->enqueue( Calamares::job_ptr( job ) );
|
|
|
|
|
m_jobs << Calamares::job_ptr( job );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeviceInfo* info = deviceInfoForDevice( device );
|
|
|
|
|
info->partitionModel->reload();
|
|
|
|
|
|
|
|
|
|
dumpQueue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
PartitionCoreModule::dumpQueue() const
|
|
|
|
|
{
|
|
|
|
|
cDebug() << "Queue:";
|
|
|
|
|
for ( auto job : m_jobs )
|
|
|
|
|
{
|
|
|
|
|
cDebug() << job->prettyName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|