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