From 5c9c414988464aad0c631ff14bc7540dff21efa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Thu, 7 Aug 2014 13:04:02 +0200 Subject: [PATCH] Use PartResizerWidget in CreatePartitionDialog --- .../partition/CreatePartitionDialog.cpp | 25 +++++- src/modules/partition/CreatePartitionDialog.h | 3 +- .../partition/CreatePartitionDialog.ui | 76 +++++++++++-------- 3 files changed, 69 insertions(+), 35 deletions(-) diff --git a/src/modules/partition/CreatePartitionDialog.cpp b/src/modules/partition/CreatePartitionDialog.cpp index dc5fd8fee..593ef6558 100644 --- a/src/modules/partition/CreatePartitionDialog.cpp +++ b/src/modules/partition/CreatePartitionDialog.cpp @@ -18,6 +18,7 @@ #include +#include #include #include #include @@ -116,7 +117,8 @@ CreatePartitionDialog::createPartition() ); } - PartitionSizeWidget::SectorRange range = m_ui->sizeSpinBox->sectorRange(); + qint64 first = m_partResizerWidgetPartition->firstSector(); + qint64 last = m_partResizerWidgetPartition->lastSector(); FileSystem::Type fsType = m_role.has( PartitionRole::Extended ) ? FileSystem::Extended @@ -125,7 +127,7 @@ CreatePartitionDialog::createPartition() m_parent, *m_device, m_role, - fsType, range.first, range.second ); + fsType, first, last ); PartitionInfo::setMountPoint( partition, m_ui->mountPointComboBox->currentText() ); PartitionInfo::setFormat( partition, true ); @@ -145,10 +147,25 @@ CreatePartitionDialog::updateMountPointUi() m_ui->mountPointComboBox->setEnabled( enabled ); } +void +CreatePartitionDialog::initPartResizerWidget( Partition* partition ) +{ + PartitionSizeController* controller = new PartitionSizeController( this ); + m_partResizerWidgetPartition.reset( PMUtils::clonePartition( m_device, partition ) ); + + qint64 minFirstSector = partition->firstSector() - m_device->partitionTable()->freeSectorsBefore( *partition ); + qint64 maxLastSector = partition->lastSector() + m_device->partitionTable()->freeSectorsAfter( *partition ); + m_ui->partResizerWidget->init( *m_device, *m_partResizerWidgetPartition, minFirstSector, maxLastSector ); + + controller->init( m_device, m_partResizerWidgetPartition.data() ); + controller->setPartResizerWidget( m_ui->partResizerWidget ); + controller->setSpinBox( m_ui->sizeSpinBox ); +} + void CreatePartitionDialog::initFromFreeSpace( Partition* freeSpacePartition ) { - m_ui->sizeSpinBox->init( m_device, freeSpacePartition ); + initPartResizerWidget( freeSpacePartition ); } void @@ -164,7 +181,7 @@ CreatePartitionDialog::initFromPartitionToCreate( Partition* partition ) return; } - m_ui->sizeSpinBox->init( m_device, partition ); + initPartResizerWidget( partition ); // File System FileSystem::Type fsType = partition->fileSystem().type(); diff --git a/src/modules/partition/CreatePartitionDialog.h b/src/modules/partition/CreatePartitionDialog.h index 289d25c5a..5680637aa 100644 --- a/src/modules/partition/CreatePartitionDialog.h +++ b/src/modules/partition/CreatePartitionDialog.h @@ -49,10 +49,11 @@ private: Device* m_device; PartitionNode* m_parent; PartitionRole m_role = PartitionRole( PartitionRole::None ); + QScopedPointer< Partition > m_partResizerWidgetPartition; void initGptPartitionTypeUi(); void initMbrPartitionTypeUi(); - void initSectorRange( Partition* ); + void initPartResizerWidget( Partition* ); }; #endif /* CREATEPARTITIONDIALOG_H */ diff --git a/src/modules/partition/CreatePartitionDialog.ui b/src/modules/partition/CreatePartitionDialog.ui index c14074c8c..2671ca9a6 100644 --- a/src/modules/partition/CreatePartitionDialog.ui +++ b/src/modules/partition/CreatePartitionDialog.ui @@ -14,9 +14,25 @@ Create a Partition + + + + + 0 + 0 + + + + + 0 + 59 + + + + - + Partition &Type: @@ -26,7 +42,7 @@ - + @@ -67,7 +83,7 @@ - + F&ile System: @@ -77,27 +93,10 @@ - + - - - - Si&ze: - - - sizeSpinBox - - - - - - - MB - - - - + Qt::Vertical @@ -113,7 +112,7 @@ - + &Mount Point: @@ -123,7 +122,7 @@ - + true @@ -163,7 +162,7 @@ - + Qt::Vertical @@ -176,7 +175,7 @@ - + Qt::Vertical @@ -189,6 +188,23 @@ + + + + Si&ze: + + + sizeSpinBox + + + + + + + MB + + + @@ -205,15 +221,15 @@ - PartitionSizeWidget - QSpinBox -
PartitionSizeWidget.h
+ PartResizerWidget + QWidget +
gui/partresizerwidget.h
+ 1
primaryRadioButton fsComboBox - sizeSpinBox