Coding style fixes

main
Aurélien Gâteau 11 years ago
parent 79bf4f3b5a
commit cbcd821943

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

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

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

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

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

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

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

@ -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<CreatePartitionDialog> dlg = new CreatePartitionDialog( model->device(), partition, this );
if ( dlg->exec() == QDialog::Accepted )
{
m_core->createPartition( model->device(), dlg->createPartitionInfo() );
}
delete dlg;
}

Loading…
Cancel
Save