Move code cloning the partition for PartResizerWidget to PMUtils

This commit is contained in:
Aurélien Gâteau 2014-08-07 12:59:24 +02:00
parent c109059eb7
commit 38c685dc10
3 changed files with 19 additions and 13 deletions

View File

@ -44,19 +44,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
// Create a partition for partResizerWidget because it alters the first and // Create a partition for partResizerWidget because it alters the first and
// last sectors when used // last sectors when used
FileSystem* fs = FileSystemFactory::create( m_partResizerWidgetPartition.reset( PMUtils::clonePartition( m_device, m_partition ) );
m_partition->fileSystem().type(),
m_partition->firstSector(),
m_partition->lastSector()
);
m_partResizerWidgetPartition.reset( new Partition(
m_partition->parent(),
*m_device,
m_partition->roles(),
fs, fs->firstSector(), fs->lastSector(),
m_partition->partitionPath()
)
);
m_partitionSizeController->init( m_device, m_partResizerWidgetPartition.data() ); m_partitionSizeController->init( m_device, m_partResizerWidgetPartition.data() );
m_partitionSizeController->setSpinBox( m_ui->sizeSpinBox ); m_partitionSizeController->setSpinBox( m_ui->sizeSpinBox );

View File

@ -66,4 +66,21 @@ createNewPartition( PartitionNode* parent, const Device& device, const Partition
); );
} }
Partition*
clonePartition( Device* device, Partition* partition )
{
FileSystem* fs = FileSystemFactory::create(
partition->fileSystem().type(),
partition->firstSector(),
partition->lastSector()
);
return new Partition(
partition->parent(),
*device,
partition->roles(),
fs, fs->firstSector(), fs->lastSector(),
partition->partitionPath()
);
}
} // namespace } // namespace

View File

@ -40,6 +40,7 @@ Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QSt
Partition* createNewPartition( PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem::Type fsType, qint64 firstSector, qint64 lastSector ); Partition* createNewPartition( PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem::Type fsType, qint64 firstSector, qint64 lastSector );
Partition* clonePartition( Device* device, Partition* partition );
} }
#endif /* PMUTILS_H */ #endif /* PMUTILS_H */