Coding style fixes

This commit is contained in:
Aurélien Gâteau 2014-07-15 11:11:17 +02:00
parent 79bf4f3b5a
commit cbcd821943
8 changed files with 47 additions and 93 deletions

View File

@ -55,9 +55,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePar
} }
if ( fixedPartitionType.isEmpty() ) if ( fixedPartitionType.isEmpty() )
{
m_ui->fixedPartitionLabel->hide(); m_ui->fixedPartitionLabel->hide();
}
else else
{ {
m_ui->fixedPartitionLabel->setText( fixedPartitionType ); m_ui->fixedPartitionLabel->setText( fixedPartitionType );
@ -70,10 +68,8 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePar
for ( auto fs : FileSystemFactory::map() ) for ( auto fs : FileSystemFactory::map() )
{ {
if ( fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Extended ) if ( fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Extended )
{
fsNames << fs->name(); fsNames << fs->name();
} }
}
m_ui->fsComboBox->addItems( fsNames ); m_ui->fsComboBox->addItems( fsNames );
// Size // Size

View File

@ -84,9 +84,7 @@ CreatePartitionJob::exec()
FileSystem& fs = m_partition->fileSystem(); FileSystem& fs = m_partition->fileSystem();
if ( fs.type() == FileSystem::Unformatted ) if ( fs.type() == FileSystem::Unformatted )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
if ( !fs.create( report, partitionPath ) ) if ( !fs.create( report, partitionPath ) )
{ {

View File

@ -89,7 +89,7 @@ PartitionTable*
CreatePartitionTableJob::createTable() CreatePartitionTableJob::createTable()
{ {
PartitionTable::TableType type = PartitionTable::msdos; PartitionTable::TableType type = PartitionTable::msdos;
return new PartitionTable(type, return new PartitionTable( type,
PartitionTable::defaultFirstUsable( *m_device, type ), PartitionTable::defaultFirstUsable( *m_device, type ),
PartitionTable::defaultLastUsable( *m_device, type ) PartitionTable::defaultLastUsable( *m_device, type )
); );

View File

@ -104,7 +104,5 @@ DeletePartitionJob::updatePreview()
// become sda5, sda6, sda7 // become sda5, sda6, sda7
Partition* parentPartition = dynamic_cast< Partition* >( m_partition->parent() ); Partition* parentPartition = dynamic_cast< Partition* >( m_partition->parent() );
if ( parentPartition && parentPartition->roles().has( PartitionRole::Extended ) ) if ( parentPartition && parentPartition->roles().has( PartitionRole::Extended ) )
{
parentPartition->adjustLogicalNumbers( m_partition->number(), -1 ); parentPartition->adjustLogicalNumbers( m_partition->number(), -1 );
}
} }

View File

@ -49,9 +49,7 @@ DeviceModel::data( const QModelIndex& index, int role ) const
{ {
int row = index.row(); int row = index.row();
if ( row < 0 || row >= m_devices.count() ) if ( row < 0 || row >= m_devices.count() )
{
return QVariant(); return QVariant();
}
Device* device = m_devices.at( row ); Device* device = m_devices.at( row );
@ -59,13 +57,9 @@ DeviceModel::data( const QModelIndex& index, int role ) const
{ {
case Qt::DisplayRole: case Qt::DisplayRole:
if ( device->name().isEmpty() ) if ( device->name().isEmpty() )
{
return device->deviceNode(); return device->deviceNode();
}
else else
{
return device->name() + " " + device->deviceNode(); return device->name() + " " + device->deviceNode();
}
default: default:
return QVariant(); return QVariant();
} }
@ -76,8 +70,6 @@ DeviceModel::deviceForIndex( const QModelIndex& index ) const
{ {
int row = index.row(); int row = index.row();
if ( row < 0 || row >= m_devices.count() ) if ( row < 0 || row >= m_devices.count() )
{
return nullptr; return nullptr;
}
return m_devices.at( row ); return m_devices.at( row );
} }

View File

@ -56,9 +56,7 @@ PartitionCoreModule::DeviceInfo::addInfoForPartition( PartitionInfo* partitionIn
{ {
Q_ASSERT( partitionInfo ); Q_ASSERT( partitionInfo );
if ( infoForPartition( partitionInfo->partition ) ) if ( infoForPartition( partitionInfo->partition ) )
{
return false; return false;
}
m_partitionInfoHash.insert( partitionInfo->partition, partitionInfo ); m_partitionInfoHash.insert( partitionInfo->partition, partitionInfo );
return true; return true;
} }
@ -75,10 +73,8 @@ PartitionCoreModule::DeviceInfo::hasRootMountPoint() const
for ( auto info : m_partitionInfoHash ) for ( auto info : m_partitionInfoHash )
{ {
if ( info->mountPoint == "/" ) if ( info->mountPoint == "/" )
{
return true; return true;
} }
}
return false; return false;
} }
@ -97,9 +93,7 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent )
{ {
// FIXME: Should be done at startup // FIXME: Should be done at startup
if ( !CalaPM::init() ) if ( !CalaPM::init() )
{
qFatal( "Failed to init CalaPM" ); qFatal( "Failed to init CalaPM" );
}
CoreBackend* backend = CoreBackendManager::self()->backend(); CoreBackend* backend = CoreBackendManager::self()->backend();
auto devices = backend->scanDevices(); auto devices = backend->scanDevices();
@ -221,9 +215,7 @@ PartitionCoreModule::jobs() const
{ {
QList< Calamares::job_ptr > lst; QList< Calamares::job_ptr > lst;
for ( auto info : m_deviceInfos ) for ( auto info : m_deviceInfos )
{
lst << info->jobs; lst << info->jobs;
}
return lst; return lst;
} }
@ -235,10 +227,8 @@ PartitionCoreModule::dumpQueue() const
{ {
cDebug() << "Device:" << info->device->name(); cDebug() << "Device:" << info->device->name();
for ( auto job : info->jobs ) for ( auto job : info->jobs )
{
cDebug() << job->prettyName(); cDebug() << job->prettyName();
} }
}
} }
void void
@ -264,9 +254,7 @@ void PartitionCoreModule::updateHasRootMountPoint()
} }
if ( oldValue != m_hasRootMountPoint ) if ( oldValue != m_hasRootMountPoint )
{
hasRootMountPointChanged( m_hasRootMountPoint ); hasRootMountPointChanged( m_hasRootMountPoint );
}
} }
PartitionCoreModule::DeviceInfo* PartitionCoreModule::DeviceInfo*
@ -275,9 +263,7 @@ PartitionCoreModule::infoForDevice( Device* device ) const
for ( auto deviceInfo : m_deviceInfos ) for ( auto deviceInfo : m_deviceInfos )
{ {
if ( deviceInfo->device.data() == device ) if ( deviceInfo->device.data() == device )
{
return deviceInfo; return deviceInfo;
} }
}
return nullptr; return nullptr;
} }

