Support creation of extended partitions
This commit is contained in:
parent
e3c6869fbd
commit
1421a04dd2
@ -36,6 +36,26 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePar
|
||||
m_ui->setupUi( this );
|
||||
|
||||
FileSystemFactory::init();
|
||||
|
||||
bool hidePartitionType = false;
|
||||
if ( freePartition->roles().has( PartitionRole::Logical ) )
|
||||
{
|
||||
m_role = PartitionRole( PartitionRole::Logical );
|
||||
hidePartitionType = true;
|
||||
}
|
||||
else if ( m_device->partitionTable()->hasExtended() )
|
||||
{
|
||||
m_role = PartitionRole( PartitionRole::Primary );
|
||||
hidePartitionType = true;
|
||||
}
|
||||
|
||||
if ( hidePartitionType )
|
||||
{
|
||||
m_ui->partitionTypeLabel->hide();
|
||||
m_ui->primaryRadioButton->hide();
|
||||
m_ui->extendedRadioButton->hide();
|
||||
}
|
||||
|
||||
QStringList fsNames;
|
||||
for ( auto fs : FileSystemFactory::map() )
|
||||
{
|
||||
@ -58,18 +78,29 @@ CreatePartitionDialog::~CreatePartitionDialog()
|
||||
CreatePartitionJob*
|
||||
CreatePartitionDialog::createJob()
|
||||
{
|
||||
if ( m_role.roles() == PartitionRole::None )
|
||||
{
|
||||
m_role = PartitionRole(
|
||||
m_ui->extendedRadioButton->isChecked()
|
||||
? PartitionRole::Extended
|
||||
: PartitionRole::Primary
|
||||
);
|
||||
}
|
||||
|
||||
qint64 first = m_freePartition->firstSector();
|
||||
// FIXME: Check rounding errors here
|
||||
qint64 last = first + qint64( m_ui->sizeSpinBox->value() ) * 1024 * 1024 / m_device->logicalSectorSize();
|
||||
|
||||
FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() );
|
||||
FileSystem::Type type = m_role.has( PartitionRole::Extended )
|
||||
? FileSystem::Extended
|
||||
: FileSystem::typeForName( m_ui->fsComboBox->currentText() );
|
||||
FileSystem* fs = FileSystemFactory::create( type, first, last );
|
||||
|
||||
PartitionNode* parent = m_freePartition->parent();
|
||||
Partition* partition = new Partition(
|
||||
parent,
|
||||
*m_device,
|
||||
PartitionRole( PartitionRole::Primary ), // FIXME: Support extended partitions
|
||||
m_role,
|
||||
fs, first, last,
|
||||
QString() /* path */
|
||||
);
|
||||
|
@ -22,6 +22,9 @@
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
|
||||
// CalaPM
|
||||
#include <core/partitionrole.h>
|
||||
|
||||
class CreatePartitionJob;
|
||||
class Device;
|
||||
class Partition;
|
||||
@ -39,6 +42,7 @@ private:
|
||||
QScopedPointer< Ui_CreatePartitionDialog > m_ui;
|
||||
Device* m_device;
|
||||
Partition* m_freePartition;
|
||||
PartitionRole m_role = PartitionRole( PartitionRole::None );
|
||||
};
|
||||
|
||||
#endif /* CREATEPARTITIONDIALOG_H */
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>186</width>
|
||||
<height>170</height>
|
||||
<width>263</width>
|
||||
<height>179</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -16,24 +16,30 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>File System:</string>
|
||||
<string>F&ile System:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>fsComboBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="fsComboBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
<string>Si&ze:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>sizeSpinBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -46,13 +52,40 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="sizeSpinBox">
|
||||
<property name="suffix">
|
||||
<string> MB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="primaryRadioButton">
|
||||
<property name="text">
|
||||
<string>&Primary</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QRadioButton" name="extendedRadioButton">
|
||||
<property name="text">
|
||||
<string>E&xtended</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="partitionTypeLabel">
|
||||
<property name="text">
|
||||
<string>Partition &Type:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>primaryRadioButton</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@ -68,9 +101,10 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>primaryRadioButton</tabstop>
|
||||
<tabstop>extendedRadioButton</tabstop>
|
||||
<tabstop>fsComboBox</tabstop>
|
||||
<tabstop>sizeSpinBox</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
@ -86,7 +120,7 @@
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
<y>178</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -101,8 +135,24 @@
|
||||
<y>165</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
<x>262</x>
|
||||
<y>178</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>extendedRadioButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>fsComboBox</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>131</x>
|
||||
<y>36</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>134</x>
|
||||
<y>66</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
Loading…
Reference in New Issue
Block a user