[partition] Apply coding style

This commit is contained in:
Adriaan de Groot 2021-03-27 15:43:32 +01:00
parent 1007680931
commit 1eba562d07
8 changed files with 51 additions and 55 deletions

View File

@ -543,7 +543,8 @@ PartitionCoreModule::formatPartition( Device* device, Partition* partition )
} }
void void
PartitionCoreModule::setFilesystemLabel(Device *device, Partition *partition, const QString& newLabel) { PartitionCoreModule::setFilesystemLabel( Device* device, Partition* partition, const QString& newLabel )
{
auto deviceInfo = infoForDevice( device ); auto deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo ); Q_ASSERT( deviceInfo );

View File

@ -213,7 +213,8 @@ CreatePartitionDialog::createPartition()
} }
else else
{ {
partition = KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, fsLabel, first, last, newFlags() ); partition
= KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, fsLabel, first, last, newFlags() );
} }
if ( m_device->type() == Device::Type::LVM_Device ) if ( m_device->type() == Device::Type::LVM_Device )

View File

@ -225,8 +225,9 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
// In this case, we are not formatting the partition, but we are setting the // In this case, we are not formatting the partition, but we are setting the
// label on the current filesystem, if any. We only create the job if the // label on the current filesystem, if any. We only create the job if the
// label actually changed. // label actually changed.
if (m_partition->fileSystem().type() != FileSystem::Type::Unformatted && if ( m_partition->fileSystem().type() != FileSystem::Type::Unformatted
fsLabel != m_partition->fileSystem().label()) { && fsLabel != m_partition->fileSystem().label() )
{
core->setFilesystemLabel( m_device, m_partition, fsLabel ); core->setFilesystemLabel( m_device, m_partition, fsLabel );
} }
core->refreshPartition( m_device, m_partition ); core->refreshPartition( m_device, m_partition );

View File

