[partition] Apply coding style

This applies the new(er) style to the whole module,
rather than just the files that recently changed.
This commit is contained in:
Adriaan de Groot 2022-02-01 16:03:49 +01:00
parent c4eee7bb11
commit cf913b87ff
21 changed files with 258 additions and 179 deletions

View File

@ -675,7 +675,11 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
// because it could take a while. Then when it's done, we can set up the widgets
// and remove the spinner.
m_future = new QFutureWatcher< void >();
connect( m_future, &QFutureWatcher< void >::finished, this, [this] {
connect( m_future,
&QFutureWatcher< void >::finished,
this,
[ this ]
{
continueLoading();
this->m_future->deleteLater();
this->m_future = nullptr;

View File

@ -28,9 +28,9 @@
static void
sortDevices( DeviceModel::DeviceList& l )
{
std::sort( l.begin(), l.end(), []( const Device* dev1, const Device* dev2 ) {
return dev1->deviceNode() < dev2->deviceNode();
} );
std::sort( l.begin(),
l.end(),
[]( const Device* dev1, const Device* dev2 ) { return dev1->deviceNode() < dev2->deviceNode(); } );
}
DeviceModel::DeviceModel( QObject* parent )

View File

@ -262,9 +262,7 @@ PartitionCoreModule::doInit()
// Gives ownership of the Device* to the DeviceInfo object
auto deviceInfo = new DeviceInfo( device );
m_deviceInfos << deviceInfo;
cDebug() << Logger::SubEntry
<< device->deviceNode()
<< device->capacity()
cDebug() << Logger::SubEntry << device->deviceNode() << device->capacity()
<< Logger::RedactedName( "DevName", device->name() )
<< Logger::RedactedName( "DevNamePretty", device->prettyName() );
}
@ -685,9 +683,8 @@ PartitionCoreModule::lvmPVs() const
bool
PartitionCoreModule::hasVGwithThisName( const QString& name ) const
{
auto condition = [name]( DeviceInfo* d ) {
return dynamic_cast< LvmDevice* >( d->device.data() ) && d->device.data()->name() == name;
};
auto condition = [ name ]( DeviceInfo* d )
{ return dynamic_cast< LvmDevice* >( d->device.data() ) && d->device.data()->name() == name; };
return std::find_if( m_deviceInfos.begin(), m_deviceInfos.end(), condition ) != m_deviceInfos.end();
}
@ -695,7 +692,8 @@ PartitionCoreModule::hasVGwithThisName( const QString& name ) const
bool
PartitionCoreModule::isInVG( const Partition* partition ) const
{
auto condition = [partition]( DeviceInfo* d ) {
auto condition = [ partition ]( DeviceInfo* d )
{
LvmDevice* vg = dynamic_cast< LvmDevice* >( d->device.data() );
return vg && vg->physicalVolumes().contains( partition );
};
@ -964,9 +962,9 @@ PartitionCoreModule::layoutApply( Device* dev,
const QString boot = QStringLiteral( "/boot" );
const QString root = QStringLiteral( "/" );
const auto is_boot
= [&]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == boot || p->mountPoint() == boot; };
= [ & ]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == boot || p->mountPoint() == boot; };
const auto is_root
= [&]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == root || p->mountPoint() == root; };
= [ & ]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == root || p->mountPoint() == root; };
const bool separate_boot_partition
= std::find_if( partList.constBegin(), partList.constEnd(), is_boot ) != partList.constEnd();
@ -1089,7 +1087,11 @@ void
PartitionCoreModule::asyncRevertDevice( Device* dev, std::function< void() > callback )
{
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
connect( watcher, &QFutureWatcher< void >::finished, this, [watcher, callback] {
connect( watcher,
&QFutureWatcher< void >::finished,
this,
[ watcher, callback ]
{
callback();
watcher->deleteLater();
} );

View File

@ -283,7 +283,7 @@ PartitionLayout::createPartitions( Device* dev,
}
}
auto correctFS = [d = m_defaultFsType]( FileSystem::Type t ) { return t == FileSystem::Type::Unknown ? d : t; };
auto correctFS = [ d = m_defaultFsType ]( FileSystem::Type t ) { return t == FileSystem::Type::Unknown ? d : t; };
// Create the partitions.
currentSector = firstSector;

View File

@ -19,7 +19,8 @@
* to bother with one-byte accuracy (and anyway, a double has at least 50 bits
* at which point we're printing giga (or gibi) bytes).
*/
static inline QString formatByteSize( qint64 sizeValue )
static inline QString
formatByteSize( qint64 sizeValue )
{
return Capacity::formatByteSize( static_cast< double >( sizeValue ) );
}

View File

@ -176,7 +176,11 @@ ChoicePage::init( PartitionCoreModule* core )
// We need to do this because a PCM revert invalidates the deviceModel.
connect( core, &PartitionCoreModule::reverted, this, [=] {
connect( core,
&PartitionCoreModule::reverted,
this,
[ = ]
{
setModelToComboBox( m_drivesCombo, core->deviceModel() );
m_drivesCombo->setCurrentIndex( m_lastSelectedDeviceIndex );
} );
@ -303,7 +307,11 @@ ChoicePage::setupChoices()
#else
auto buttonSignal = &QButtonGroup::idToggled;
#endif
connect( m_grp, buttonSignal, this, [this]( int id, bool checked ) {
connect( m_grp,
buttonSignal,
this,
[ this ]( int id, bool checked )
{
if ( checked ) // An action was picked.
{
m_config->setInstallChoice( id );
@ -401,11 +409,13 @@ ChoicePage::applyDeviceChoice()
if ( m_core->isDirty() )
{
ScanningDialog::run(
QtConcurrent::run( [=] {
QtConcurrent::run(
[ = ]
{
QMutexLocker locker( &m_coreMutex );
m_core->revertAllDevices();
} ),
[this] { continueApplyDeviceChoice(); },
[ this ] { continueApplyDeviceChoice(); },
this );
}
else
@ -493,11 +503,14 @@ ChoicePage::applyActionChoice( InstallChoice choice )
if ( m_core->isDirty() )
{
ScanningDialog::run(
QtConcurrent::run( [=] {
QtConcurrent::run(
[ = ]
{
QMutexLocker locker( &m_coreMutex );
m_core->revertDevice( selectedDevice() );
} ),
[=] {
[ = ]
{
PartitionActions::doAutopartition( m_core, selectedDevice(), options );
Q_EMIT deviceChosen();
},
@ -514,7 +527,9 @@ ChoicePage::applyActionChoice( InstallChoice choice )
if ( m_core->isDirty() )
{
ScanningDialog::run(
QtConcurrent::run( [=] {
QtConcurrent::run(
[ = ]
{
QMutexLocker locker( &m_coreMutex );
m_core->revertDevice( selectedDevice() );
} ),
@ -532,11 +547,14 @@ ChoicePage::applyActionChoice( InstallChoice choice )
if ( m_core->isDirty() )
{
ScanningDialog::run(
QtConcurrent::run( [=] {
QtConcurrent::run(
[ = ]
{
QMutexLocker locker( &m_coreMutex );
m_core->revertDevice( selectedDevice() );
} ),
[this] {
[ this ]
{
// We need to reupdate after reverting because the splitter widget is
// not a true view.
updateActionChoicePreview( m_config->installChoice() );
@ -772,7 +790,8 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
ScanningDialog::run(
QtConcurrent::run(
[this, current, homePartitionPath]( bool doReuseHomePartition ) {
[ this, current, homePartitionPath ]( bool doReuseHomePartition )
{
QMutexLocker locker( &m_coreMutex );
if ( m_core->isDirty() )
@ -853,7 +872,8 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
}
},
m_reuseHomeCheckBox->isChecked() ),
[this, homePartitionPath] {
[ this, homePartitionPath ]
{
m_reuseHomeCheckBox->setVisible( !homePartitionPath->isEmpty() );
if ( !homePartitionPath->isEmpty() )
m_reuseHomeCheckBox->setText( tr( "Reuse %1 as home partition for %2." )
@ -1006,7 +1026,8 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
connect( m_afterPartitionSplitterWidget,
&PartitionSplitterWidget::partitionResized,
this,
[this, sizeLabel]( const QString& path, qint64 size, qint64 sizeNext ) {
[ this, sizeLabel ]( const QString& path, qint64 size, qint64 sizeNext )
{
Q_UNUSED( path )
sizeLabel->setText(
tr( "%1 will be shrunk to %2MiB and a new "
@ -1020,7 +1041,8 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
m_previewAfterFrame->show();
m_previewAfterLabel->show();
SelectionFilter filter = []( const QModelIndex& index ) {
SelectionFilter filter = []( const QModelIndex& index )
{
return PartUtils::canBeResized(
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ),
Logger::Once() );
@ -1069,17 +1091,22 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
eraseBootloaderLabel->setText( tr( "Boot loader location:" ) );
m_bootloaderComboBox = createBootloaderComboBox( eraseWidget );
connect( m_core->bootLoaderModel(), &QAbstractItemModel::modelReset, [this]() {
connect( m_core->bootLoaderModel(),
&QAbstractItemModel::modelReset,
[ this ]()
{
if ( !m_bootloaderComboBox.isNull() )
{
Calamares::restoreSelectedBootLoader( *m_bootloaderComboBox, m_core->bootLoaderInstallPath() );
Calamares::restoreSelectedBootLoader( *m_bootloaderComboBox,
m_core->bootLoaderInstallPath() );
}
} );
connect(
m_core,
&PartitionCoreModule::deviceReverted,
this,
[this]( Device* dev ) {
[ this ]( Device* dev )
{
Q_UNUSED( dev )
if ( !m_bootloaderComboBox.isNull() )
{
@ -1110,7 +1137,8 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
}
else
{
SelectionFilter filter = []( const QModelIndex& index ) {
SelectionFilter filter = []( const QModelIndex& index )
{
return PartUtils::canBeReplaced(
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ),
Logger::Once() );
@ -1217,7 +1245,11 @@ ChoicePage::createBootloaderComboBox( QWidget* parent )
comboForBootloader->setModel( m_core->bootLoaderModel() );
// When the chosen bootloader device changes, we update the choice in the PCM
connect( comboForBootloader, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, [this]( int newIndex ) {
connect( comboForBootloader,
QOverload< int >::of( &QComboBox::currentIndexChanged ),
this,
[ this ]( int newIndex )
{
QComboBox* bootloaderCombo = qobject_cast< QComboBox* >( sender() );
if ( bootloaderCombo )
{

View File

@ -325,7 +325,10 @@ CreatePartitionDialog::updateMountPointUi()
void
CreatePartitionDialog::checkMountPointSelection()
{
validateMountPoint( selectedMountPoint( m_ui->mountPointComboBox ), m_usedMountPoints, m_ui->mountPointExplanation, m_ui->buttonBox->button( QDialogButtonBox::Ok ));
validateMountPoint( selectedMountPoint( m_ui->mountPointComboBox ),
m_usedMountPoints,
m_ui->mountPointExplanation,
m_ui->buttonBox->button( QDialogButtonBox::Ok ) );
}
void

View File

@ -69,7 +69,10 @@ 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 );
@ -84,7 +87,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;
@ -295,5 +298,8 @@ EditExistingPartitionDialog::updateMountPointPicker()
void
EditExistingPartitionDialog::checkMountPointSelection()
{
validateMountPoint( selectedMountPoint( m_ui->mountPointComboBox ), m_usedMountPoints, m_ui->mountPointExplanation, m_ui->buttonBox->button( QDialogButtonBox::Ok ));
validateMountPoint( selectedMountPoint( m_ui->mountPointComboBox ),
m_usedMountPoints,
m_ui->mountPointExplanation,
m_ui->buttonBox->button( QDialogButtonBox::Ok ) );
}

View File

@ -28,7 +28,8 @@
* Since we don't have an oracle that can answer that question,
* just pretend every system can do it.
*/
static inline bool systemSupportsEncryptionAcceptably()
static inline bool
systemSupportsEncryptionAcceptably()
{
return true;
}
@ -53,7 +54,7 @@ EncryptWidget::EncryptWidget( QWidget* parent )
else
{
// This is really ugly, but the character is unicode "unlocked"
m_ui->m_encryptionUnsupportedLabel->setText( QStringLiteral("🔓") );
m_ui->m_encryptionUnsupportedLabel->setText( QStringLiteral( "🔓" ) );
m_ui->m_encryptionUnsupportedLabel->show();
}

View File

@ -54,9 +54,10 @@ PartitionBarsView::PartitionBarsView( QWidget* parent )
setSelectionMode( QAbstractItemView::SingleSelection );
// Debug
connect( this, &PartitionBarsView::clicked, this, [=]( const QModelIndex& index ) {
cDebug() << "Clicked row" << index.row();
} );
connect( this,
&PartitionBarsView::clicked,
this,
[ = ]( const QModelIndex& index ) { cDebug() << "Clicked row" << index.row(); } );
setMouseTracking( true );
}
@ -399,7 +400,7 @@ void
PartitionBarsView::setSelectionModel( QItemSelectionModel* selectionModel )
{
QAbstractItemView::setSelectionModel( selectionModel );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [=] { viewport()->repaint(); } );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [ = ] { viewport()->repaint(); } );
}
@ -410,7 +411,8 @@ PartitionBarsView::setSelectionFilter( std::function< bool( const QModelIndex& )
}
QModelIndex PartitionBarsView::moveCursor( CursorAction, Qt::KeyboardModifiers )
QModelIndex
PartitionBarsView::moveCursor( CursorAction, Qt::KeyboardModifiers )
{
return QModelIndex();
}

View File

@ -80,7 +80,8 @@ setSelectedMountPoint( QComboBox& combo, const QString& selected )
}
}
bool validateMountPoint( const QString& mountPoint, const QStringList& inUse, QLabel* label, QPushButton* button )
bool
validateMountPoint( const QString& mountPoint, const QStringList& inUse, QLabel* label, QPushButton* button )
{
QString msg;
bool ok = true;

View File

@ -519,7 +519,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

@ -451,7 +451,9 @@ void
PartitionPage::onRevertClicked()
{
ScanningDialog::run(
QtConcurrent::run( [this] {
QtConcurrent::run(
[ this ]
{
QMutexLocker locker( &m_revertMutex );
int oldIndex = m_ui->deviceComboBox->currentIndex();
@ -459,7 +461,8 @@ PartitionPage::onRevertClicked()
m_ui->deviceComboBox->setCurrentIndex( ( oldIndex < 0 ) ? 0 : oldIndex );
updateFromCurrentDevice();
} ),
[this] {
[ this ]
{
m_lastSelectedBootLoaderIndex = -1;
if ( m_ui->bootLoaderComboBox->currentIndex() < 0 )
{
@ -606,7 +609,8 @@ 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 );
@ -625,7 +629,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,9 @@ 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 +186,9 @@ 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 +362,9 @@ 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,9 +46,10 @@ ReplaceWidget::ReplaceWidget( PartitionCoreModule* core, QComboBox* devicesCombo
m_ui->bootStatusLabel->clear();
updateFromCurrentDevice( devicesComboBox );
connect( devicesComboBox, &QComboBox::currentTextChanged, this, [=]( const QString& /* text */ ) {
updateFromCurrentDevice( devicesComboBox );
} );
connect( devicesComboBox,
&QComboBox::currentTextChanged,
this,
[ = ]( const QString& /* text */ ) { updateFromCurrentDevice( devicesComboBox ); } );
CALAMARES_RETRANSLATE( onPartitionSelected(); );
}

View File

@ -47,7 +47,11 @@ 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

@ -45,17 +45,25 @@ 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()

View File

@ -26,7 +26,9 @@ Calamares::JobResult
AutoMountManagementJob::exec()
{
cVerbose() << "this" << Logger::Pointer( this ) << "value" << Logger::Pointer( m_stored )
<< ( m_stored ? "restore" : m_disable ? "disable" : "enable" );
<< ( m_stored ? "restore"
: m_disable ? "disable"
: "enable" );
if ( m_stored )
{
CalamaresUtils::Partition::automountRestore( m_stored );

View File

@ -157,9 +157,11 @@ getLVMVolumes()
QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
// Get the second column (`value(1)`) sinec that is the device name,
// remove quoting.
std::transform( lvscanLines.begin(), lvscanLines.end(), lvscanLines.begin(), []( const QString& lvscanLine ) {
return lvscanLine.simplified().split( ' ' ).value( 1 ).replace( '\'', "" );
} );
std::transform( lvscanLines.begin(),
lvscanLines.end(),
lvscanLines.begin(),
[]( const QString& lvscanLine )
{ return lvscanLine.simplified().split( ' ' ).value( 1 ).replace( '\'', "" ); } );
return lvscanLines;
}
else

View File

@ -69,8 +69,8 @@ AutoMountJobTests::testRunQueue()
QVERIFY( !q.isRunning() );
QEventLoop loop;
QTimer::singleShot( std::chrono::milliseconds( 100 ), [&q]() { q.start(); } );
QTimer::singleShot( std::chrono::milliseconds( 5000 ), [&loop]() { loop.quit(); } );
QTimer::singleShot( std::chrono::milliseconds( 100 ), [ &q ]() { q.start(); } );
QTimer::singleShot( std::chrono::milliseconds( 5000 ), [ &loop ]() { loop.quit(); } );
connect( &q, &Calamares::JobQueue::finished, &loop, &QEventLoop::quit );
loop.exec();

View File

@ -32,9 +32,9 @@ getPartitionsForDevice_other( const QString& deviceName )
{
QProcess process;
process.setProgram( "sh" );
process.setArguments(
{ "-c",
QString( "echo $(awk '{print \"/dev/\"$4}' /proc/partitions | sed -e '/name/d' -e '/^$/d' -e '/[1-9]/!d' | grep %1)" )
process.setArguments( { "-c",
QString( "echo $(awk '{print \"/dev/\"$4}' /proc/partitions | sed -e '/name/d' -e '/^$/d' "
"-e '/[1-9]/!d' | grep %1)" )
.arg( deviceName ) } );
process.start();
process.waitForFinished();