[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

@ -95,3 +95,24 @@ flagsFromList( const QListWidget& list )
return flags;
}
void
setFlagList( QListWidget& list, PartitionTable::Flags available, PartitionTable::Flags checked )
{
int f = 1;
QString s;
while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() )
{
if ( available & f )
{
QListWidgetItem* item = new QListWidgetItem( s );
list.addItem( item );
item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
item->setData( Qt::UserRole, f );
item->setCheckState( ( checked & f ) ?
Qt::Checked :
Qt::Unchecked );
}
f <<= 1;
}
}