@ -11,22 +11,21 @@
#include "utils/Logger.h" #include "utils/Logger.h"
#include <kpmcore/core/partition.h>
#include <kpmcore/backend/corebackend.h> #include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackenddevice.h> #include <kpmcore/backend/corebackenddevice.h>
#include <kpmcore/backend/corebackendmanager.h> #include <kpmcore/backend/corebackendmanager.h>
#include <kpmcore/backend/corebackendpartition.h> #include <kpmcore/backend/corebackendpartition.h>
#include <kpmcore/backend/corebackendpartitiontable.h> #include <kpmcore/backend/corebackendpartitiontable.h>
#include <kpmcore/core/device.h> #include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/util/report.h> #include <kpmcore/util/report.h>
ChangeFilesystemLabelJob::ChangeFilesystemLabelJob( Device* device, ChangeFilesystemLabelJob::ChangeFilesystemLabelJob( Device* device, Partition* partition, const QString& newLabel )
Partition* partition,
const QString& newLabel )
: PartitionJob( partition ) : PartitionJob( partition )
, m_device( device ) , m_device( device )
, m_label( newLabel ) , m_label( newLabel )
{} {
}
QString QString
@ -56,7 +55,8 @@ ChangeFilesystemLabelJob::prettyStatusMessage() const
Calamares::JobResult Calamares::JobResult
ChangeFilesystemLabelJob::exec() ChangeFilesystemLabelJob::exec()
{ {
if (m_label == partition()->fileSystem().label()) { if ( m_label == partition()->fileSystem().label() )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
} }
@ -66,31 +66,25 @@ ChangeFilesystemLabelJob::exec()
QScopedPointer< CoreBackendDevice > backendDevice( backend->openDevice( m_device->deviceNode() ) ); QScopedPointer< CoreBackendDevice > backendDevice( backend->openDevice( m_device->deviceNode() ) );
if ( !backendDevice.data() ) if ( !backendDevice.data() )
{ {
return Calamares::JobResult::error( return Calamares::JobResult::error( tr( "Could not open device '%1'." ).arg( m_device->deviceNode() ),
tr( "Could not open device '%1'." ).arg( m_device->deviceNode() ), report.toText() );
report.toText()
);
} }
QScopedPointer< CoreBackendPartitionTable > backendPartitionTable( backendDevice->openPartitionTable() ); QScopedPointer< CoreBackendPartitionTable > backendPartitionTable( backendDevice->openPartitionTable() );
if ( !backendPartitionTable.data() ) if ( !backendPartitionTable.data() )
{ {
return Calamares::JobResult::error( return Calamares::JobResult::error(
tr( "Could not open partition table on device '%1'." ).arg( m_device->deviceNode() ), tr( "Could not open partition table on device '%1'." ).arg( m_device->deviceNode() ), report.toText() );
report.toText()
);
} }
QScopedPointer< CoreBackendPartition > backendPartition( QScopedPointer< CoreBackendPartition > backendPartition(
( partition()->roles().has( PartitionRole::Extended ) ) ( partition()->roles().has( PartitionRole::Extended ) )
? backendPartitionTable->getExtendedPartition() ? backendPartitionTable->getExtendedPartition()
: backendPartitionTable->getPartitionBySector( partition()->firstSector() ) : backendPartitionTable->getPartitionBySector( partition()->firstSector() ) );
); if ( !backendPartition.data() )
if ( !backendPartition.data() ) { {
return Calamares::JobResult::error( return Calamares::JobResult::error( tr( "Could not find partition '%1'." ).arg( partition()->partitionPath() ),
tr( "Could not find partition '%1'." ).arg( partition()->partitionPath() ), report.toText() );
report.toText()
);
} }
FileSystem& fs = m_partition->fileSystem(); FileSystem& fs = m_partition->fileSystem();
@ -100,8 +94,7 @@ ChangeFilesystemLabelJob::exec()
{ {
return Calamares::JobResult::error( return Calamares::JobResult::error(
tr( "The installer failed to update partition table on disk '%1'." ).arg( m_device->name() ), tr( "The installer failed to update partition table on disk '%1'." ).arg( m_device->name() ),
report.toText() report.toText() );
);
} }
backendPartitionTable->commit(); backendPartitionTable->commit();

View File

@ -146,7 +146,8 @@ CreatePartitionJob::prettyDescription() const
QString entries = prettyGptEntries( m_partition ); QString entries = prettyGptEntries( m_partition );
if ( !entries.isEmpty() ) if ( !entries.isEmpty() )
{ {
return tr( "Create new <strong>%1MiB</strong> partition on <strong>%3</strong> (%2) with entries <em>%4</em>." ) return tr( "Create new <strong>%1MiB</strong> partition on <strong>%3</strong> (%2) with entries "
"<em>%4</em>." )
.arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) )
.arg( m_device->name() ) .arg( m_device->name() )
.arg( m_device->deviceNode() ) .arg( m_device->deviceNode() )
@ -186,9 +187,7 @@ CreatePartitionJob::prettyStatusMessage() const
type = userVisibleFS( m_partition->fileSystem() ); type = userVisibleFS( m_partition->fileSystem() );
} }
return tr( "Creating new %1 partition on %2." ) return tr( "Creating new %1 partition on %2." ).arg( type ).arg( m_device->deviceNode() );
.arg( type )
.arg( m_device->deviceNode() );
} }
return tr( "Creating new %1 partition on %2." ) return tr( "Creating new %1 partition on %2." )

View File

@ -9,8 +9,8 @@
#include "jobs/AutoMountManagementJob.h" #include "jobs/AutoMountManagementJob.h"
#include "utils/Logger.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "utils/Logger.h"
#include <QObject> #include <QObject>
#include <QtTest/QtTest> #include <QtTest/QtTest>
@ -52,7 +52,8 @@ AutoMountJobTests::testRunThrice()
CalamaresUtils::Partition::automountRestore( original ); CalamaresUtils::Partition::automountRestore( original );
} }
void AutoMountJobTests::testRunQueue() void
AutoMountJobTests::testRunQueue()
{ {
Calamares::JobQueue q; Calamares::JobQueue q;
Calamares::job_ptr jp( new AutoMountManagementJob( false ) ); Calamares::job_ptr jp( new AutoMountManagementJob( false ) );