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

View File

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

View File

@ -54,7 +54,7 @@ PartitionBarsView::PartitionBarsView( QWidget* parent )
setSelectionMode( QAbstractItemView::SingleSelection ); setSelectionMode( QAbstractItemView::SingleSelection );
// Debug // Debug
connect( this, &PartitionBarsView::clicked, this, [=]( const QModelIndex& index ) { connect( this, &PartitionBarsView::clicked, this, [ = ]( const QModelIndex& index ) {
cDebug() << "Clicked row" << index.row(); cDebug() << "Clicked row" << index.row();
} ); } );
setMouseTracking( true ); setMouseTracking( true );
@ -399,7 +399,7 @@ void
PartitionBarsView::setSelectionModel( QItemSelectionModel* selectionModel ) PartitionBarsView::setSelectionModel( QItemSelectionModel* selectionModel )
{ {
QAbstractItemView::setSelectionModel( 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 ) PartitionLabelsView::setSelectionModel( QItemSelectionModel* selectionModel )
{ {
QAbstractItemView::setSelectionModel( 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() PartitionPage::onRevertClicked()
{ {
ScanningDialog::run( ScanningDialog::run(
QtConcurrent::run( [this] { QtConcurrent::run( [ this ] {
QMutexLocker locker( &m_revertMutex ); QMutexLocker locker( &m_revertMutex );
int oldIndex = m_ui->deviceComboBox->currentIndex(); int oldIndex = m_ui->deviceComboBox->currentIndex();
@ -446,7 +446,7 @@ PartitionPage::onRevertClicked()
m_ui->deviceComboBox->setCurrentIndex( ( oldIndex < 0 ) ? 0 : oldIndex ); m_ui->deviceComboBox->setCurrentIndex( ( oldIndex < 0 ) ? 0 : oldIndex );
updateFromCurrentDevice(); updateFromCurrentDevice();
} ), } ),
[this] { [ this ] {
m_lastSelectedBootLoaderIndex = -1; m_lastSelectedBootLoaderIndex = -1;
if ( m_ui->bootLoaderComboBox->currentIndex() < 0 ) if ( m_ui->bootLoaderComboBox->currentIndex() < 0 )
{ {
@ -594,7 +594,7 @@ PartitionPage::updateFromCurrentDevice()
m_ui->partitionBarsView->selectionModel(), m_ui->partitionBarsView->selectionModel(),
&QItemSelectionModel::currentChanged, &QItemSelectionModel::currentChanged,
this, this,
[=] { [ = ] {
QModelIndex selectedIndex = m_ui->partitionBarsView->selectionModel()->currentIndex(); QModelIndex selectedIndex = m_ui->partitionBarsView->selectionModel()->currentIndex();
selectedIndex = selectedIndex.sibling( selectedIndex.row(), 0 ); selectedIndex = selectedIndex.sibling( selectedIndex.row(), 0 );
m_ui->partitionBarsView->setCurrentIndex( selectedIndex ); m_ui->partitionBarsView->setCurrentIndex( selectedIndex );
@ -613,7 +613,7 @@ PartitionPage::updateFromCurrentDevice()
// model changes // model changes
connect( m_ui->partitionTreeView->selectionModel(), connect( m_ui->partitionTreeView->selectionModel(),
&QItemSelectionModel::currentChanged, &QItemSelectionModel::currentChanged,
[this]( const QModelIndex&, const QModelIndex& ) { updateButtons(); } ); [ this ]( const QModelIndex&, const QModelIndex& ) { updateButtons(); } );
connect( model, &QAbstractItemModel::modelReset, this, &PartitionPage::onPartitionModelReset ); connect( model, &QAbstractItemModel::modelReset, this, &PartitionPage::onPartitionModelReset );
} }

View File

@ -159,7 +159,7 @@ PartitionSplitterWidget::setSplitPartition( const QString& path, qint64 minSize,
m_itemToResizePath.clear(); 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 ) if ( path == item.itemPath )
{ {
item.status = PartitionSplitterItem::Resizing; item.status = PartitionSplitterItem::Resizing;
@ -184,7 +184,7 @@ PartitionSplitterWidget::setSplitPartition( const QString& path, qint64 minSize,
qint64 newSize = m_itemToResize.size - preferredSize; qint64 newSize = m_itemToResize.size - preferredSize;
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 ) if ( item.status == PartitionSplitterItem::Resizing )
{ {
item.size = preferredSize; item.size = preferredSize;
@ -358,7 +358,7 @@ PartitionSplitterWidget::mouseMoveEvent( QMouseEvent* event )
m_itemToResize.size = qRound64( span * percent ); m_itemToResize.size = qRound64( span * percent );
m_itemToResizeNext.size -= m_itemToResize.size - oldsize; 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 ) if ( item.status == PartitionSplitterItem::Resizing )
{ {
item.size = m_itemToResize.size; item.size = m_itemToResize.size;

View File

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

View File

@ -47,7 +47,7 @@ ScanningDialog::run( const QFuture< void >& future,
theDialog->show(); theDialog->show();
QFutureWatcher< void >* watcher = new QFutureWatcher< void >(); 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(); watcher->deleteLater();
theDialog->hide(); theDialog->hide();
theDialog->deleteLater(); theDialog->deleteLater();

View File

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