Do not let the user pick a partition type when creating a partition of a GPT disk

Fixes #27
This commit is contained in:
Aurélien Gâteau 2014-07-28 11:45:13 +02:00
parent feee2b3b60
commit 62d706543b
2 changed files with 40 additions and 21 deletions

View File

@ -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()
{

View File

@ -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;