[partition] Avoid KPMCore warnings

- Get ready for KPMCore post-3.3.0, which deprecates a bunch of
   Flag<foo> and State<foo> in preparation of enum classes.
This commit is contained in:
Adriaan de Groot 2019-03-20 16:32:13 +01:00
parent 5d6d2b8078
commit 2a2795c54c
9 changed files with 29 additions and 20 deletions

View File

@ -67,7 +67,7 @@ isPartitionFreeSpace( Partition* partition )
bool bool
isPartitionNew( Partition* partition ) isPartitionNew( Partition* partition )
{ {
return partition->state() == Partition::StateNew; return partition->state() == KPM_PARTITION_STATE(New);
} }
@ -127,11 +127,11 @@ createNewPartition( PartitionNode* parent,
role, role,
fs, fs->firstSector(), fs->lastSector(), fs, fs->firstSector(), fs->lastSector(),
QString() /* path */, QString() /* path */,
PartitionTable::FlagNone /* availableFlags */, KPM_PARTITION_FLAG(None) /* availableFlags */,
QString() /* mountPoint */, QString() /* mountPoint */,
false /* mounted */, false /* mounted */,
flags /* activeFlags */, flags /* activeFlags */,
Partition::StateNew KPM_PARTITION_STATE(New)
); );
} }
@ -169,11 +169,11 @@ createNewEncryptedPartition( PartitionNode* parent,
PartitionRole( newRoles ), PartitionRole( newRoles ),
fs, fs->firstSector(), fs->lastSector(), fs, fs->firstSector(), fs->lastSector(),
QString() /* path */, QString() /* path */,
PartitionTable::FlagNone /* availableFlags */, KPM_PARTITION_FLAG(None) /* availableFlags */,
QString() /* mountPoint */, QString() /* mountPoint */,
false /* mounted */, false /* mounted */,
flags /* activeFlags */, flags /* activeFlags */,
Partition::StateNew ); KPM_PARTITION_STATE(New) );
return p; return p;
} }

View File

@ -33,6 +33,14 @@ class Partition;
class PartitionNode; class PartitionNode;
class PartitionRole; class PartitionRole;
#ifdef WITH_KPMCOREGT33
#define KPM_PARTITION_FLAG(x) PartitionTable::Flag::x
#define KPM_PARTITION_STATE(x) Partition::State::x
#else
#define KPM_PARTITION_FLAG(x) PartitionTable::Flag##x
#define KPM_PARTITION_STATE(x) Partition::State##x
#endif
/** /**
* Helper functions to manipulate partitions * Helper functions to manipulate partitions
*/ */

View File

@ -425,7 +425,7 @@ isEfiBootable( const Partition* candidate )
const PartitionTable* table = dynamic_cast<const PartitionTable*>( root ); const PartitionTable* table = dynamic_cast<const PartitionTable*>( root );
cDebug() << " .. partition table" << (void *)table << "type" << ( table ? table->type() : PartitionTable::TableType::unknownTableType ); cDebug() << " .. partition table" << (void *)table << "type" << ( table ? table->type() : PartitionTable::TableType::unknownTableType );
return table && ( table->type() == PartitionTable::TableType::gpt ) && return table && ( table->type() == PartitionTable::TableType::gpt ) &&
flags.testFlag( PartitionTable::FlagBoot ); flags.testFlag( KPM_PARTITION_FLAG(Boot) );
} }
QString QString

View File

@ -129,7 +129,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
FileSystem::Fat32, FileSystem::Fat32,
firstFreeSector, firstFreeSector,
lastSector, lastSector,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
PartitionInfo::setFormat( efiPartition, true ); PartitionInfo::setFormat( efiPartition, true );
PartitionInfo::setMountPoint( efiPartition, o.efiPartitionMountPoint ); PartitionInfo::setMountPoint( efiPartition, o.efiPartitionMountPoint );
@ -178,7 +178,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
FileSystem::LinuxSwap, FileSystem::LinuxSwap,
lastSectorForRoot + 1, lastSectorForRoot + 1,
dev->totalLogical() - 1, dev->totalLogical() - 1,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
} }
else else
@ -191,7 +191,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
lastSectorForRoot + 1, lastSectorForRoot + 1,
dev->totalLogical() - 1, dev->totalLogical() - 1,
o.luksPassphrase, o.luksPassphrase,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
} }
PartitionInfo::setFormat( swapPartition, true ); PartitionInfo::setFormat( swapPartition, true );

View File

