[partition] Improve constness, naming

main
Adriaan de Groot 4 years ago
parent 4e8d67052f
commit 46ca4d93e7

@ -125,8 +125,8 @@ PartitionPage::~PartitionPage() {}
void void
PartitionPage::updateButtons() PartitionPage::updateButtons()
{ {
bool create = false, createTable = false, edit = false, del = false, currentDeviceIsVG = false, bool allow_create = false, allow_create_table = false, allow_edit = false, allow_delete = false;
isDeactivable = false; bool currentDeviceIsVG = false, isDeactivable = false;
bool isRemovable = false, isVGdeactivated = false; bool isRemovable = false, isVGdeactivated = false;
QModelIndex index = m_ui->partitionTreeView->currentIndex(); QModelIndex index = m_ui->partitionTreeView->currentIndex();
@ -136,17 +136,21 @@ PartitionPage::updateButtons()
Q_ASSERT( model ); Q_ASSERT( model );
Partition* partition = model->partitionForIndex( index ); Partition* partition = model->partitionForIndex( index );
Q_ASSERT( partition ); Q_ASSERT( partition );
bool isFree = CalamaresUtils::Partition::isPartitionFreeSpace( partition ); const bool isFree = CalamaresUtils::Partition::isPartitionFreeSpace( partition );
bool isExtended = partition->roles().has( PartitionRole::Extended ); const bool isExtended = partition->roles().has( PartitionRole::Extended );
bool hasChildren = isExtended // An extended partition can have a "free space" child; that one does
// not count as a real child. If there are more children, at least one
// is a real one and we should not allow the extended partition to be
// deleted.
const bool hasChildren = isExtended
&& ( partition->children().length() > 1 && ( partition->children().length() > 1
|| ( partition->children().length() == 1 || ( partition->children().length() == 1
&& !CalamaresUtils::Partition::isPartitionFreeSpace( partition->children().at( 0 ) ) ) ); && !CalamaresUtils::Partition::isPartitionFreeSpace( partition->children().at( 0 ) ) ) );
bool isInVG = m_core->isInVG( partition ); const bool isInVG = m_core->isInVG( partition );
create = isFree; allow_create = isFree;
// Keep it simple for now: do not support editing extended partitions as // Keep it simple for now: do not support editing extended partitions as
// it does not work with our current edit implementation which is // it does not work with our current edit implementation which is
@ -155,8 +159,8 @@ PartitionPage::updateButtons()
// inside them, so an edit must be applied without altering the job // inside them, so an edit must be applied without altering the job
// order. // order.
// TODO: See if LVM PVs can be edited in Calamares // TODO: See if LVM PVs can be edited in Calamares
edit = !isFree && !isExtended; allow_edit = !isFree && !isExtended;
del = !isFree && !isInVG && !hasChildren; allow_delete = !isFree && !isInVG && !hasChildren;
} }
if ( m_ui->deviceComboBox->currentIndex() >= 0 ) if ( m_ui->deviceComboBox->currentIndex() >= 0 )
@ -173,7 +177,7 @@ PartitionPage::updateButtons()
} }
else if ( device->type() != Device::Type::LVM_Device ) else if ( device->type() != Device::Type::LVM_Device )
{ {
createTable = true; allow_create_table = true;
#ifdef WITH_KPMCORE4API #ifdef WITH_KPMCORE4API
if ( device->type() == Device::Type::SoftwareRAID_Device if ( device->type() == Device::Type::SoftwareRAID_Device
@ -202,10 +206,10 @@ PartitionPage::updateButtons()
} }
} }
m_ui->createButton->setEnabled( create ); m_ui->createButton->setEnabled( allow_create );
m_ui->editButton->setEnabled( edit ); m_ui->editButton->setEnabled( allow_edit );
m_ui->deleteButton->setEnabled( del ); m_ui->deleteButton->setEnabled( allow_delete );
m_ui->newPartitionTableButton->setEnabled( createTable ); m_ui->newPartitionTableButton->setEnabled( allow_create_table );
m_ui->resizeVolumeGroupButton->setEnabled( currentDeviceIsVG && !isVGdeactivated ); m_ui->resizeVolumeGroupButton->setEnabled( currentDeviceIsVG && !isVGdeactivated );
m_ui->deactivateVolumeGroupButton->setEnabled( currentDeviceIsVG && isDeactivable && !isVGdeactivated ); m_ui->deactivateVolumeGroupButton->setEnabled( currentDeviceIsVG && isDeactivable && !isVGdeactivated );
m_ui->removeVolumeGroupButton->setEnabled( currentDeviceIsVG && isRemovable ); m_ui->removeVolumeGroupButton->setEnabled( currentDeviceIsVG && isRemovable );

Loading…
Cancel
Save