From cbcd821943407d786b34452fe4f5e8dbc99af088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Tue, 15 Jul 2014 11:11:17 +0200 Subject: [PATCH] Coding style fixes --- .../partition/CreatePartitionDialog.cpp | 4 --- src/modules/partition/CreatePartitionJob.cpp | 32 +++++++++---------- .../partition/CreatePartitionTableJob.cpp | 20 ++++++------ src/modules/partition/DeletePartitionJob.cpp | 30 ++++++++--------- src/modules/partition/DeviceModel.cpp | 8 ----- src/modules/partition/PartitionCoreModule.cpp | 14 -------- src/modules/partition/PartitionModel.cpp | 12 ------- src/modules/partition/PartitionPage.cpp | 22 ++++++------- 8 files changed, 48 insertions(+), 94 deletions(-) diff --git a/src/modules/partition/CreatePartitionDialog.cpp b/src/modules/partition/CreatePartitionDialog.cpp index 8c9cfb0ce..463554847 100644 --- a/src/modules/partition/CreatePartitionDialog.cpp +++ b/src/modules/partition/CreatePartitionDialog.cpp @@ -55,9 +55,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePar } if ( fixedPartitionType.isEmpty() ) - { m_ui->fixedPartitionLabel->hide(); - } else { m_ui->fixedPartitionLabel->setText( fixedPartitionType ); @@ -70,9 +68,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePar for ( auto fs : FileSystemFactory::map() ) { if ( fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Extended ) - { fsNames << fs->name(); - } } m_ui->fsComboBox->addItems( fsNames ); diff --git a/src/modules/partition/CreatePartitionJob.cpp b/src/modules/partition/CreatePartitionJob.cpp index ce8cb590b..44e96d9f1 100644 --- a/src/modules/partition/CreatePartitionJob.cpp +++ b/src/modules/partition/CreatePartitionJob.cpp @@ -58,50 +58,48 @@ CreatePartitionJob::exec() if ( !backendDevice.data() ) { return Calamares::JobResult::error( - message, - tr( "Could not open device %1." ).arg( m_device->deviceNode() ) - ); + message, + tr( "Could not open device %1." ).arg( m_device->deviceNode() ) + ); } QScopedPointer backendPartitionTable( backendDevice->openPartitionTable() ); if ( !backendPartitionTable.data() ) { return Calamares::JobResult::error( - message, - tr( "Could not open partition table." ) - ); + message, + tr( "Could not open partition table." ) + ); } QString partitionPath = backendPartitionTable->createPartition( report, *m_partition ); if ( partitionPath.isEmpty() ) { return Calamares::JobResult::error( - message, - report.toText() - ); + message, + report.toText() + ); } backendPartitionTable->commit(); FileSystem& fs = m_partition->fileSystem(); if ( fs.type() == FileSystem::Unformatted ) - { return Calamares::JobResult::ok(); - } if ( !fs.create( report, partitionPath ) ) { return Calamares::JobResult::error( - tr( "The installer failed to create file system on partition %1." ).arg( partitionPath ), - report.toText() - ); + tr( "The installer failed to create file system on partition %1." ).arg( partitionPath ), + report.toText() + ); } if ( !backendPartitionTable->setPartitionSystemType( report, *m_partition ) ) { return Calamares::JobResult::error( - tr( "The installer failed to update partition table on %1." ).arg( m_device->name() ), - report.toText() - ); + tr( "The installer failed to update partition table on %1." ).arg( m_device->name() ), + report.toText() + ); } backendPartitionTable->commit(); diff --git a/src/modules/partition/CreatePartitionTableJob.cpp b/src/modules/partition/CreatePartitionTableJob.cpp index b3aea3b6c..f214d2ffc 100644 --- a/src/modules/partition/CreatePartitionTableJob.cpp +++ b/src/modules/partition/CreatePartitionTableJob.cpp @@ -57,9 +57,9 @@ CreatePartitionTableJob::exec() if ( !backendDevice.data() ) { return Calamares::JobResult::error( - message, - tr( "Could not open device %1." ).arg( m_device->deviceNode() ) - ); + message, + tr( "Could not open device %1." ).arg( m_device->deviceNode() ) + ); } QScopedPointer< PartitionTable > table( createTable() ); @@ -67,9 +67,9 @@ CreatePartitionTableJob::exec() if ( !ok ) { return Calamares::JobResult::error( - message, - report.toText() - ); + message, + report.toText() + ); } return Calamares::JobResult::ok(); @@ -89,8 +89,8 @@ PartitionTable* CreatePartitionTableJob::createTable() { PartitionTable::TableType type = PartitionTable::msdos; - return new PartitionTable(type, - PartitionTable::defaultFirstUsable( *m_device, type ), - PartitionTable::defaultLastUsable( *m_device, type ) - ); + return new PartitionTable( type, + PartitionTable::defaultFirstUsable( *m_device, type ), + PartitionTable::defaultLastUsable( *m_device, type ) + ); } diff --git a/src/modules/partition/DeletePartitionJob.cpp b/src/modules/partition/DeletePartitionJob.cpp index a3b96e163..1bb1e665e 100644 --- a/src/modules/partition/DeletePartitionJob.cpp +++ b/src/modules/partition/DeletePartitionJob.cpp @@ -50,11 +50,11 @@ DeletePartitionJob::exec() if ( m_device->deviceNode() != m_partition->devicePath() ) { return Calamares::JobResult::error( - message, - tr( "Partition (%1) and device (%2) do not match." ) - .arg( m_partition->devicePath() ) - .arg( m_device->deviceNode() ) - ); + message, + tr( "Partition (%1) and device (%2) do not match." ) + .arg( m_partition->devicePath() ) + .arg( m_device->deviceNode() ) + ); } CoreBackend* backend = CoreBackendManager::self()->backend(); @@ -62,27 +62,27 @@ DeletePartitionJob::exec() if ( !backendDevice.data() ) { return Calamares::JobResult::error( - message, - tr( "Could not open device %1." ).arg( m_device->deviceNode() ) - ); + message, + tr( "Could not open device %1." ).arg( m_device->deviceNode() ) + ); } QScopedPointer backendPartitionTable( backendDevice->openPartitionTable() ); if ( !backendPartitionTable.data() ) { return Calamares::JobResult::error( - message, - tr( "Could not open partition table." ) - ); + message, + tr( "Could not open partition table." ) + ); } bool ok = backendPartitionTable->deletePartition( report, *m_partition ); if ( !ok ) { return Calamares::JobResult::error( - message, - report.toText() - ); + message, + report.toText() + ); } backendPartitionTable->commit(); @@ -104,7 +104,5 @@ DeletePartitionJob::updatePreview() // become sda5, sda6, sda7 Partition* parentPartition = dynamic_cast< Partition* >( m_partition->parent() ); if ( parentPartition && parentPartition->roles().has( PartitionRole::Extended ) ) - { parentPartition->adjustLogicalNumbers( m_partition->number(), -1 ); - } } diff --git a/src/modules/partition/DeviceModel.cpp b/src/modules/partition/DeviceModel.cpp index a401f39a7..308fa96aa 100644 --- a/src/modules/partition/DeviceModel.cpp +++ b/src/modules/partition/DeviceModel.cpp @@ -49,9 +49,7 @@ DeviceModel::data( const QModelIndex& index, int role ) const { int row = index.row(); if ( row < 0 || row >= m_devices.count() ) - { return QVariant(); - } Device* device = m_devices.at( row ); @@ -59,13 +57,9 @@ DeviceModel::data( const QModelIndex& index, int role ) const { case Qt::DisplayRole: if ( device->name().isEmpty() ) - { return device->deviceNode(); - } else - { return device->name() + " " + device->deviceNode(); - } default: return QVariant(); } @@ -76,8 +70,6 @@ DeviceModel::deviceForIndex( const QModelIndex& index ) const { int row = index.row(); if ( row < 0 || row >= m_devices.count() ) - { return nullptr; - } return m_devices.at( row ); } diff --git a/src/modules/partition/PartitionCoreModule.cpp b/src/modules/partition/PartitionCoreModule.cpp index c1bb28c20..a4ac3620a 100644 --- a/src/modules/partition/PartitionCoreModule.cpp +++ b/src/modules/partition/PartitionCoreModule.cpp @@ -56,9 +56,7 @@ PartitionCoreModule::DeviceInfo::addInfoForPartition( PartitionInfo* partitionIn { Q_ASSERT( partitionInfo ); if ( infoForPartition( partitionInfo->partition ) ) - { return false; - } m_partitionInfoHash.insert( partitionInfo->partition, partitionInfo ); return true; } @@ -75,9 +73,7 @@ PartitionCoreModule::DeviceInfo::hasRootMountPoint() const for ( auto info : m_partitionInfoHash ) { if ( info->mountPoint == "/" ) - { return true; - } } return false; } @@ -97,9 +93,7 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent ) { // FIXME: Should be done at startup if ( !CalaPM::init() ) - { qFatal( "Failed to init CalaPM" ); - } CoreBackend* backend = CoreBackendManager::self()->backend(); auto devices = backend->scanDevices(); @@ -221,9 +215,7 @@ PartitionCoreModule::jobs() const { QList< Calamares::job_ptr > lst; for ( auto info : m_deviceInfos ) - { lst << info->jobs; - } return lst; } @@ -235,9 +227,7 @@ PartitionCoreModule::dumpQueue() const { cDebug() << "Device:" << info->device->name(); for ( auto job : info->jobs ) - { cDebug() << job->prettyName(); - } } } @@ -264,9 +254,7 @@ void PartitionCoreModule::updateHasRootMountPoint() } if ( oldValue != m_hasRootMountPoint ) - { hasRootMountPointChanged( m_hasRootMountPoint ); - } } PartitionCoreModule::DeviceInfo* @@ -275,9 +263,7 @@ PartitionCoreModule::infoForDevice( Device* device ) const for ( auto deviceInfo : m_deviceInfos ) { if ( deviceInfo->device.data() == device ) - { return deviceInfo; - } } return nullptr; } diff --git a/src/modules/partition/PartitionModel.cpp b/src/modules/partition/PartitionModel.cpp index 4b15b9afa..8730102f4 100644 --- a/src/modules/partition/PartitionModel.cpp +++ b/src/modules/partition/PartitionModel.cpp @@ -52,9 +52,7 @@ PartitionModel::reload() beginResetModel(); m_partitionList.clear(); if ( m_device ) - { fillPartitionList( m_device->partitionTable() ); - } endResetModel(); } @@ -75,9 +73,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const { int row = index.row(); if ( row < 0 || row >= m_partitionList.count() ) - { return QVariant(); - } Partition* partition = m_partitionList.at( row ); @@ -93,9 +89,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const QString prefix = partition->roles().has( PartitionRole::Logical ) ? QStringLiteral( " " ) : QStringLiteral(); if ( PMUtils::isPartitionFreeSpace( partition ) ) - { return prefix + tr( "Free Space" ); - } else { return prefix + ( partition->partitionPath().isEmpty() @@ -104,9 +98,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const } } if ( col == FileSystemColumn ) - { return partition->fileSystem().name(); - } if ( col == MountPointColumn ) { PartitionInfo* info = m_infoProvider->infoForPartition( partition ); @@ -129,9 +121,7 @@ void PartitionModel::fillPartitionList( PartitionNode* parent ) { if ( !parent ) - { return; - } for ( auto partition : parent->children() ) { m_partitionList << partition; @@ -144,8 +134,6 @@ PartitionModel::partitionForIndex( const QModelIndex& index ) const { int row = index.row(); if ( row < 0 || row >= m_partitionList.count() ) - { return nullptr; - } return m_partitionList.at( row ); } diff --git a/src/modules/partition/PartitionPage.cpp b/src/modules/partition/PartitionPage.cpp index ace979f8b..b759c930c 100644 --- a/src/modules/partition/PartitionPage.cpp +++ b/src/modules/partition/PartitionPage.cpp @@ -109,18 +109,16 @@ PartitionPage::onNewPartitionTableClicked() Device* device = m_core->deviceModel()->deviceForIndex( index ); auto answer = QMessageBox::warning( this, - tr( "New Partition Table" ), - tr( "Are you sure you want to create a new partition table on %1?\n" - "Creating a new partition table will delete all existing data on the disk.") - .arg( device->name() ), - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Cancel - ); - - if (answer != QMessageBox::Ok ) - { + tr( "New Partition Table" ), + tr( "Are you sure you want to create a new partition table on %1?\n" + "Creating a new partition table will delete all existing data on the disk." ) + .arg( device->name() ), + QMessageBox::Ok | QMessageBox::Cancel, + QMessageBox::Cancel + ); + + if ( answer != QMessageBox::Ok ) return; - } m_core->createPartitionTable( device ); } @@ -136,9 +134,7 @@ PartitionPage::onCreateClicked() QPointer dlg = new CreatePartitionDialog( model->device(), partition, this ); if ( dlg->exec() == QDialog::Accepted ) - { m_core->createPartition( model->device(), dlg->createPartitionInfo() ); - } delete dlg; }