[partition] Apply coding style

This commit is contained in:
Adriaan de Groot 2021-06-22 00:21:01 +02:00
parent e2bf717ea0
commit 131352ca03
9 changed files with 45 additions and 31 deletions

View File

@ -10,8 +10,8 @@
#include "DeviceList.h" #include "DeviceList.h"
#include "utils/Logger.h"
#include "partition/PartitionIterator.h" #include "partition/PartitionIterator.h"
#include "utils/Logger.h"
#include <kpmcore/backend/corebackend.h> #include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackendmanager.h> #include <kpmcore/backend/corebackendmanager.h>
@ -133,11 +133,11 @@ getDevices( DeviceType which )
#endif #endif
// Unsafe partitioning // Unsafe partitioning
auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it) { return erase(l, it); }; auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it ) { return erase( l, it ); };
auto removeInSafeMode = []( DeviceList&, DeviceList::iterator& it) { return ++it; }; auto removeInSafeMode = []( DeviceList&, DeviceList::iterator& it ) { return ++it; };
#else #else
// Safe partitioning // Safe partitioning
auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it) { return erase(l, it); }; auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it ) { return erase( l, it ); };
auto& removeInSafeMode = removeInAllModes; auto& removeInSafeMode = removeInAllModes;
#endif #endif

View File

@ -177,7 +177,8 @@ canBeResized( Partition* candidate, const Logger::Once& o )
if ( availableStorageB > advisedStorageB ) if ( availableStorageB > advisedStorageB )
{ {
cDebug() << o << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install."; cDebug() << o << "Partition" << convenienceName( candidate )
<< "authorized for resize + autopartition install.";
return true; return true;
} }
else else
@ -412,8 +413,14 @@ runOsprober( DeviceModel* dm )
FstabEntryList fstabEntries = lookForFstabEntries( path ); FstabEntryList fstabEntries = lookForFstabEntries( path );
QString homePath = findPartitionPathForMountPoint( fstabEntries, "/home" ); QString homePath = findPartitionPathForMountPoint( fstabEntries, "/home" );
osproberEntries.append( osproberEntries.append( { prettyName,
{ prettyName, path, file, QString(), canBeResized( dm, path, o ), lineColumns, fstabEntries, homePath } ); path,
file,
QString(),
canBeResized( dm, path, o ),
lineColumns,
fstabEntries,
homePath } );
osproberCleanLines.append( line ); osproberCleanLines.append( line );
} }
} }

View File

@ -26,7 +26,7 @@ class DeviceModel;
class Partition; class Partition;
namespace Logger namespace Logger
{ {
class Once; class Once;
} }
namespace PartUtils namespace PartUtils

View File

@ -258,7 +258,7 @@ PartitionCoreModule::doInit()
cDebug() << Logger::SubEntry << "node\tcapacity\tname\tprettyName"; cDebug() << Logger::SubEntry << "node\tcapacity\tname\tprettyName";
for ( auto device : devices ) for ( auto device : devices )
{ {
cDebug() << Logger::SubEntry << Logger::Pointer(device); cDebug() << Logger::SubEntry << Logger::Pointer( device );
if ( device ) if ( device )
{ {
// Gives ownership of the Device* to the DeviceInfo object // Gives ownership of the Device* to the DeviceInfo object

View File

@ -144,14 +144,15 @@ ChoicePage::~ChoicePage() {}
* this avoids cases where the popup would truncate data being drawn * this avoids cases where the popup would truncate data being drawn
* because the overall box is sized too narrow. * because the overall box is sized too narrow.
*/ */
void setModelToComboBox( QComboBox* box, QAbstractItemModel* model ) void
setModelToComboBox( QComboBox* box, QAbstractItemModel* model )
{ {
box->setModel( model ); box->setModel( model );
if ( model->rowCount() > 0 ) if ( model->rowCount() > 0 )
{ {
QStyleOptionViewItem options; QStyleOptionViewItem options;
options.initFrom( box ); options.initFrom( box );
auto delegateSize = box->itemDelegate()->sizeHint(options, model->index(0, 0) ); auto delegateSize = box->itemDelegate()->sizeHint( options, model->index( 0, 0 ) );
box->setMinimumWidth( delegateSize.width() ); box->setMinimumWidth( delegateSize.width() );
} }
} }
@ -1005,7 +1006,8 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
SelectionFilter filter = []( const QModelIndex& index ) { SelectionFilter filter = []( const QModelIndex& index ) {
return PartUtils::canBeResized( return PartUtils::canBeResized(
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ), Logger::Once() ); static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ),
Logger::Once() );
}; };
m_beforePartitionBarsView->setSelectionFilter( filter ); m_beforePartitionBarsView->setSelectionFilter( filter );
m_beforePartitionLabelsView->setSelectionFilter( filter ); m_beforePartitionLabelsView->setSelectionFilter( filter );
@ -1094,7 +1096,8 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
{ {
SelectionFilter filter = []( const QModelIndex& index ) { SelectionFilter filter = []( const QModelIndex& index ) {
return PartUtils::canBeReplaced( return PartUtils::canBeReplaced(
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ), Logger::Once() ); static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ),
Logger::Once() );
}; };
m_beforePartitionBarsView->setSelectionFilter( filter ); m_beforePartitionBarsView->setSelectionFilter( filter );
m_beforePartitionLabelsView->setSelectionFilter( filter ); m_beforePartitionLabelsView->setSelectionFilter( filter );

View File

@ -135,7 +135,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device,
const FreeSpace& freeSpacePartition, const FreeSpace& freeSpacePartition,
const QStringList& usedMountPoints, const QStringList& usedMountPoints,
QWidget* parentWidget ) QWidget* parentWidget )
: CreatePartitionDialog(device, freeSpacePartition.p->parent(), usedMountPoints, parentWidget ) : CreatePartitionDialog( device, freeSpacePartition.p->parent(), usedMountPoints, parentWidget )
{ {
standardMountPoints( *( m_ui->mountPointComboBox ), QString() ); standardMountPoints( *( m_ui->mountPointComboBox ), QString() );
setFlagList( *( m_ui->m_listFlags ), setFlagList( *( m_ui->m_listFlags ),
@ -148,10 +148,9 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device,
const FreshPartition& existingNewPartition, const FreshPartition& existingNewPartition,
const QStringList& usedMountPoints, const QStringList& usedMountPoints,
QWidget* parentWidget ) QWidget* parentWidget )
: CreatePartitionDialog(device, existingNewPartition.p->parent(), usedMountPoints, parentWidget ) : CreatePartitionDialog( device, existingNewPartition.p->parent(), usedMountPoints, parentWidget )
{ {
standardMountPoints( *( m_ui->mountPointComboBox ), standardMountPoints( *( m_ui->mountPointComboBox ), PartitionInfo::mountPoint( existingNewPartition.p ) );
PartitionInfo::mountPoint( existingNewPartition.p ) );
setFlagList( *( m_ui->m_listFlags ), setFlagList( *( m_ui->m_listFlags ),
static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int( 0 ) ), static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int( 0 ) ),
PartitionInfo::flags( existingNewPartition.p ) ); PartitionInfo::flags( existingNewPartition.p ) );
@ -248,8 +247,8 @@ CreatePartitionDialog::getNewlyCreatedPartition()
} }
else else
{ {
partition partition = KPMHelpers::createNewPartition(
= KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, fsLabel, first, last, PartitionTable::Flags() ); m_parent, *m_device, m_role, fsType, fsLabel, first, last, PartitionTable::Flags() );
} }
if ( m_device->type() == Device::Type::LVM_Device ) if ( m_device->type() == Device::Type::LVM_Device )

