diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 697d82e6532cd36012aa3db44d8fbb10326c52d0..a6ef98943bcfbf7e809038f2b1cd385482d4c572 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -39,6 +39,7 @@ #include <QComboBox> #include <QDir> #include <QSet> +#include <QListWidgetItem> static QSet< FileSystem::Type > s_unmountableFS( { @@ -83,11 +84,46 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par // Connections connect( m_ui->fsComboBox, SIGNAL( activated( int ) ), SLOT( updateMountPointUi() ) ); connect( m_ui->extendedRadioButton, SIGNAL( toggled( bool ) ), SLOT( updateMountPointUi() ) ); + + setupFlagsList(); } CreatePartitionDialog::~CreatePartitionDialog() {} + +PartitionTable::Flags +CreatePartitionDialog::newFlags() const +{ + PartitionTable::Flags flags; + + 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; +} + + +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() { @@ -145,10 +181,11 @@ CreatePartitionDialog::createPartition() m_parent, *m_device, m_role, - fsType, first, last ); + fsType, first, last, newFlags() ); PartitionInfo::setMountPoint( partition, m_ui->mountPointComboBox->currentText() ); PartitionInfo::setFormat( partition, true ); + return partition; } diff --git a/src/modules/partition/gui/CreatePartitionDialog.h b/src/modules/partition/gui/CreatePartitionDialog.h index 360f3b42b143e13baca771d4ce5b7fda80d75d5e..6be9a5a7e78ae80a0252268443c9ddc071c8e446 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.h +++ b/src/modules/partition/gui/CreatePartitionDialog.h @@ -21,6 +21,7 @@ // KPMcore #include <kpmcore/core/partitionrole.h> +#include <kpmcore/core/partitiontable.h> #include <QDialog> #include <QScopedPointer> @@ -55,10 +56,13 @@ public: void initFromPartitionToCreate( Partition* partition ); Partition* createPartition(); + PartitionTable::Flags newFlags() const; + private Q_SLOTS: void updateMountPointUi(); private: + void setupFlagsList(); QScopedPointer< Ui_CreatePartitionDialog > m_ui; PartitionSizeController* m_partitionSizeController; Device* m_device; diff --git a/src/modules/partition/gui/CreatePartitionDialog.ui b/src/modules/partition/gui/CreatePartitionDialog.ui index e5cc5179b2b0c33a941cfd5f3f3cb1d717eb6d1b..c5ff9e1ea4ee2f655b18efd0d278a7adcd70f873 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.ui +++ b/src/modules/partition/gui/CreatePartitionDialog.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>425</width> - <height>208</height> + <width>642</width> + <height>489</height> </rect> </property> <property name="windowTitle"> @@ -86,7 +86,7 @@ <item row="3" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> - <string>F&ile System:</string> + <string>Fi&le System:</string> </property> <property name="buddy"> <cstring>fsComboBox</cstring> @@ -132,7 +132,7 @@ </property> </widget> </item> - <item row="7" column="0"> + <item row="8" column="0"> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -175,6 +175,26 @@ </property> </widget> </item> + <item row="7" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Flags:</string> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QListWidget" name="m_listFlags"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::NoSelection</enum> + </property> + <property name="sortingEnabled"> + <bool>true</bool> + </property> + </widget> + </item> </layout> </item> <item>