[partition] Switch to convenience function for MiB

This commit is contained in:
Adriaan de Groot 2017-12-14 16:00:46 -05:00
parent 38688bab47
commit 5c4286eebf
2 changed files with 16 additions and 9 deletions

View File

@ -20,11 +20,15 @@
#include "jobs/ResizePartitionJob.h" #include "jobs/ResizePartitionJob.h"
#include "utils/Units.h"
// KPMcore // KPMcore
#include <core/device.h> #include <core/device.h>
#include <ops/resizeoperation.h> #include <ops/resizeoperation.h>
#include <util/report.h> #include <util/report.h>
using CalamaresUtils::BytesToMiB;
//- ResizePartitionJob --------------------------------------------------------- //- ResizePartitionJob ---------------------------------------------------------
ResizePartitionJob::ResizePartitionJob( Device* device, Partition* partition, qint64 firstSector, qint64 lastSector ) ResizePartitionJob::ResizePartitionJob( Device* device, Partition* partition, qint64 firstSector, qint64 lastSector )
: PartitionJob( partition ) : PartitionJob( partition )
@ -51,8 +55,8 @@ ResizePartitionJob::prettyDescription() const
return tr( "Resize <strong>%2MB</strong> partition <strong>%1</strong> to " return tr( "Resize <strong>%2MB</strong> partition <strong>%1</strong> to "
"<strong>%3MB</strong>." ) "<strong>%3MB</strong>." )
.arg( partition()->partitionPath() ) .arg( partition()->partitionPath() )
.arg( ( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() / 1024 / 1024 ) .arg( ( BytesToMiB( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() ) )
.arg( ( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() / 1024 / 1024 ); .arg( ( BytesToMiB( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() ) );
} }
@ -62,8 +66,8 @@ ResizePartitionJob::prettyStatusMessage() const
return tr( "Resizing %2MB partition %1 to " return tr( "Resizing %2MB partition %1 to "
"%3MB." ) "%3MB." )
.arg( partition()->partitionPath() ) .arg( partition()->partitionPath() )
.arg( ( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() / 1024 / 1024 ) .arg( ( BytesToMiB( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() ) )
.arg( ( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() / 1024 / 1024 ); .arg( ( BytesToMiB( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() ) );
} }

View File

@ -22,6 +22,7 @@
#include "SetPartitionFlagsJob.h" #include "SetPartitionFlagsJob.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Units.h"
// KPMcore // KPMcore
#include <core/device.h> #include <core/device.h>
@ -30,6 +31,8 @@
#include <ops/setpartflagsoperation.h> #include <ops/setpartflagsoperation.h>
#include <util/report.h> #include <util/report.h>
using CalamaresUtils::BytesToMiB;
SetPartFlagsJob::SetPartFlagsJob( Device* device, SetPartFlagsJob::SetPartFlagsJob( Device* device,
Partition* partition, Partition* partition,
PartitionTable::Flags flags ) PartitionTable::Flags flags )
@ -47,7 +50,7 @@ SetPartFlagsJob::prettyName() const
if ( !partition()->fileSystem().name().isEmpty() ) if ( !partition()->fileSystem().name().isEmpty() )
return tr( "Set flags on %1MB %2 partition." ) return tr( "Set flags on %1MB %2 partition." )
.arg( partition()->capacity() /1024 /1024 ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() ); .arg( partition()->fileSystem().name() );
return tr( "Set flags on new partition." ); return tr( "Set flags on new partition." );
@ -66,7 +69,7 @@ SetPartFlagsJob::prettyDescription() const
if ( !partition()->fileSystem().name().isEmpty() ) if ( !partition()->fileSystem().name().isEmpty() )
return tr( "Clear flags on %1MB <strong>%2</strong> partition." ) return tr( "Clear flags on %1MB <strong>%2</strong> partition." )
.arg( partition()->capacity() /1024 /1024 ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() ); .arg( partition()->fileSystem().name() );
return tr( "Clear flags on new partition." ); return tr( "Clear flags on new partition." );
@ -81,7 +84,7 @@ SetPartFlagsJob::prettyDescription() const
if ( !partition()->fileSystem().name().isEmpty() ) if ( !partition()->fileSystem().name().isEmpty() )
return tr( "Flag %1MB <strong>%2</strong> partition as " return tr( "Flag %1MB <strong>%2</strong> partition as "
"<strong>%3</strong>." ) "<strong>%3</strong>." )
.arg( partition()->capacity() /1024 /1024 ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() ) .arg( partition()->fileSystem().name() )
.arg( flagsList.join( ", " ) ); .arg( flagsList.join( ", " ) );
@ -102,7 +105,7 @@ SetPartFlagsJob::prettyStatusMessage() const
if ( !partition()->fileSystem().name().isEmpty() ) if ( !partition()->fileSystem().name().isEmpty() )
return tr( "Clearing flags on %1MB <strong>%2</strong> partition." ) return tr( "Clearing flags on %1MB <strong>%2</strong> partition." )
.arg( partition()->capacity() /1024 /1024 ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() ); .arg( partition()->fileSystem().name() );
return tr( "Clearing flags on new partition." ); return tr( "Clearing flags on new partition." );
@ -117,7 +120,7 @@ SetPartFlagsJob::prettyStatusMessage() const
if ( !partition()->fileSystem().name().isEmpty() ) if ( !partition()->fileSystem().name().isEmpty() )
return tr( "Setting flags <strong>%3</strong> on " return tr( "Setting flags <strong>%3</strong> on "
"%1MB <strong>%2</strong> partition." ) "%1MB <strong>%2</strong> partition." )
.arg( partition()->capacity() /1024 /1024 ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() ) .arg( partition()->fileSystem().name() )
.arg( flagsList.join( ", " ) ); .arg( flagsList.join( ", " ) );