Let CreatePartitionDialog create the Partition object

This commit is contained in:
Aurélien Gâteau 2014-07-01 17:09:39 +02:00
parent 90d26bfd31
commit e3c6869fbd
4 changed files with 18 additions and 19 deletions

View File

@ -64,5 +64,14 @@ CreatePartitionDialog::createJob()
FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() ); FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() );
FileSystem* fs = FileSystemFactory::create( type, first, last ); FileSystem* fs = FileSystemFactory::create( type, first, last );
return new CreatePartitionJob( m_device, m_freePartition, fs );
PartitionNode* parent = m_freePartition->parent();
Partition* partition = new Partition(
parent,
*m_device,
PartitionRole( PartitionRole::Primary ), // FIXME: Support extended partitions
fs, first, last,
QString() /* path */
);
return new CreatePartitionJob( m_device, partition );
} }

View File

@ -24,10 +24,9 @@
#include <core/partitiontable.h> #include <core/partitiontable.h>
#include <fs/filesystem.h> #include <fs/filesystem.h>
CreatePartitionJob::CreatePartitionJob( Device* device, Partition* freePartition, FileSystem* fs ) CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition )
: m_device( device ) : m_device( device )
, m_freePartition( freePartition ) , m_partition( partition )
, m_fs( fs )
{ {
} }
@ -43,18 +42,9 @@ CreatePartitionJob::exec()
} }
void void
CreatePartitionJob::createPreview() CreatePartitionJob::updatePreview()
{ {
PartitionNode* parent = m_freePartition->parent();
Partition* partition = new Partition(
parent,
*m_device,
PartitionRole( PartitionRole::Primary ), // FIXME: Support extended partitions
m_fs, m_fs->firstSector(), m_fs->lastSector(),
QString() /* path */
);
m_device->partitionTable()->removeUnallocated(); m_device->partitionTable()->removeUnallocated();
parent->insert( partition ); m_partition->parent()->insert( m_partition );
m_device->partitionTable()->updateUnallocated( *m_device ); m_device->partitionTable()->updateUnallocated( *m_device );
} }

View File

@ -28,11 +28,11 @@ class FileSystem;
class CreatePartitionJob : public Calamares::Job class CreatePartitionJob : public Calamares::Job
{ {
public: public:
CreatePartitionJob( Device* device, Partition* freePartition, FileSystem* fs ); CreatePartitionJob( Device* device, Partition* partition );
QString prettyName() override; QString prettyName() override;
void exec() override; void exec() override;
void createPreview(); void updatePreview();
Device* device() const Device* device() const
{ {
return m_device; return m_device;
@ -40,7 +40,7 @@ public:
private: private:
Device* m_device; Device* m_device;
Partition* m_freePartition; Partition* m_partition;
FileSystem* m_fs; FileSystem* m_fs;
}; };

View File

@ -93,7 +93,7 @@ PartitionCoreModule::createPartition( CreatePartitionJob* job )
{ {
DeviceInfo* info = deviceInfoForDevice( job->device() ); DeviceInfo* info = deviceInfoForDevice( job->device() );
Q_ASSERT( info ); Q_ASSERT( info );
job->createPreview(); job->updatePreview();
info->partitionModel->reload(); info->partitionModel->reload();
Calamares::JobQueue::instance()->enqueue( Calamares::job_ptr( job ) ); Calamares::JobQueue::instance()->enqueue( Calamares::job_ptr( job ) );
} }