[partition] Refactor getting the checked flags
This commit is contained in:
parent
950cc9070d
commit
4f451eece5
@ -133,14 +133,7 @@ CreatePartitionDialog::~CreatePartitionDialog()
|
|||||||
PartitionTable::Flags
|
PartitionTable::Flags
|
||||||
CreatePartitionDialog::newFlags() const
|
CreatePartitionDialog::newFlags() const
|
||||||
{
|
{
|
||||||
PartitionTable::Flags flags;
|
return flagsFromList( *(m_ui->m_listFlags) );
|
||||||
|
|
||||||
for ( int i = 0; i < m_ui->m_listFlags->count(); i++ )
|
|
||||||
if ( m_ui->m_listFlags->item( i )->checkState() == Qt::Checked )
|
|
||||||
flags |= static_cast< PartitionTable::Flag >(
|
|
||||||
m_ui->m_listFlags->item( i )->data( Qt::UserRole ).toInt() );
|
|
||||||
|
|
||||||
return flags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,14 +117,7 @@ EditExistingPartitionDialog::~EditExistingPartitionDialog()
|
|||||||
PartitionTable::Flags
|
PartitionTable::Flags
|
||||||
EditExistingPartitionDialog::newFlags() const
|
EditExistingPartitionDialog::newFlags() const
|
||||||
{
|
{
|
||||||
PartitionTable::Flags flags;
|
return flagsFromList( *(m_ui->m_listFlags) );
|
||||||
|
|
||||||
for ( int i = 0; i < m_ui->m_listFlags->count(); i++ )
|
|
||||||
if ( m_ui->m_listFlags->item( i )->checkState() == Qt::Checked )
|
|
||||||
flags |= static_cast< PartitionTable::Flag >(
|
|
||||||
m_ui->m_listFlags->item( i )->data( Qt::UserRole ).toInt() );
|
|
||||||
|
|
||||||
return flags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
standardMountPoints()
|
standardMountPoints()
|
||||||
@ -79,3 +80,18 @@ setSelectedMountPoint(QComboBox& combo, const QString& selected)
|
|||||||
combo.setCurrentIndex( combo.count() - 1);
|
combo.setCurrentIndex( combo.count() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PartitionTable::Flags
|
||||||
|
flagsFromList( const QListWidget& list )
|
||||||
|
{
|
||||||
|
PartitionTable::Flags flags;
|
||||||
|
|
||||||
|
for ( int i = 0; i < list.count(); i++ )
|
||||||
|
if ( list.item( i )->checkState() == Qt::Checked )
|
||||||
|
flags |= static_cast< PartitionTable::Flag >(
|
||||||
|
list.item( i )->data( Qt::UserRole ).toInt() );
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,12 @@
|
|||||||
#ifndef PARTITION_GUI_PARTITIONDIALOGHELPERS
|
#ifndef PARTITION_GUI_PARTITIONDIALOGHELPERS
|
||||||
#define PARTITION_GUI_PARTITIONDIALOGHELPERS
|
#define PARTITION_GUI_PARTITIONDIALOGHELPERS
|
||||||
|
|
||||||
|
#include <kpmcore/core/partitiontable.h>
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
class QListWidget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of standard mount points (e.g. /, /usr, ...).
|
* Returns a list of standard mount points (e.g. /, /usr, ...).
|
||||||
@ -56,4 +59,9 @@ static inline QString selectedMountPoint(QComboBox* combo) { return selectedMoun
|
|||||||
void setSelectedMountPoint( QComboBox& combo, const QString& selected );
|
void setSelectedMountPoint( QComboBox& combo, const QString& selected );
|
||||||
static inline void setSelectedMountPoint(QComboBox* combo, const QString& selected) { setSelectedMountPoint( *combo, selected); }
|
static inline void setSelectedMountPoint(QComboBox* combo, const QString& selected) { setSelectedMountPoint( *combo, selected); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the flags that have been checked in the list widget.
|
||||||
|
*/
|
||||||
|
PartitionTable::Flags flagsFromList( const QListWidget& list );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user