[partition] Coding style

This commit is contained in:
Adriaan de Groot 2020-09-29 14:04:12 +02:00
parent b41e4624c9
commit 010526ee2a
9 changed files with 33 additions and 33 deletions

View File

@ -165,13 +165,13 @@ PartitionLayout::execute( Device* dev,
{
QList< Partition* > partList;
// Map each partition entry to its requested size (0 when calculated later)
QMap< const PartitionLayout::PartitionEntry *, qint64 > partSizeMap;
QMap< const PartitionLayout::PartitionEntry*, qint64 > partSizeMap;
qint64 minSize, maxSize, end;
qint64 totalSize = lastSector - firstSector + 1;
qint64 availableSize = totalSize;
// Let's check if we have enough space for each partSize
for( const PartitionLayout::PartitionEntry& part : m_partLayout )
for ( const PartitionLayout::PartitionEntry& part : m_partLayout )
{
qint64 size = -1;
// Calculate partition size
@ -179,7 +179,7 @@ PartitionLayout::execute( Device* dev,
if ( part.partSize.isValid() )
{
// We need to ignore the percent-defined
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent)
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent )
{
size = part.partSize.toSectors( totalSize, dev->logicalSize() );
}
@ -201,15 +201,15 @@ PartitionLayout::execute( Device* dev,
continue;
}
partSizeMap.insert (&part, size);
partSizeMap.insert( &part, size );
availableSize -= size;
}
// Use partMinSize and see if we can do better afterward.
if (availableSize < 0)
if ( availableSize < 0 )
{
availableSize = totalSize;
for( const PartitionLayout::PartitionEntry& part : m_partLayout )
for ( const PartitionLayout::PartitionEntry& part : m_partLayout )
{
qint64 size;
@ -219,7 +219,7 @@ PartitionLayout::execute( Device* dev,
}
else if ( part.partSize.isValid() )
{
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent)
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent )
{
size = part.partSize.toSectors( totalSize, dev->logicalSize() );
}
@ -233,23 +233,23 @@ PartitionLayout::execute( Device* dev,
size = 0;
}
partSizeMap.insert (&part, size);
partSizeMap.insert( &part, size );
availableSize -= size;
}
}
// Assign size for percentage-defined partitions
for( const PartitionLayout::PartitionEntry& part : m_partLayout )
for ( const PartitionLayout::PartitionEntry& part : m_partLayout )
{
if ( part.partSize.unit() == CalamaresUtils::Partition::SizeUnit::Percent)
if ( part.partSize.unit() == CalamaresUtils::Partition::SizeUnit::Percent )
{
qint64 size = partSizeMap.value (&part);
qint64 size = partSizeMap.value( &part );
size = part.partSize.toSectors( availableSize + size, dev->logicalSize() );
partSizeMap.insert (&part, size);
partSizeMap.insert( &part, size );
if ( part.partMinSize.isValid() )
{
qint64 minSize = part.partMinSize.toSectors( totalSize, dev->logicalSize() );
if (minSize > size)
if ( minSize > size )
{
size = minSize;
}
@ -257,7 +257,7 @@ PartitionLayout::execute( Device* dev,
if ( part.partMaxSize.isValid() )
{
qint64 maxSize = part.partMaxSize.toSectors( totalSize, dev->logicalSize() );
if (maxSize < size)
if ( maxSize < size )
{
size = maxSize;
}
@ -270,9 +270,9 @@ PartitionLayout::execute( Device* dev,
// TODO: Refine partition sizes to make sure there is room for every partition
// Use a default (200-500M ?) minimum size for partition without minSize
for( const PartitionLayout::PartitionEntry& part : m_partLayout )
for ( const PartitionLayout::PartitionEntry& part : m_partLayout )
{
qint64 size = partSizeMap.value (&part);
qint64 size = partSizeMap.value( &part );
Partition* currentPartition = nullptr;
// Adjust partition size based on user-defined boundaries and available space

View File

@ -64,7 +64,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
replacePartResizerWidget();
connect( m_ui->formatRadioButton, &QAbstractButton::toggled, [this]( bool doFormat ) {
connect( m_ui->formatRadioButton, &QAbstractButton::toggled, [ this ]( bool doFormat ) {
replacePartResizerWidget();
m_ui->fileSystemLabel->setEnabled( doFormat );
@ -79,7 +79,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
} );
connect(
m_ui->fileSystemComboBox, &QComboBox::currentTextChanged, [this]( QString ) { updateMountPointPicker(); } );
m_ui->fileSystemComboBox, &QComboBox::currentTextChanged, [ this ]( QString ) { updateMountPointPicker(); } );
// File system
QStringList fsNames;

View File

@ -54,7 +54,7 @@ PartitionBarsView::PartitionBarsView( QWidget* parent )
setSelectionMode( QAbstractItemView::SingleSelection );
// Debug
connect( this, &PartitionBarsView::clicked, this, [=]( const QModelIndex& index ) {
connect( this, &PartitionBarsView::clicked, this, [ = ]( const QModelIndex& index ) {
cDebug() << "Clicked row" << index.row();
} );
setMouseTracking( true );
@ -399,7 +399,7 @@ void
PartitionBarsView::setSelectionModel( QItemSelectionModel* selectionModel )
{
QAbstractItemView::setSelectionModel( selectionModel );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [=] { viewport()->repaint(); } );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [ = ] { viewport()->repaint(); } );
}

View File

@ -520,7 +520,7 @@ void
PartitionLabelsView::setSelectionModel( QItemSelectionModel* selectionModel )
{
QAbstractItemView::setSelectionModel( selectionModel );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [=] { viewport()->repaint(); } );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [ = ] { viewport()->repaint(); } );
}

View File

@ -438,7 +438,7 @@ void
PartitionPage::onRevertClicked()
{
ScanningDialog::run(
QtConcurrent::run( [this] {
QtConcurrent::run( [ this ] {
QMutexLocker locker( &m_revertMutex );
int oldIndex = m_ui->deviceComboBox->currentIndex();
@ -446,7 +446,7 @@ PartitionPage::onRevertClicked()
m_ui->deviceComboBox->setCurrentIndex( ( oldIndex < 0 ) ? 0 : oldIndex );
updateFromCurrentDevice();
} ),
[this] {
[ this ] {
m_lastSelectedBootLoaderIndex = -1;
if ( m_ui->bootLoaderComboBox->currentIndex() < 0 )
{
@ -594,7 +594,7 @@ PartitionPage::updateFromCurrentDevice()
m_ui->partitionBarsView->selectionModel(),
&QItemSelectionModel::currentChanged,
this,
[=] {
[ = ] {
QModelIndex selectedIndex = m_ui->partitionBarsView->selectionModel()->currentIndex();
selectedIndex = selectedIndex.sibling( selectedIndex.row(), 0 );
m_ui->partitionBarsView->setCurrentIndex( selectedIndex );
@ -613,7 +613,7 @@ PartitionPage::updateFromCurrentDevice()
// model changes
connect( m_ui->partitionTreeView->selectionModel(),
&QItemSelectionModel::currentChanged,
[this]( const QModelIndex&, const QModelIndex& ) { updateButtons(); } );
[ this ]( const QModelIndex&, const QModelIndex& ) { updateButtons(); } );
connect( model, &QAbstractItemModel::modelReset, this, &PartitionPage::onPartitionModelReset );
}

View File

@ -159,7 +159,7 @@ PartitionSplitterWidget::setSplitPartition( const QString& path, qint64 minSize,
m_itemToResizePath.clear();
}
PartitionSplitterItem itemToResize = _findItem( m_items, [path]( PartitionSplitterItem& item ) -> bool {
PartitionSplitterItem itemToResize = _findItem( m_items, [ path ]( PartitionSplitterItem& item ) -> bool {
if ( path == item.itemPath )
{
item.status = PartitionSplitterItem::Resizing;
@ -184,7 +184,7 @@ PartitionSplitterWidget::setSplitPartition( const QString& path, qint64 minSize,
qint64 newSize = m_itemToResize.size - preferredSize;
m_itemToResize.size = preferredSize;
int opCount = _eachItem( m_items, [preferredSize]( PartitionSplitterItem& item ) -> bool {
int opCount = _eachItem( m_items, [ preferredSize ]( PartitionSplitterItem& item ) -> bool {
if ( item.status == PartitionSplitterItem::Resizing )
{
item.size = preferredSize;
@ -358,7 +358,7 @@ PartitionSplitterWidget::mouseMoveEvent( QMouseEvent* event )
m_itemToResize.size = qRound64( span * percent );
m_itemToResizeNext.size -= m_itemToResize.size - oldsize;
_eachItem( m_items, [this]( PartitionSplitterItem& item ) -> bool {
_eachItem( m_items, [ this ]( PartitionSplitterItem& item ) -> bool {
if ( item.status == PartitionSplitterItem::Resizing )
{
item.size = m_itemToResize.size;

View File

@ -46,7 +46,7 @@ ReplaceWidget::ReplaceWidget( PartitionCoreModule* core, QComboBox* devicesCombo
m_ui->bootStatusLabel->clear();
updateFromCurrentDevice( devicesComboBox );
connect( devicesComboBox, &QComboBox::currentTextChanged, this, [=]( const QString& /* text */ ) {
connect( devicesComboBox, &QComboBox::currentTextChanged, this, [ = ]( const QString& /* text */ ) {
updateFromCurrentDevice( devicesComboBox );
} );

View File

@ -47,7 +47,7 @@ ScanningDialog::run( const QFuture< void >& future,
theDialog->show();
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
connect( watcher, &QFutureWatcher< void >::finished, theDialog, [watcher, theDialog, callback] {
connect( watcher, &QFutureWatcher< void >::finished, theDialog, [ watcher, theDialog, callback ] {
watcher->deleteLater();
theDialog->hide();
theDialog->deleteLater();

View File

@ -46,17 +46,17 @@ VolumeGroupBaseDialog::VolumeGroupBaseDialog( QString& vgName, QVector< const Pa
updateOkButton();
updateTotalSize();
connect( ui->pvList, &QListWidget::itemChanged, this, [&]( QListWidgetItem* ) {
connect( ui->pvList, &QListWidget::itemChanged, this, [ & ]( QListWidgetItem* ) {
updateTotalSize();
updateOkButton();
} );
connect( ui->peSize, qOverload< int >( &QSpinBox::valueChanged ), this, [&]( int ) {
connect( ui->peSize, qOverload< int >( &QSpinBox::valueChanged ), this, [ & ]( int ) {
updateTotalSectors();
updateOkButton();
} );
connect( ui->vgName, &QLineEdit::textChanged, this, [&]( const QString& ) { updateOkButton(); } );
connect( ui->vgName, &QLineEdit::textChanged, this, [ & ]( const QString& ) { updateOkButton(); } );
}
VolumeGroupBaseDialog::~VolumeGroupBaseDialog()