diff --git a/src/modules/partition/CreatePartitionDialog.cpp b/src/modules/partition/CreatePartitionDialog.cpp index 2a40752bb..3fc337154 100644 --- a/src/modules/partition/CreatePartitionDialog.cpp +++ b/src/modules/partition/CreatePartitionDialog.cpp @@ -32,6 +32,12 @@ #include #include +static QSet< FileSystem::Type > s_unmountableFS( +{ + FileSystem::Unformatted, + FileSystem::LinuxSwap +} ); + CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* parentPartition, QWidget* parentWidget ) : QDialog( parentWidget ) , m_ui( new Ui_CreatePartitionDialog ) @@ -141,13 +147,11 @@ CreatePartitionDialog::createPartitionInfo() void CreatePartitionDialog::updateMountPointUi() { - static QSet< FileSystem::Type > unmountableFS( { FileSystem::Unformatted, FileSystem::LinuxSwap } ); - bool enabled = m_ui->primaryRadioButton->isChecked(); if ( enabled ) { FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() ); - enabled = !unmountableFS.contains( type ); + enabled = !s_unmountableFS.contains( type ); } m_ui->mountPointLabel->setEnabled( enabled ); m_ui->mountPointComboBox->setEnabled( enabled ); @@ -176,11 +180,30 @@ CreatePartitionDialog::initFromPartitionInfo( PartitionInfo* partitionInfo ) Q_ASSERT( partitionInfo ); Partition* partition = partitionInfo->partition; + bool isExtended = partition->roles().has( PartitionRole::Extended ); + Q_ASSERT( !isExtended ); + if ( isExtended ) + { + cDebug() << "Editing extended partitions is not supported for now"; + return; + } + initSectorRange( partition ); + if ( isExtended ) + m_ui->extendedRadioButton->setChecked( true ); + + // Size m_ui->sizeSpinBox->setValue( mbSizeForSectorRange( partition->firstSector(), partition->lastSector() ) ); + // File System + FileSystem::Type fsType = partition->fileSystem().type(); + m_ui->fsComboBox->setCurrentText( FileSystem::nameForType( fsType ) ); + + // Mount point m_ui->mountPointComboBox->setCurrentText( partitionInfo->mountPoint ); + + updateMountPointUi(); } qint64 diff --git a/src/modules/partition/PartitionPage.cpp b/src/modules/partition/PartitionPage.cpp index eba971b60..3b74fc947 100644 --- a/src/modules/partition/PartitionPage.cpp +++ b/src/modules/partition/PartitionPage.cpp @@ -94,8 +94,17 @@ PartitionPage::updateButtons() Partition* partition = model->partitionForIndex( index ); Q_ASSERT( partition ); bool isFree = PMUtils::isPartitionFreeSpace( partition ); + bool isExtended = partition->roles().has( PartitionRole::Extended ); + create = isFree; - edit = del = !isFree; + // Keep it simple for now: do not support editing extended partitions as + // it does not work with our current edit implementation which is + // actually remove + add. This would not work with extended partitions + // because they need to be created *before* creating logical partitions + // inside them, so an edit must be applied without altering the job + // order. + edit = !isFree && !isExtended; + del = !isFree; } m_ui->createButton->setEnabled( create ); m_ui->editButton->setEnabled( edit );