[partition] Refactor setting the flags UI

- Setup the lsit of flags consistently, by providing the available
   and to-be-checked flags.
 - In CreatePartitionDialog, assume that ~0 is all the flags.
This commit is contained in:
Adriaan de Groot 2018-05-16 09:04:47 -04:00
parent 4f451eece5
commit ca03dad67b
6 changed files with 25 additions and 47 deletions

View file

@ -121,7 +121,8 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
m_ui->fsComboBox->setCurrentIndex( defaultFsIndex );
updateMountPointUi();
setupFlagsList();
setFlagList( *(m_ui->m_listFlags), static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int(0) ), PartitionTable::Flags() );
// Checks the initial selection.
checkMountPointSelection();
}
@ -136,25 +137,6 @@ CreatePartitionDialog::newFlags() const
return flagsFromList( *(m_ui->m_listFlags) );
}
void
CreatePartitionDialog::setupFlagsList()
{
int f = 1;
QString s;
while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() )
{
QListWidgetItem* item = new QListWidgetItem( s );
m_ui->m_listFlags->addItem( item );
item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
item->setData( Qt::UserRole, f );
item->setCheckState( Qt::Unchecked );
f <<= 1;
}
}
void
CreatePartitionDialog::initMbrPartitionTypeUi()
{