Use new kpmcore function to check whether LVM VG can be removed.

This commit is contained in:
Andrius Štikonas 2016-11-05 15:35:27 +00:00
parent 042b83e1a0
commit 3eddfe2374
1 changed files with 4 additions and 11 deletions

View File

@ -515,11 +515,9 @@ void MainWindow::enableActions()
bool lvmDevice = pmWidget().selectedDevice() && pmWidget().selectedDevice()->type() == Device::LVM_Device; bool lvmDevice = pmWidget().selectedDevice() && pmWidget().selectedDevice()->type() == Device::LVM_Device;
bool removable = false; bool removable = false;
if (lvmDevice) { if (lvmDevice)
LvmDevice* d = static_cast<LvmDevice*>(pmWidget().selectedDevice()); removable = RemoveVolumeGroupOperation::isRemovable(dynamic_cast<LvmDevice*>(pmWidget().selectedDevice()));
if(!d->LVPathList()->count())
removable = true;
}
actionCollection()->action(QStringLiteral("removeVolumeGroup"))->setEnabled(removable); actionCollection()->action(QStringLiteral("removeVolumeGroup"))->setEnabled(removable);
actionCollection()->action(QStringLiteral("removeVolumeGroup"))->setVisible(lvmDevice); actionCollection()->action(QStringLiteral("removeVolumeGroup"))->setVisible(lvmDevice);
@ -1133,12 +1131,7 @@ void MainWindow::onRemoveVolumeGroup()
{ {
Device* tmpDev = pmWidget().selectedDevice(); Device* tmpDev = pmWidget().selectedDevice();
if (tmpDev->type() == Device::LVM_Device) { if (tmpDev->type() == Device::LVM_Device) {
LvmDevice* d = static_cast<LvmDevice*>(tmpDev); operationStack().push(new RemoveVolumeGroupOperation(*(dynamic_cast<LvmDevice*>(tmpDev))));
if(d->LVPathList()->count()) {
KMessageBox::error(this, xi18nc("@info", "Could not remove <filename>%1</filename>. There are still Logical Volumes on the Volume Group.", tmpDev->name()), i18nc("@title:window", "Error Removing Volume Group"));
} else {
operationStack().push(new RemoveVolumeGroupOperation( *(dynamic_cast<LvmDevice*>(tmpDev)) ));
}
} }
} }