From 1eba562d07283f2778ebb8d6507e777a9103e439 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 27 Mar 2021 15:43:32 +0100 Subject: [PATCH] [partition] Apply coding style --- .../partition/core/PartitionCoreModule.cpp | 3 +- .../partition/core/PartitionCoreModule.h | 2 +- .../partition/gui/CreatePartitionDialog.cpp | 3 +- .../gui/EditExistingPartitionDialog.cpp | 5 ++- .../jobs/ChangeFilesystemLabelJob.cpp | 45 ++++++++----------- .../partition/jobs/ChangeFilesystemLabelJob.h | 2 +- .../partition/jobs/CreatePartitionJob.cpp | 37 ++++++++------- .../partition/tests/AutoMountTests.cpp | 9 ++-- 8 files changed, 51 insertions(+), 55 deletions(-) diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 0ef4dca56..058c10d18 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -543,7 +543,8 @@ PartitionCoreModule::formatPartition( Device* device, Partition* partition ) } void -PartitionCoreModule::setFilesystemLabel(Device *device, Partition *partition, const QString& newLabel) { +PartitionCoreModule::setFilesystemLabel( Device* device, Partition* partition, const QString& newLabel ) +{ auto deviceInfo = infoForDevice( device ); Q_ASSERT( deviceInfo ); diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h index 47353530b..492348187 100644 --- a/src/modules/partition/core/PartitionCoreModule.h +++ b/src/modules/partition/core/PartitionCoreModule.h @@ -147,7 +147,7 @@ public: void formatPartition( Device* device, Partition* partition ); - void setFilesystemLabel( Device* device, Partition* partition, const QString& newLabel); + void setFilesystemLabel( Device* device, Partition* partition, const QString& newLabel ); void resizePartition( Device* device, Partition* partition, qint64 first, qint64 last ); diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 11f7f3e86..c765bf1f7 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -213,7 +213,8 @@ CreatePartitionDialog::createPartition() } 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 ) diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 7a4ea138f..e2d7ac5ba 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -225,8 +225,9 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core ) // 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 actually changed. - if (m_partition->fileSystem().type() != FileSystem::Type::Unformatted && - fsLabel != m_partition->fileSystem().label()) { + if ( m_partition->fileSystem().type() != FileSystem::Type::Unformatted + && fsLabel != m_partition->fileSystem().label() ) + { core->setFilesystemLabel( m_device, m_partition, fsLabel ); } core->refreshPartition( m_device, m_partition ); diff --git a/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp b/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp index 658acc71c..2df2db5e4 100644 --- a/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp +++ b/src/modules/partition/jobs/ChangeFilesystemLabelJob.cpp @@ -11,22 +11,21 @@ #include "utils/Logger.h" -#include #include #include #include #include #include #include +#include #include -ChangeFilesystemLabelJob::ChangeFilesystemLabelJob( Device* device, - Partition* partition, - const QString& newLabel ) +ChangeFilesystemLabelJob::ChangeFilesystemLabelJob( Device* device, Partition* partition, const QString& newLabel ) : PartitionJob( partition ) , m_device( device ) , m_label( newLabel ) -{} +{ +} QString @@ -41,8 +40,8 @@ ChangeFilesystemLabelJob::prettyDescription() const { return tr( "Set filesystem label %1 to partition " "%2." ) - .arg( m_label ) - .arg( partition()->partitionPath() ); + .arg( m_label ) + .arg( partition()->partitionPath() ); } @@ -56,7 +55,8 @@ ChangeFilesystemLabelJob::prettyStatusMessage() const Calamares::JobResult ChangeFilesystemLabelJob::exec() { - if (m_label == partition()->fileSystem().label()) { + if ( m_label == partition()->fileSystem().label() ) + { return Calamares::JobResult::ok(); } @@ -66,31 +66,25 @@ ChangeFilesystemLabelJob::exec() QScopedPointer< CoreBackendDevice > backendDevice( backend->openDevice( m_device->deviceNode() ) ); if ( !backendDevice.data() ) { - return Calamares::JobResult::error( - tr( "Could not open device '%1'." ).arg( m_device->deviceNode() ), - report.toText() - ); + return Calamares::JobResult::error( tr( "Could not open device '%1'." ).arg( m_device->deviceNode() ), + report.toText() ); } QScopedPointer< CoreBackendPartitionTable > backendPartitionTable( backendDevice->openPartitionTable() ); if ( !backendPartitionTable.data() ) { return Calamares::JobResult::error( - tr( "Could not open partition table on device '%1'." ).arg( m_device->deviceNode() ), - report.toText() - ); + tr( "Could not open partition table on device '%1'." ).arg( m_device->deviceNode() ), report.toText() ); } QScopedPointer< CoreBackendPartition > backendPartition( - ( partition()->roles().has( PartitionRole::Extended ) ) + ( partition()->roles().has( PartitionRole::Extended ) ) ? backendPartitionTable->getExtendedPartition() - : backendPartitionTable->getPartitionBySector( partition()->firstSector() ) - ); - if ( !backendPartition.data() ) { - return Calamares::JobResult::error( - tr( "Could not find partition '%1'." ).arg( partition()->partitionPath() ), - report.toText() - ); + : backendPartitionTable->getPartitionBySector( partition()->firstSector() ) ); + if ( !backendPartition.data() ) + { + return Calamares::JobResult::error( tr( "Could not find partition '%1'." ).arg( partition()->partitionPath() ), + report.toText() ); } FileSystem& fs = m_partition->fileSystem(); @@ -99,9 +93,8 @@ ChangeFilesystemLabelJob::exec() if ( !backendPartitionTable->setPartitionSystemType( report, *m_partition ) ) { return Calamares::JobResult::error( - tr( "The installer failed to update partition table on disk '%1'." ).arg( m_device->name() ), - report.toText() - ); + tr( "The installer failed to update partition table on disk '%1'." ).arg( m_device->name() ), + report.toText() ); } backendPartitionTable->commit(); diff --git a/src/modules/partition/jobs/ChangeFilesystemLabelJob.h b/src/modules/partition/jobs/ChangeFilesystemLabelJob.h index 3d8982c15..ac3960538 100644 --- a/src/modules/partition/jobs/ChangeFilesystemLabelJob.h +++ b/src/modules/partition/jobs/ChangeFilesystemLabelJob.h @@ -37,4 +37,4 @@ private: QString m_label; }; -#endif // CHANGEFILESYSTEMLABELJOB_H +#endif // CHANGEFILESYSTEMLABELJOB_H diff --git a/src/modules/partition/jobs/CreatePartitionJob.cpp b/src/modules/partition/jobs/CreatePartitionJob.cpp index 2b6451c3e..b4d89c5eb 100644 --- a/src/modules/partition/jobs/CreatePartitionJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionJob.cpp @@ -33,7 +33,7 @@ CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition ) { } -static const QMap < QString, QString > gptTypePrettyStrings = { +static const QMap< QString, QString > gptTypePrettyStrings = { { "44479540-f297-41b2-9af7-d131d5f0458a", "Linux Root Partition (x86)" }, { "4f68bce3-e8cd-4db1-96e7-fbcaf984b709", "Linux Root Partition (x86-64)" }, { "69dad710-2ce4-4e3c-b16c-21a1d49abed3", "Linux Root Partition (32-bit ARM)" }, @@ -115,17 +115,17 @@ CreatePartitionJob::prettyName() const if ( !entries.isEmpty() ) { return tr( "Create new %1MiB partition on %3 (%2) with entries %4." ) - .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) - .arg( m_device->name() ) - .arg( m_device->deviceNode() ) - .arg( entries ); + .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) + .arg( m_device->name() ) + .arg( m_device->deviceNode() ) + .arg( entries ); } else { return tr( "Create new %1MiB partition on %3 (%2)." ) - .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) - .arg( m_device->name() ) - .arg( m_device->deviceNode() ); + .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) + .arg( m_device->name() ) + .arg( m_device->deviceNode() ); } } @@ -146,18 +146,19 @@ CreatePartitionJob::prettyDescription() const QString entries = prettyGptEntries( m_partition ); if ( !entries.isEmpty() ) { - return tr( "Create new %1MiB partition on %3 (%2) with entries %4." ) - .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) - .arg( m_device->name() ) - .arg( m_device->deviceNode() ) - .arg( entries ); + return tr( "Create new %1MiB partition on %3 (%2) with entries " + "%4." ) + .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) + .arg( m_device->name() ) + .arg( m_device->deviceNode() ) + .arg( entries ); } else { return tr( "Create new %1MiB partition on %3 (%2)." ) - .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) - .arg( m_device->name() ) - .arg( m_device->deviceNode() ); + .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) + .arg( m_device->name() ) + .arg( m_device->deviceNode() ); } } @@ -186,9 +187,7 @@ CreatePartitionJob::prettyStatusMessage() const type = userVisibleFS( m_partition->fileSystem() ); } - return tr( "Creating new %1 partition on %2." ) - .arg( type ) - .arg( m_device->deviceNode() ); + return tr( "Creating new %1 partition on %2." ).arg( type ).arg( m_device->deviceNode() ); } return tr( "Creating new %1 partition on %2." ) diff --git a/src/modules/partition/tests/AutoMountTests.cpp b/src/modules/partition/tests/AutoMountTests.cpp index fcebe02bd..45a7b4f12 100644 --- a/src/modules/partition/tests/AutoMountTests.cpp +++ b/src/modules/partition/tests/AutoMountTests.cpp @@ -9,8 +9,8 @@ #include "jobs/AutoMountManagementJob.h" -#include "utils/Logger.h" #include "JobQueue.h" +#include "utils/Logger.h" #include #include @@ -52,7 +52,8 @@ AutoMountJobTests::testRunThrice() CalamaresUtils::Partition::automountRestore( original ); } -void AutoMountJobTests::testRunQueue() +void +AutoMountJobTests::testRunQueue() { Calamares::JobQueue q; Calamares::job_ptr jp( new AutoMountManagementJob( false ) ); @@ -68,8 +69,8 @@ void AutoMountJobTests::testRunQueue() QVERIFY( !q.isRunning() ); QEventLoop loop; - QTimer::singleShot( std::chrono::milliseconds( 100 ), [&q](){ q.start(); } ); - QTimer::singleShot( std::chrono::milliseconds( 5000 ), [&loop](){ loop.quit(); } ); + QTimer::singleShot( std::chrono::milliseconds( 100 ), [&q]() { q.start(); } ); + QTimer::singleShot( std::chrono::milliseconds( 5000 ), [&loop]() { loop.quit(); } ); connect( &q, &Calamares::JobQueue::finished, &loop, &QEventLoop::quit ); loop.exec();