Newly created / to be removed LVM PVs in Resize VG dialog
Port changes from Create VG dialog:
Commit: af9fbe8a4f
This commit is contained in:
parent
b68db554f6
commit
773cbf6d3b
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <fs/lvm2_pv.h>
|
||||
|
||||
#include <ops/createvolumegroupoperation.h>
|
||||
#include <ops/deleteoperation.h>
|
||||
|
||||
#include <util/capacity.h>
|
||||
|
|
|
@ -15,17 +15,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#if !defined(CREATEVOLUMEGROUPDIALOG_H)
|
||||
|
||||
#ifndef CREATEVOLUMEGROUPDIALOG_H
|
||||
#define CREATEVOLUMEGROUPDIALOG_H
|
||||
|
||||
#include <core/device.h>
|
||||
#include <fs/lvm2_pv.h>
|
||||
#include <ops/operation.h>
|
||||
|
||||
#include "gui/volumegroupdialog.h"
|
||||
|
||||
class Device;
|
||||
class Operation;
|
||||
|
||||
class CreateVolumeGroupDialog : public VolumeGroupDialog
|
||||
{
|
||||
|
|
|
@ -1121,7 +1121,7 @@ void MainWindow::onResizeVolumeGroup()
|
|||
QVector<const Partition*> pvList;
|
||||
// *NOTE*: pvList will be modified and validated by the dialog
|
||||
|
||||
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList);
|
||||
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList, operationStack().previewDevices(), operationStack().operations());
|
||||
if (dlg->exec() == QDialog::Accepted)
|
||||
operationStack().push(new ResizeVolumeGroupOperation(*d, pvList));
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <core/partitiontable.h>
|
||||
#include <fs/lvm2_pv.h>
|
||||
|
||||
#include <ops/deleteoperation.h>
|
||||
|
||||
#include <util/capacity.h>
|
||||
#include <util/helpers.h>
|
||||
|
||||
|
@ -35,9 +37,11 @@
|
|||
@param parent pointer to the parent widget
|
||||
@param d the Device to show properties for
|
||||
*/
|
||||
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QVector<const Partition*>& partList)
|
||||
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QVector<const Partition*>& partList, QList<Device*> devices, QList<Operation*> pendingOps)
|
||||
: VolumeGroupDialog(parent, d->name(), partList)
|
||||
, m_Devices(devices)
|
||||
, m_Device(d)
|
||||
, m_PendingOps(pendingOps)
|
||||
{
|
||||
setWindowTitle(xi18nc("@title:window", "Resize Volume Group"));
|
||||
|
||||
|
@ -52,6 +56,19 @@ void ResizeVolumeGroupDialog::setupDialog()
|
|||
{
|
||||
if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) {
|
||||
for (const auto &p : qAsConst(LVM::pvList::list())) {
|
||||
bool toBeDeleted = false;
|
||||
|
||||
// Ignore partitions that are going to be deleted
|
||||
for (const auto &o : qAsConst(m_PendingOps)) {
|
||||
if (dynamic_cast<DeleteOperation *>(o) && o->targets(*p.partition())) {
|
||||
toBeDeleted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (toBeDeleted)
|
||||
continue;
|
||||
|
||||
if (p.isLuks())
|
||||
continue;
|
||||
if (p.vgName() == device()->name())
|
||||
|
@ -59,6 +76,26 @@ void ResizeVolumeGroupDialog::setupDialog()
|
|||
else if (p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition())) // TODO: Remove LVM PVs in current VG
|
||||
dialogWidget().listPV().addPartition(*p.partition(), false);
|
||||
}
|
||||
|
||||
for (const Device *d : qAsConst(m_Devices)) {
|
||||
for (const Partition *p : qAsConst(d->partitionTable()->children())) {
|
||||
// Looking if there is another VG creation that contains this partition
|
||||
if (LvmDevice::s_DirtyPVs.contains(p))
|
||||
continue;
|
||||
|
||||
// Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation)
|
||||
if (p->state() == Partition::State::New) {
|
||||
if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV)
|
||||
dialogWidget().listPV().addPartition(*p, false);
|
||||
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
|
||||
FileSystem *fs = static_cast<const FS::luks *>(&p->fileSystem())->innerFS();
|
||||
|
||||
if (fs->type() == FileSystem::Type::Lvm2_PV)
|
||||
dialogWidget().listPV().addPartition(*p, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update used size and LV infos
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#if !defined(RESIZEVOLUMEGROUPDIALOG_H)
|
||||
|
||||
#ifndef RESIZEVOLUMEGROUPDIALOG_H
|
||||
#define RESIZEVOLUMEGROUPDIALOG_H
|
||||
|
||||
#include <fs/lvm2_pv.h>
|
||||
|
@ -24,6 +23,7 @@
|
|||
#include "gui/volumegroupdialog.h"
|
||||
|
||||
class Device;
|
||||
class Operation;
|
||||
class VolumeManagerDevice;
|
||||
|
||||
class ResizeVolumeGroupDialog : public VolumeGroupDialog
|
||||
|
@ -31,7 +31,7 @@ class ResizeVolumeGroupDialog : public VolumeGroupDialog
|
|||
Q_DISABLE_COPY(ResizeVolumeGroupDialog)
|
||||
|
||||
public:
|
||||
ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QVector<const Partition*>& partList);
|
||||
ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QVector<const Partition*>& partList, QList<Device*> devices, QList<Operation*> pendingOps = QList<Operation *>());
|
||||
|
||||
protected:
|
||||
void accept() override;
|
||||
|
@ -43,7 +43,9 @@ protected:
|
|||
}
|
||||
|
||||
private:
|
||||
const QList<Device*> m_Devices; // List of all devices found on the system
|
||||
VolumeManagerDevice* m_Device;
|
||||
const QList<Operation*> m_PendingOps; // List of pending operations in KPM
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue