Allow editing of partition mount points
This commit is contained in:
parent
48c078acc5
commit
9216982859
@ -149,11 +149,12 @@ CreatePartitionDialog::updateMountPointUi()
|
||||
}
|
||||
|
||||
void
|
||||
CreatePartitionDialog::initFromPartition( Partition* partition )
|
||||
CreatePartitionDialog::initFromPartitionInfo( PartitionInfo* partitionInfo )
|
||||
{
|
||||
Q_ASSERT( partition );
|
||||
Q_ASSERT( partitionInfo );
|
||||
Partition* partition = partitionInfo->partition;
|
||||
qint64 maxSize = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
|
||||
m_ui->sizeSpinBox->setValue( maxSize / 1024 / 1024 );
|
||||
|
||||
// FIXME: Update other fields
|
||||
m_ui->mountPointComboBox->setCurrentText( partitionInfo->mountPoint );
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
~CreatePartitionDialog();
|
||||
|
||||
void setSectorRange( qint64 minSector, qint64 maxSector );
|
||||
void initFromPartition( Partition* partition );
|
||||
void initFromPartitionInfo( PartitionInfo* partitionInfo );
|
||||
PartitionInfo* createPartitionInfo();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
@ -139,3 +139,12 @@ PartitionModel::partitionForIndex( const QModelIndex& index ) const
|
||||
return nullptr;
|
||||
return m_partitionList.at( row );
|
||||
}
|
||||
|
||||
PartitionInfo*
|
||||
PartitionModel::partitionInfoForIndex( const QModelIndex& index ) const
|
||||
{
|
||||
Partition* partition = partitionForIndex( index );
|
||||
if (!partition )
|
||||
return nullptr;
|
||||
return m_infoProvider->infoForPartition( partition );
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
class Device;
|
||||
class Partition;
|
||||
class PartitionInfo;
|
||||
class PartitionNode;
|
||||
|
||||
class PartitionInfoProvider
|
||||
@ -63,6 +64,7 @@ public:
|
||||
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
|
||||
|
||||
Partition* partitionForIndex( const QModelIndex& index ) const;
|
||||
PartitionInfo* partitionInfoForIndex( const QModelIndex& index ) const;
|
||||
|
||||
Device* device() const
|
||||
{
|
||||
|
@ -149,10 +149,11 @@ PartitionPage::onEditClicked()
|
||||
|
||||
const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
|
||||
Partition* partition = model->partitionForIndex( index );
|
||||
PartitionInfo* partitionInfo = model->partitionInfoForIndex( index );
|
||||
Q_ASSERT( partition );
|
||||
|
||||
if ( index.data( PartitionModel::IsNewPartitionRole ).toBool() )
|
||||
updatePartitionToCreate( model->device(), partition );
|
||||
if ( PMUtils::isPartitionNew( partitionInfo->partition ) )
|
||||
updatePartitionToCreate( model->device(), partitionInfo );
|
||||
else
|
||||
editExistingPartition( partition );
|
||||
}
|
||||
@ -171,12 +172,13 @@ PartitionPage::onDeleteClicked()
|
||||
}
|
||||
|
||||
void
|
||||
PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
|
||||
PartitionPage::updatePartitionToCreate( Device* device, PartitionInfo* partitionInfo )
|
||||
{
|
||||
Partition* partition = partitionInfo->partition;
|
||||
QPointer<CreatePartitionDialog> dlg = new CreatePartitionDialog( device, partition->parent(), this );
|
||||
qint64 extraSectors = device->partitionTable()->freeSectorsAfter( *partition );
|
||||
dlg->setSectorRange( partition->firstSector(), partition->lastSector() + extraSectors );
|
||||
dlg->initFromPartition( partition );
|
||||
dlg->initFromPartitionInfo( partitionInfo );
|
||||
if ( dlg->exec() == QDialog::Accepted )
|
||||
{
|
||||
m_core->deletePartition( device, partition );
|
||||
|
@ -28,6 +28,7 @@ class Ui_PartitionPage;
|
||||
class Device;
|
||||
class DeviceModel;
|
||||
class Partition;
|
||||
class PartitionInfo;
|
||||
|
||||
class PartitionPage : public QWidget
|
||||
{
|
||||
@ -49,7 +50,7 @@ private:
|
||||
void onEditClicked();
|
||||
void onDeleteClicked();
|
||||
|
||||
void updatePartitionToCreate( Device*, Partition* );
|
||||
void updatePartitionToCreate( Device*, PartitionInfo* );
|
||||
void editExistingPartition( Partition* );
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user