Init all fields when editing a partition. Disable editing of extended partitions for now.

This commit is contained in:
Aurélien Gâteau 2014-07-16 10:59:24 +02:00
parent d500c7b480
commit 568dc4db0a
2 changed files with 36 additions and 4 deletions

View File

@ -32,6 +32,12 @@
#include <QComboBox> #include <QComboBox>
#include <QSet> #include <QSet>
static QSet< FileSystem::Type > s_unmountableFS(
{
FileSystem::Unformatted,
FileSystem::LinuxSwap
} );
CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* parentPartition, QWidget* parentWidget ) CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* parentPartition, QWidget* parentWidget )
: QDialog( parentWidget ) : QDialog( parentWidget )
, m_ui( new Ui_CreatePartitionDialog ) , m_ui( new Ui_CreatePartitionDialog )
@ -141,13 +147,11 @@ CreatePartitionDialog::createPartitionInfo()
void void
CreatePartitionDialog::updateMountPointUi() CreatePartitionDialog::updateMountPointUi()
{ {
static QSet< FileSystem::Type > unmountableFS( { FileSystem::Unformatted, FileSystem::LinuxSwap } );
bool enabled = m_ui->primaryRadioButton->isChecked(); bool enabled = m_ui->primaryRadioButton->isChecked();
if ( enabled ) if ( enabled )
{ {
FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() ); 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->mountPointLabel->setEnabled( enabled );
m_ui->mountPointComboBox->setEnabled( enabled ); m_ui->mountPointComboBox->setEnabled( enabled );
@ -176,11 +180,30 @@ CreatePartitionDialog::initFromPartitionInfo( PartitionInfo* partitionInfo )
Q_ASSERT( partitionInfo ); Q_ASSERT( partitionInfo );
Partition* partition = partitionInfo->partition; 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 ); initSectorRange( partition );
if ( isExtended )
m_ui->extendedRadioButton->setChecked( true );
// Size
m_ui->sizeSpinBox->setValue( mbSizeForSectorRange( partition->firstSector(), partition->lastSector() ) ); 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 ); m_ui->mountPointComboBox->setCurrentText( partitionInfo->mountPoint );
updateMountPointUi();
} }
qint64 qint64

View File

@ -94,8 +94,17 @@ PartitionPage::updateButtons()
Partition* partition = model->partitionForIndex( index ); Partition* partition = model->partitionForIndex( index );
Q_ASSERT( partition ); Q_ASSERT( partition );
bool isFree = PMUtils::isPartitionFreeSpace( partition ); bool isFree = PMUtils::isPartitionFreeSpace( partition );
bool isExtended = partition->roles().has( PartitionRole::Extended );
create = isFree; 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->createButton->setEnabled( create );
m_ui->editButton->setEnabled( edit ); m_ui->editButton->setEnabled( edit );