[partition] Including revert on creation of LVM VGs.
This commit is contained in:
parent
f8897e0e0b
commit
0465cc4214
@ -139,3 +139,17 @@ DeviceModel::addDevice( Device *device )
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void
|
||||
DeviceModel::removeDevice( Device *device )
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
m_devices.removeAll( device );
|
||||
std::sort( m_devices.begin(), m_devices.end(), []( const Device* dev1, const Device* dev2 )
|
||||
{
|
||||
return dev1->deviceNode() < dev2->deviceNode();
|
||||
} );
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
|
||||
void addDevice( Device* device );
|
||||
|
||||
void removeDevice( Device* device );
|
||||
|
||||
private:
|
||||
QList< Device* > m_devices;
|
||||
};
|
||||
|
@ -680,8 +680,33 @@ PartitionCoreModule::revert()
|
||||
void
|
||||
PartitionCoreModule::revertAllDevices()
|
||||
{
|
||||
foreach ( DeviceInfo* devInfo, m_deviceInfos )
|
||||
revertDevice( devInfo->device.data() );
|
||||
for ( auto it = m_deviceInfos.begin(); it != m_deviceInfos.end(); )
|
||||
{
|
||||
// In new VGs device info, there will be always a CreateVolumeGroupJob as the first job in jobs list
|
||||
if ( !( *it )->jobs.empty() )
|
||||
{
|
||||
CreateVolumeGroupJob* vgJob = dynamic_cast<CreateVolumeGroupJob*>( ( *it )->jobs[0].data() );
|
||||
|
||||
if ( vgJob )
|
||||
{
|
||||
vgJob->undoPreview();
|
||||
|
||||
( *it )->forgetChanges();
|
||||
|
||||
m_deviceModel->removeDevice( ( *it )->device.data() );
|
||||
|
||||
it = m_deviceInfos.erase( it );
|
||||
|
||||
scanForLVMPVs();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
revertDevice( ( *it )->device.data() );
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
@ -691,6 +716,7 @@ PartitionCoreModule::revertDevice( Device* dev )
|
||||
{
|
||||
QMutexLocker locker( &m_revertMutex );
|
||||
DeviceInfo* devInfo = infoForDevice( dev );
|
||||
|
||||
if ( !devInfo )
|
||||
return;
|
||||
devInfo->forgetChanges();
|
||||
|
@ -222,16 +222,17 @@ PartitionPage::onNewVolumeGroupClicked()
|
||||
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
||||
Q_ASSERT( deviceIndex.isValid() );
|
||||
|
||||
QVariant previousDeviceData = m_core->deviceModel()->data( deviceIndex, Qt::ToolTipRole );
|
||||
QVariant previousIndexDeviceData = m_core->deviceModel()->data( deviceIndex, Qt::ToolTipRole );
|
||||
|
||||
// Creating new VG
|
||||
m_core->createVolumeGroup( vgName, selectedPVs, peSize );
|
||||
|
||||
// As createVolumeGroup method call resets deviceModel,
|
||||
// is needed to set the current index in deviceComboBox as the previous one
|
||||
int previousIndex = m_ui->deviceComboBox->findData( previousDeviceData, Qt::ToolTipRole );
|
||||
int previousIndex = m_ui->deviceComboBox->findData( previousIndexDeviceData, Qt::ToolTipRole );
|
||||
|
||||
if ( previousIndex != -1 )
|
||||
m_ui->deviceComboBox->setCurrentIndex( previousIndex );
|
||||
m_ui->deviceComboBox->setCurrentIndex( ( previousIndex < 0 ) ? 0 : previousIndex );
|
||||
updateFromCurrentDevice();
|
||||
}
|
||||
|
||||
delete dlg;
|
||||
@ -301,7 +302,7 @@ PartitionPage::onRevertClicked()
|
||||
|
||||
int oldIndex = m_ui->deviceComboBox->currentIndex();
|
||||
m_core->revertAllDevices();
|
||||
m_ui->deviceComboBox->setCurrentIndex( oldIndex );
|
||||
m_ui->deviceComboBox->setCurrentIndex( ( oldIndex < 0 ) ? 0 : oldIndex );
|
||||
updateFromCurrentDevice();
|
||||
} ),
|
||||
[ this ]{
|
||||
|
Loading…
Reference in New Issue
Block a user