Refactor: Move creation of CreatePartitionJob to PartitionCoreModule

main
Aurélien Gâteau 11 years ago
parent d54dfcfb78
commit 3ed5704818

@ -18,7 +18,7 @@
#include <CreatePartitionDialog.h>
#include <CreatePartitionJob.h>
#include <PartitionInfo.h>
#include <ui_CreatePartitionDialog.h>
// CalaPM
@ -78,8 +78,8 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePar
CreatePartitionDialog::~CreatePartitionDialog()
{}
CreatePartitionJob*
CreatePartitionDialog::createJob()
PartitionInfo*
CreatePartitionDialog::createPartitionInfo()
{
if ( m_role.roles() == PartitionRole::None )
{
@ -100,7 +100,7 @@ CreatePartitionDialog::createJob()
FileSystem* fs = FileSystemFactory::create( type, first, last );
PartitionNode* parent = m_freePartition->parent();
Partition* partition = new Partition(
auto partition = new Partition(
parent,
*m_device,
m_role,
@ -112,7 +112,8 @@ CreatePartitionDialog::createJob()
PartitionTable::FlagNone /* activeFlags */,
Partition::StateNew
);
return new CreatePartitionJob( m_device, partition,
m_ui->mountPointComboBox->currentText()
);
auto info = new PartitionInfo( partition );
info->mountPoint = m_ui->mountPointComboBox->currentText();
return info;
}

@ -25,9 +25,9 @@
// CalaPM
#include <core/partitionrole.h>
class CreatePartitionJob;
class Device;
class Partition;
class PartitionInfo;
class Ui_CreatePartitionDialog;
class CreatePartitionDialog : public QDialog
@ -36,7 +36,7 @@ public:
CreatePartitionDialog( Device* device, Partition* freePartition, QWidget* parent = nullptr );
~CreatePartitionDialog();
CreatePartitionJob* createJob();
PartitionInfo* createPartitionInfo();
private:
QScopedPointer< Ui_CreatePartitionDialog > m_ui;

@ -24,10 +24,9 @@
#include <core/partitiontable.h>
#include <fs/filesystem.h>
CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition, const QString& mountPoint )
CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition )
: m_device( device )
, m_partition( partition )
, m_mountPoint( mountPoint )
{
}

@ -29,7 +29,7 @@ class CreatePartitionJob : public Calamares::Job
{
Q_OBJECT
public:
CreatePartitionJob( Device* device, Partition* partition, const QString& mountPoint );
CreatePartitionJob( Device* device, Partition* partition );
QString prettyName() override;
void exec() override;
@ -44,15 +44,9 @@ public:
return m_partition;
}
QString mountPoint() const
{
return m_mountPoint;
}
private:
Device* m_device;
Partition* m_partition;
QString m_mountPoint;
};
#endif /* CREATEPARTITIONJOB_H */

@ -74,13 +74,15 @@ PartitionCoreModule::partitionModelForDevice( Device* device ) const
}
void
PartitionCoreModule::createPartition( CreatePartitionJob* job )
PartitionCoreModule::createPartition( Device* device, PartitionInfo* partitionInfo )
{
Q_ASSERT( !m_infoForPartitionHash.contains( job->partition() ) );
PartitionInfo* partitionInfo = new PartitionInfo( job->partition() );
partitionInfo->mountPoint = job->mountPoint();
m_infoForPartitionHash[ job->partition() ] = partitionInfo;
auto partition = partitionInfo->partition;
Q_ASSERT( !m_infoForPartitionHash.contains( partition ) );
m_infoForPartitionHash[ partition ] = partitionInfo;
CreatePartitionJob* job = new CreatePartitionJob( device, partition );
job->updatePreview();
auto partitionModel = m_partitionModelForDeviceHash.value( job->device() );
Q_ASSERT( partitionModel );
partitionModel->reload();

@ -49,7 +49,7 @@ public:
PartitionModel* partitionModelForDevice( Device* device ) const;
void createPartition( CreatePartitionJob* job );
void createPartition( Device* device, PartitionInfo* partitionInfo );
void deletePartition( Device* device, Partition* partition );

@ -107,7 +107,7 @@ PartitionPage::onCreateClicked()
QPointer<CreatePartitionDialog> dlg = new CreatePartitionDialog( model->device(), partition, this );
if ( dlg->exec() == QDialog::Accepted )
{
m_core->createPartition( dlg->createJob() );
m_core->createPartition( model->device(), dlg->createPartitionInfo() );
}
delete dlg;
}

Loading…
Cancel
Save