View File

@ -52,9 +52,7 @@ PartitionModel::reload()
beginResetModel(); beginResetModel();
m_partitionList.clear(); m_partitionList.clear();
if ( m_device ) if ( m_device )
{
fillPartitionList( m_device->partitionTable() ); fillPartitionList( m_device->partitionTable() );
}
endResetModel(); endResetModel();
} }
@ -75,9 +73,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const
{ {
int row = index.row(); int row = index.row();
if ( row < 0 || row >= m_partitionList.count() ) if ( row < 0 || row >= m_partitionList.count() )
{
return QVariant(); return QVariant();
}
Partition* partition = m_partitionList.at( row ); 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 ) QString prefix = partition->roles().has( PartitionRole::Logical )
? QStringLiteral( " " ) : QStringLiteral(); ? QStringLiteral( " " ) : QStringLiteral();
if ( PMUtils::isPartitionFreeSpace( partition ) ) if ( PMUtils::isPartitionFreeSpace( partition ) )
{
return prefix + tr( "Free Space" ); return prefix + tr( "Free Space" );
}
else else
{ {
return prefix + ( partition->partitionPath().isEmpty() return prefix + ( partition->partitionPath().isEmpty()
@ -104,9 +98,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const
} }
} }
if ( col == FileSystemColumn ) if ( col == FileSystemColumn )
{
return partition->fileSystem().name(); return partition->fileSystem().name();
}
if ( col == MountPointColumn ) if ( col == MountPointColumn )
{ {
PartitionInfo* info = m_infoProvider->infoForPartition( partition ); PartitionInfo* info = m_infoProvider->infoForPartition( partition );
@ -129,9 +121,7 @@ void
PartitionModel::fillPartitionList( PartitionNode* parent ) PartitionModel::fillPartitionList( PartitionNode* parent )
{ {
if ( !parent ) if ( !parent )
{
return; return;
}
for ( auto partition : parent->children() ) for ( auto partition : parent->children() )
{ {
m_partitionList << partition; m_partitionList << partition;
@ -144,8 +134,6 @@ PartitionModel::partitionForIndex( const QModelIndex& index ) const
{ {
int row = index.row(); int row = index.row();
if ( row < 0 || row >= m_partitionList.count() ) if ( row < 0 || row >= m_partitionList.count() )
{
return nullptr; return nullptr;
}
return m_partitionList.at( row ); return m_partitionList.at( row );
} }

View File

@ -111,16 +111,14 @@ PartitionPage::onNewPartitionTableClicked()
auto answer = QMessageBox::warning( this, auto answer = QMessageBox::warning( this,
tr( "New Partition Table" ), tr( "New Partition Table" ),
tr( "Are you sure you want to create a new partition table on %1?\n" 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.") "Creating a new partition table will delete all existing data on the disk." )
.arg( device->name() ), .arg( device->name() ),
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Cancel QMessageBox::Cancel
); );
if (answer != QMessageBox::Ok ) if ( answer != QMessageBox::Ok )
{
return; return;
}
m_core->createPartitionTable( device ); m_core->createPartitionTable( device );
} }
@ -136,9 +134,7 @@ PartitionPage::onCreateClicked()
QPointer<CreatePartitionDialog> dlg = new CreatePartitionDialog( model->device(), partition, this ); QPointer<CreatePartitionDialog> dlg = new CreatePartitionDialog( model->device(), partition, this );
if ( dlg->exec() == QDialog::Accepted ) if ( dlg->exec() == QDialog::Accepted )
{
m_core->createPartition( model->device(), dlg->createPartitionInfo() ); m_core->createPartition( model->device(), dlg->createPartitionInfo() );
}
delete dlg; delete dlg;
} }