[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:
parent
4f451eece5
commit
ca03dad67b
@ -121,7 +121,8 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
|
|||||||
m_ui->fsComboBox->setCurrentIndex( defaultFsIndex );
|
m_ui->fsComboBox->setCurrentIndex( defaultFsIndex );
|
||||||
updateMountPointUi();
|
updateMountPointUi();
|
||||||
|
|
||||||
setupFlagsList();
|
setFlagList( *(m_ui->m_listFlags), static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int(0) ), PartitionTable::Flags() );
|
||||||
|
|
||||||
// Checks the initial selection.
|
// Checks the initial selection.
|
||||||
checkMountPointSelection();
|
checkMountPointSelection();
|
||||||
}
|
}
|
||||||
@ -136,25 +137,6 @@ CreatePartitionDialog::newFlags() const
|
|||||||
return flagsFromList( *(m_ui->m_listFlags) );
|
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
|
void
|
||||||
CreatePartitionDialog::initMbrPartitionTypeUi()
|
CreatePartitionDialog::initMbrPartitionTypeUi()
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,6 @@ private Q_SLOTS:
|
|||||||
void checkMountPointSelection();
|
void checkMountPointSelection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupFlagsList();
|
|
||||||
QScopedPointer< Ui_CreatePartitionDialog > m_ui;
|
QScopedPointer< Ui_CreatePartitionDialog > m_ui;
|
||||||
PartitionSizeController* m_partitionSizeController;
|
PartitionSizeController* m_partitionSizeController;
|
||||||
Device* m_device;
|
Device* m_device;
|
||||||
|
@ -106,7 +106,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
|
|||||||
m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() );
|
m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() );
|
||||||
m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() );
|
m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() );
|
||||||
|
|
||||||
setupFlagsList();
|
setFlagList( *(m_ui->m_listFlags), m_partition->availableFlags(), PartitionInfo::flags( m_partition ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -120,30 +120,6 @@ EditExistingPartitionDialog::newFlags() const
|
|||||||
return flagsFromList( *(m_ui->m_listFlags) );
|
return flagsFromList( *(m_ui->m_listFlags) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
EditExistingPartitionDialog::setupFlagsList()
|
|
||||||
{
|
|
||||||
int f = 1;
|
|
||||||
QString s;
|
|
||||||
while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() )
|
|
||||||
{
|
|
||||||
if ( m_partition->availableFlags() & f )
|
|
||||||
{
|
|
||||||
QListWidgetItem* item = new QListWidgetItem( s );
|
|
||||||
m_ui->m_listFlags->addItem( item );
|
|
||||||
item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
|
|
||||||
item->setData( Qt::UserRole, f );
|
|
||||||
item->setCheckState( ( PartitionInfo::flags( m_partition ) & f ) ?
|
|
||||||
Qt::Checked :
|
|
||||||
Qt::Unchecked );
|
|
||||||
}
|
|
||||||
|
|
||||||
f <<= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,6 @@ private:
|
|||||||
QStringList m_usedMountPoints;
|
QStringList m_usedMountPoints;
|
||||||
|
|
||||||
PartitionTable::Flags newFlags() const;
|
PartitionTable::Flags newFlags() const;
|
||||||
void setupFlagsList();
|
|
||||||
void replacePartResizerWidget();
|
void replacePartResizerWidget();
|
||||||
void updateMountPointPicker();
|
void updateMountPointPicker();
|
||||||
};
|
};
|
||||||
|
@ -95,3 +95,24 @@ flagsFromList( const QListWidget& list )
|
|||||||
return flags;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -63,5 +63,6 @@ static inline void setSelectedMountPoint(QComboBox* combo, const QString& select
|
|||||||
* Get the flags that have been checked in the list widget.
|
* Get the flags that have been checked in the list widget.
|
||||||
*/
|
*/
|
||||||
PartitionTable::Flags flagsFromList( const QListWidget& list );
|
PartitionTable::Flags flagsFromList( const QListWidget& list );
|
||||||
|
void setFlagList( QListWidget& list, PartitionTable::Flags available, PartitionTable::Flags checked );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user