[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
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 );

View File

@ -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 );

View File

@ -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 )

View File

@ -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 );

View File

@ -11,22 +11,21 @@
#include "utils/Logger.h"
#include <kpmcore/core/partition.h>
#include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackenddevice.h>
#include <kpmcore/backend/corebackendmanager.h>
#include <kpmcore/backend/corebackendpartition.h>
#include <kpmcore/backend/corebackendpartitiontable.h>
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/util/report.h>
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 <strong>%1</strong> to partition "
"<strong>%2</strong>." )
.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();

View File

@ -37,4 +37,4 @@ private:
QString m_label;
};
#endif // CHANGEFILESYSTEMLABELJOB_H
#endif // CHANGEFILESYSTEMLABELJOB_H

View File

@ -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 <strong>%1MiB</strong> partition on <strong>%3</strong> (%2) with entries <em>%4</em>." )
.arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) )
.arg( m_device->name() )
.arg( m_device->deviceNode() )
.arg( entries );
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( m_device->name() )
.arg( m_device->deviceNode() )
.arg( entries );
}
else
{
return tr( "Create new <strong>%1MiB</strong> partition on <strong>%3</strong> (%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." )

View File

@ -9,8 +9,8 @@
#include "jobs/AutoMountManagementJob.h"
#include "utils/Logger.h"
#include "JobQueue.h"
#include "utils/Logger.h"
#include <QObject>
#include <QtTest/QtTest>
@ -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();