PartitionModel* PartitionCoreModule::partitionModelForDevice( Device* device ) const { DeviceInfo* info = infoForDevice( device ); Q_ASSERT( info ); return info->partitionModel.data(); }
Device* PartitionCoreModule::immutableDeviceCopy( const Device* device ) { Q_ASSERT( device ); DeviceInfo* info = infoForDevice( device ); if ( !info ) return nullptr; return info->immutableDevice.data(); }
void PartitionCoreModule::formatPartition( Device* device, Partition* partition ) { auto deviceInfo = infoForDevice( device ); Q_ASSERT( deviceInfo ); PartitionModel::ResetHelper helper( partitionModelForDevice( device ) ); FormatPartitionJob* job = new FormatPartitionJob( device, partition ); deviceInfo->jobs << Calamares::job_ptr( job ); refresh(); }
void PartitionCoreModule::resizePartition( Device* device, Partition* partition, qint64 first, qint64 last ) { auto deviceInfo = infoForDevice( device ); Q_ASSERT( deviceInfo ); PartitionModel::ResetHelper helper( partitionModelForDevice( device ) ); ResizePartitionJob* job = new ResizePartitionJob( device, partition, first, last ); job->updatePreview(); deviceInfo->jobs << Calamares::job_ptr( job ); refresh(); }
void PartitionCoreModule::createPartitionTable( Device* device, PartitionTable::TableType type ) { DeviceInfo* info = infoForDevice( device ); // Creating a partition table wipes all the disk, so there is no need to // keep previous changes info->forgetChanges(); PartitionModel::ResetHelper helper( partitionModelForDevice( device ) ); CreatePartitionTableJob* job = new CreatePartitionTableJob( device, type ); job->updatePreview(); info->jobs << Calamares::job_ptr( job ); refresh(); }
void PartitionCoreModule::setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags ) { auto deviceInfo = infoForDevice( device ); Q_ASSERT( deviceInfo ); PartitionModel::ResetHelper( partitionModelForDevice( device ) ); SetPartFlagsJob* job = new SetPartFlagsJob( device, partition, flags ); deviceInfo->jobs << Calamares::job_ptr( job ); refresh(); }
void PartitionCoreModule::createPartition( Device *device, Partition *partition, PartitionTable::Flags flags ) { auto deviceInfo = infoForDevice( device ); Q_ASSERT( deviceInfo ); PartitionModel::ResetHelper helper( partitionModelForDevice( device ) ); CreatePartitionJob* job = new CreatePartitionJob( device, partition ); job->updatePreview(); deviceInfo->jobs << Calamares::job_ptr( job ); if ( flags != PartitionTable::FlagNone ) { SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags ); deviceInfo->jobs << Calamares::job_ptr( fJob ); } refresh(); }
void PartitionCoreModule::deletePartition( Device* device, Partition* partition ) { auto deviceInfo = infoForDevice( device ); Q_ASSERT( deviceInfo ); PartitionModel::ResetHelper helper( partitionModelForDevice( device ) ); if ( partition->roles().has( PartitionRole::Extended ) ) { // Delete all logical partitions first // I am not sure if we can iterate on Partition::children() while // deleting them, so let's play it safe and keep our own list. QList< Partition* > lst; for ( auto childPartition : partition->children() ) if ( !PMUtils::isPartitionFreeSpace( childPartition ) ) lst << childPartition; for ( auto partition : lst ) deletePartition( device, partition ); } QList< Calamares::job_ptr >& jobs = deviceInfo->jobs; if ( partition->state() == Partition::StateNew ) { // Find matching CreatePartitionJob auto it = std::find_if( jobs.begin(), jobs.end(), [ partition ]( Calamares::job_ptr job ) { CreatePartitionJob* createJob = qobject_cast< CreatePartitionJob* >( job.data() ); return createJob && createJob->partition() == partition; } ); if ( it == 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 ); 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 { // Remove any PartitionJob on this partition for ( auto it = jobs.begin(); it != jobs.end(); ) { PartitionJob* job = qobject_cast< PartitionJob* >( it->data() ); if ( job && job->partition() == partition ) it = jobs.erase( it ); else ++it; } DeletePartitionJob* job = new DeletePartitionJob( device, partition ); job->updatePreview(); jobs << Calamares::job_ptr( job ); } refresh(); }