diff --git a/src/modules/partition/CreatePartitionDialog.cpp b/src/modules/partition/CreatePartitionDialog.cpp index a4abfbcfe..d908514a9 100644 --- a/src/modules/partition/CreatePartitionDialog.cpp +++ b/src/modules/partition/CreatePartitionDialog.cpp @@ -48,28 +48,10 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par FileSystemFactory::init(); - bool parentIsPartitionTable = parentPartition->isRoot(); - // Partition types - QString fixedPartitionType; - if ( !parentIsPartitionTable ) - { - m_role = PartitionRole( PartitionRole::Logical ); - fixedPartitionType = tr( "Logical" ); - } - else if ( m_device->partitionTable()->hasExtended() ) - { - m_role = PartitionRole( PartitionRole::Primary ); - fixedPartitionType = tr( "Primary" ); - } - - if ( fixedPartitionType.isEmpty() ) - m_ui->fixedPartitionLabel->hide(); + if ( device->partitionTable()->type() == PartitionTable::msdos ) + initMbrPartitionTypeUi(); else - { - m_ui->fixedPartitionLabel->setText( fixedPartitionType ); - m_ui->primaryRadioButton->hide(); - m_ui->extendedRadioButton->hide(); - } + initGptPartitionTypeUi(); // File system QStringList fsNames; @@ -88,6 +70,41 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par CreatePartitionDialog::~CreatePartitionDialog() {} +void +CreatePartitionDialog::initMbrPartitionTypeUi() +{ + QString fixedPartitionString; + bool parentIsPartitionTable = m_parent->isRoot(); + if ( !parentIsPartitionTable ) + { + m_role = PartitionRole( PartitionRole::Logical ); + fixedPartitionString = tr( "Logical" ); + } + else if ( m_device->partitionTable()->hasExtended() ) + { + m_role = PartitionRole( PartitionRole::Primary ); + fixedPartitionString = tr( "Primary" ); + } + + if ( fixedPartitionString.isEmpty() ) + m_ui->fixedPartitionLabel->hide(); + else + { + m_ui->fixedPartitionLabel->setText( fixedPartitionString ); + m_ui->primaryRadioButton->hide(); + m_ui->extendedRadioButton->hide(); + } +} + +void +CreatePartitionDialog::initGptPartitionTypeUi() +{ + m_role = PartitionRole( PartitionRole::Primary ); + m_ui->fixedPartitionLabel->setText( tr( "GPT" ) ); + m_ui->primaryRadioButton->hide(); + m_ui->extendedRadioButton->hide(); +} + Partition* CreatePartitionDialog::createPartition() { diff --git a/src/modules/partition/CreatePartitionDialog.h b/src/modules/partition/CreatePartitionDialog.h index 4ed8740ac..c21e4d12a 100644 --- a/src/modules/partition/CreatePartitionDialog.h +++ b/src/modules/partition/CreatePartitionDialog.h @@ -52,6 +52,8 @@ private: PartitionNode* m_parent; PartitionRole m_role = PartitionRole( PartitionRole::None ); + void initGptPartitionTypeUi(); + void initMbrPartitionTypeUi(); void initSectorRange( Partition* ); qint64 mbSizeForSectorRange( qint64 first, qint64 last ) const;