Allow editing of partition mount points

main
Aurélien Gâteau 11 years ago
parent 48c078acc5
commit 9216982859

@ -149,11 +149,12 @@ CreatePartitionDialog::updateMountPointUi()
} }
void 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(); qint64 maxSize = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
m_ui->sizeSpinBox->setValue( maxSize / 1024 / 1024 ); m_ui->sizeSpinBox->setValue( maxSize / 1024 / 1024 );
// FIXME: Update other fields m_ui->mountPointComboBox->setCurrentText( partitionInfo->mountPoint );
} }

@ -39,7 +39,7 @@ public:
~CreatePartitionDialog(); ~CreatePartitionDialog();
void setSectorRange( qint64 minSector, qint64 maxSector ); void setSectorRange( qint64 minSector, qint64 maxSector );
void initFromPartition( Partition* partition ); void initFromPartitionInfo( PartitionInfo* partitionInfo );
PartitionInfo* createPartitionInfo(); PartitionInfo* createPartitionInfo();
private Q_SLOTS: private Q_SLOTS:

@ -139,3 +139,12 @@ PartitionModel::partitionForIndex( const QModelIndex& index ) const
return nullptr; return nullptr;
return m_partitionList.at( row ); 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 Device;
class Partition; class Partition;
class PartitionInfo;
class PartitionNode; class PartitionNode;
class PartitionInfoProvider class PartitionInfoProvider
@ -63,6 +64,7 @@ public:
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
Partition* partitionForIndex( const QModelIndex& index ) const; Partition* partitionForIndex( const QModelIndex& index ) const;
PartitionInfo* partitionInfoForIndex( const QModelIndex& index ) const;
Device* device() const Device* device() const
{ {

@ -149,10 +149,11 @@ PartitionPage::onEditClicked()
const PartitionModel* model = static_cast< const PartitionModel* >( index.model() ); const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
Partition* partition = model->partitionForIndex( index ); Partition* partition = model->partitionForIndex( index );
PartitionInfo* partitionInfo = model->partitionInfoForIndex( index );
Q_ASSERT( partition ); Q_ASSERT( partition );
if ( index.data( PartitionModel::IsNewPartitionRole ).toBool() ) if ( PMUtils::isPartitionNew( partitionInfo->partition ) )
updatePartitionToCreate( model->device(), partition ); updatePartitionToCreate( model->device(), partitionInfo );
else else
editExistingPartition( partition ); editExistingPartition( partition );
} }
@ -171,12 +172,13 @@ PartitionPage::onDeleteClicked()
} }
void 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 ); QPointer<CreatePartitionDialog> dlg = new CreatePartitionDialog( device, partition->parent(), this );
qint64 extraSectors = device->partitionTable()->freeSectorsAfter( *partition ); qint64 extraSectors = device->partitionTable()->freeSectorsAfter( *partition );
dlg->setSectorRange( partition->firstSector(), partition->lastSector() + extraSectors ); dlg->setSectorRange( partition->firstSector(), partition->lastSector() + extraSectors );
dlg->initFromPartition( partition ); dlg->initFromPartitionInfo( partitionInfo );
if ( dlg->exec() == QDialog::Accepted ) if ( dlg->exec() == QDialog::Accepted )
{ {
m_core->deletePartition( device, partition ); m_core->deletePartition( device, partition );

@ -28,6 +28,7 @@ class Ui_PartitionPage;
class Device; class Device;
class DeviceModel; class DeviceModel;
class Partition; class Partition;
class PartitionInfo;
class PartitionPage : public QWidget class PartitionPage : public QWidget
{ {
@ -49,7 +50,7 @@ private:
void onEditClicked(); void onEditClicked();
void onDeleteClicked(); void onDeleteClicked();
void updatePartitionToCreate( Device*, Partition* ); void updatePartitionToCreate( Device*, PartitionInfo* );
void editExistingPartition( Partition* ); void editExistingPartition( Partition* );
}; };

Loading…
Cancel
Save