View File

@ -40,13 +40,19 @@ private:
* This does all the shared UI setup. * This does all the shared UI setup.
*/ */
CreatePartitionDialog( Device* device, CreatePartitionDialog( Device* device,
PartitionNode* parentPartition, PartitionNode* parentPartition,
const QStringList& usedMountPoints, const QStringList& usedMountPoints,
QWidget* parentWidget ); QWidget* parentWidget );
public: public:
struct FreeSpace { Partition* p; }; struct FreeSpace
struct FreshPartition { Partition* p; }; {
Partition* p;
};
struct FreshPartition
{
Partition* p;
};
/** @brief Dialog for editing a new partition based on free space. /** @brief Dialog for editing a new partition based on free space.
* *

View File

@ -391,8 +391,8 @@ PartitionPage::onCreateClicked()
return; return;
} }
QPointer< CreatePartitionDialog > dlg = new QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog(
CreatePartitionDialog ( model->device(), CreatePartitionDialog::FreeSpace{ partition }, getCurrentUsedMountpoints(), this ); model->device(), CreatePartitionDialog::FreeSpace { partition }, getCurrentUsedMountpoints(), this );
if ( dlg->exec() == QDialog::Accepted ) if ( dlg->exec() == QDialog::Accepted )
{ {
Partition* newPart = dlg->getNewlyCreatedPartition(); Partition* newPart = dlg->getNewlyCreatedPartition();
@ -493,7 +493,7 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
mountPoints.removeOne( PartitionInfo::mountPoint( partition ) ); mountPoints.removeOne( PartitionInfo::mountPoint( partition ) );
QPointer< CreatePartitionDialog > dlg QPointer< CreatePartitionDialog > dlg
= new CreatePartitionDialog( device, CreatePartitionDialog::FreshPartition{ partition }, mountPoints, this ); = new CreatePartitionDialog( device, CreatePartitionDialog::FreshPartition { partition }, mountPoints, this );
if ( dlg->exec() == QDialog::Accepted ) if ( dlg->exec() == QDialog::Accepted )
{ {
Partition* newPartition = dlg->getNewlyCreatedPartition(); Partition* newPartition = dlg->getNewlyCreatedPartition();

View File

@ -388,7 +388,7 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core )
} }
auto [ r, device ] = core->bootLoaderModel()->findBootLoader( core->bootLoaderInstallPath() ); auto [ r, device ] = core->bootLoaderModel()->findBootLoader( core->bootLoaderInstallPath() );
Q_UNUSED(r); Q_UNUSED( r );
if ( device ) if ( device )
{ {
auto* table = device->partitionTable(); auto* table = device->partitionTable();
@ -403,8 +403,7 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core )
&& ( partition->fileSystem().type() == FileSystem::Unformatted ) && ( partition->fileSystem().type() == FileSystem::Unformatted )
&& ( partition->capacity() >= 8_MiB ) ) && ( partition->capacity() >= 8_MiB ) )
{ {
cDebug() << Logger::SubEntry << "Partition" << partition->devicePath() cDebug() << Logger::SubEntry << "Partition" << partition->devicePath() << partition->partitionPath()
<< partition->partitionPath()
<< "is a suitable bios_grub partition"; << "is a suitable bios_grub partition";
return false; return false;
} }
@ -619,7 +618,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
// because it could take a while. Then when it's done, we can set up the widgets // because it could take a while. Then when it's done, we can set up the widgets
// and remove the spinner. // and remove the spinner.
m_future = new QFutureWatcher< void >(); m_future = new QFutureWatcher< void >();
connect( m_future, &QFutureWatcher< void >::finished, this, [ this ] { connect( m_future, &QFutureWatcher< void >::finished, this, [this] {
continueLoading(); continueLoading();
this->m_future->deleteLater(); this->m_future->deleteLater();
this->m_future = nullptr; this->m_future = nullptr;