@ -299,7 +299,7 @@ PartitionCoreModule::createPartition( Device* device,
deviceInfo->jobs << Calamares::job_ptr( job ); deviceInfo->jobs << Calamares::job_ptr( job );
if ( flags != PartitionTable::FlagNone ) if ( flags != KPM_PARTITION_FLAG(None) )
{ {
SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags ); SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags );
deviceInfo->jobs << Calamares::job_ptr( fJob ); deviceInfo->jobs << Calamares::job_ptr( fJob );
@ -401,7 +401,7 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
} }
QList< Calamares::job_ptr >& jobs = deviceInfo->jobs; QList< Calamares::job_ptr >& jobs = deviceInfo->jobs;
if ( partition->state() == Partition::StateNew ) if ( partition->state() == KPM_PARTITION_STATE(New) )
{ {
// First remove matching SetPartFlagsJobs // First remove matching SetPartFlagsJobs
for ( auto it = jobs.begin(); it != jobs.end(); ) for ( auto it = jobs.begin(); it != jobs.end(); )
@ -832,7 +832,7 @@ PartitionCoreModule::layoutApply( Device *dev,
if ( part->mountPoint() == "/" ) if ( part->mountPoint() == "/" )
{ {
createPartition( dev, part, createPartition( dev, part,
part->activeFlags() | ( isEfi ? PartitionTable::FlagNone : PartitionTable::FlagBoot ) part->activeFlags() | ( isEfi ? KPM_PARTITION_FLAG(None) : KPM_PARTITION_FLAG(Boot) )
); );
} }
else else

View File

@ -20,6 +20,7 @@
#ifndef PARTITIONCOREMODULE_H #ifndef PARTITIONCOREMODULE_H
#define PARTITIONCOREMODULE_H #define PARTITIONCOREMODULE_H
#include "core/KPMHelpers.h"
#include "core/PartitionLayout.h" #include "core/PartitionLayout.h"
#include "core/PartitionModel.h" #include "core/PartitionModel.h"
#include "Typedefs.h" #include "Typedefs.h"
@ -136,7 +137,7 @@ public:
* applied to the newly-created partition. * applied to the newly-created partition.
*/ */
void createPartition( Device* device, Partition* partition, void createPartition( Device* device, Partition* partition,
PartitionTable::Flags flags = PartitionTable::FlagNone ); PartitionTable::Flags flags = KPM_PARTITION_FLAG(None) );
void createVolumeGroup( QString &vgName, QVector< const Partition* > pvList, qint32 peSize ); void createVolumeGroup( QString &vgName, QVector< const Partition* > pvList, qint32 peSize );

View File

@ -143,7 +143,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
part.partFileSystem, part.partFileSystem,
firstSector, firstSector,
end, end,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
} }
else else
@ -156,7 +156,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
firstSector, firstSector,
end, end,
luksPassphrase, luksPassphrase,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
} }
PartitionInfo::setFormat( currentPartition, true ); PartitionInfo::setFormat( currentPartition, true );

View File

@ -154,7 +154,7 @@ ReplaceWidget::onPartitionSelected()
Partition* partition = model->partitionForIndex( m_ui->partitionTreeView->currentIndex() ); Partition* partition = model->partitionForIndex( m_ui->partitionTreeView->currentIndex() );
if ( !partition || if ( !partition ||
partition->state() != Partition::StateNone ) partition->state() != KPM_PARTITION_STATE(None) )
{ {
updateStatus( CalamaresUtils::Fail, updateStatus( CalamaresUtils::Fail,
tr( "The selected item does not appear to be a valid partition." ) ); tr( "The selected item does not appear to be a valid partition." ) );

View File

@ -228,11 +228,11 @@ PartitionJobTests::newCreatePartitionJob( Partition* freeSpacePartition, Partiti
role, role,
fs, firstSector, lastSector, fs, firstSector, lastSector,
QString() /* path */, QString() /* path */,
PartitionTable::FlagNone /* availableFlags */, KPM_PARTITION_FLAG(None) /* availableFlags */,
QString() /* mountPoint */, QString() /* mountPoint */,
false /* mounted */, false /* mounted */,
PartitionTable::FlagNone /* activeFlags */, KPM_PARTITION_FLAG(None) /* activeFlags */,
Partition::StateNew KPM_PARTITION_STATE(New)
); );
return new CreatePartitionJob( m_device.data(), partition ); return new CreatePartitionJob( m_device.data(), partition );
} }
@ -366,7 +366,7 @@ PartitionJobTests::testResizePartition()
FileSystem::Ext4, FileSystem::Ext4,
oldFirst, oldFirst,
oldLast, oldLast,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
CreatePartitionJob* job = new CreatePartitionJob( m_device.data(), partition ); CreatePartitionJob* job = new CreatePartitionJob( m_device.data(), partition );
job->updatePreview(); job->updatePreview();