[partition] Make private struct type private

- no need for the definition to be in public header, move to implementation
- while here, sort the members and private methods
- add a makeJob() to add jobs to the queue
This commit is contained in:
Adriaan de Groot 2020-08-03 13:20:04 +02:00
parent c2929e93b3
commit 22ba3cc62d
2 changed files with 42 additions and 29 deletions

View File

@ -106,6 +106,39 @@ private:
//- DeviceInfo --------------------------------------------- //- DeviceInfo ---------------------------------------------
/**
* Owns the Device, PartitionModel and the jobs
*/
struct PartitionCoreModule::DeviceInfo
{
DeviceInfo( Device* );
~DeviceInfo();
QScopedPointer< Device > device;
QScopedPointer< PartitionModel > partitionModel;
const QScopedPointer< Device > immutableDevice;
// To check if LVM VGs are deactivated
bool isAvailable;
void forgetChanges();
bool isDirty() const;
const Calamares::JobList& jobs() const { return m_jobs; }
template< typename Job, typename... Args >
Calamares::Job* makeJob(Args... a)
{
auto* job = new Job( device.get(), a... );
job->updatePreview();
m_jobs << Calamares::job_ptr( job );
return job;
}
private:
Calamares::JobList m_jobs;
};
PartitionCoreModule::DeviceInfo::DeviceInfo( Device* _device ) PartitionCoreModule::DeviceInfo::DeviceInfo( Device* _device )
: device( _device ) : device( _device )
, partitionModel( new PartitionModel ) , partitionModel( new PartitionModel )

View File

@ -24,6 +24,7 @@
#include "core/KPMHelpers.h" #include "core/KPMHelpers.h"
#include "core/PartitionLayout.h" #include "core/PartitionLayout.h"
#include "core/PartitionModel.h" #include "core/PartitionModel.h"
#include "jobs/PartitionJob.h"
#include "Job.h" #include "Job.h"
#include "partition/KPMManager.h" #include "partition/KPMManager.h"
@ -241,32 +242,19 @@ Q_SIGNALS:
void deviceReverted( Device* device ); void deviceReverted( Device* device );
private: private:
CalamaresUtils::Partition::KPMManager m_kpmcore; struct DeviceInfo;
void refreshAfterModelChange(); void refreshAfterModelChange();
/** void doInit();
* Owns the Device, PartitionModel and the jobs void updateHasRootMountPoint();
*/ void updateIsDirty();
struct DeviceInfo void scanForEfiSystemPartitions();
{ void scanForLVMPVs();
DeviceInfo( Device* );
~DeviceInfo();
QScopedPointer< Device > device;
QScopedPointer< PartitionModel > partitionModel;
const QScopedPointer< Device > immutableDevice;
// To check if LVM VGs are deactivated DeviceInfo* infoForDevice( const Device* ) const;
bool isAvailable;
void forgetChanges(); CalamaresUtils::Partition::KPMManager m_kpmcore;
bool isDirty() const;
const Calamares::JobList& jobs() const { return m_jobs; }
private:
Calamares::JobList m_jobs;
};
QList< DeviceInfo* > m_deviceInfos; QList< DeviceInfo* > m_deviceInfos;
QList< Partition* > m_efiSystemPartitions; QList< Partition* > m_efiSystemPartitions;
QVector< const Partition* > m_lvmPVs; QVector< const Partition* > m_lvmPVs;
@ -278,14 +266,6 @@ private:
QString m_bootLoaderInstallPath; QString m_bootLoaderInstallPath;
PartitionLayout* m_partLayout; PartitionLayout* m_partLayout;
void doInit();
void updateHasRootMountPoint();
void updateIsDirty();
void scanForEfiSystemPartitions();
void scanForLVMPVs();
DeviceInfo* infoForDevice( const Device* ) const;
OsproberEntryList m_osproberLines; OsproberEntryList m_osproberLines;
QMutex m_revertMutex; QMutex m_revertMutex;