diff --git a/src/gui/createvolumegroupdialog.cpp b/src/gui/createvolumegroupdialog.cpp index ca635be..eab4681 100644 --- a/src/gui/createvolumegroupdialog.cpp +++ b/src/gui/createvolumegroupdialog.cpp @@ -25,7 +25,6 @@ #include -#include #include #include diff --git a/src/gui/createvolumegroupdialog.h b/src/gui/createvolumegroupdialog.h index 1f40119..4dcf2dc 100644 --- a/src/gui/createvolumegroupdialog.h +++ b/src/gui/createvolumegroupdialog.h @@ -15,17 +15,16 @@ * along with this program. If not, see .* *************************************************************************/ -#if !defined(CREATEVOLUMEGROUPDIALOG_H) - +#ifndef CREATEVOLUMEGROUPDIALOG_H #define CREATEVOLUMEGROUPDIALOG_H #include #include -#include #include "gui/volumegroupdialog.h" class Device; +class Operation; class CreateVolumeGroupDialog : public VolumeGroupDialog { diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 99ea56a..fdd0736 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1121,7 +1121,7 @@ void MainWindow::onResizeVolumeGroup() QVector pvList; // *NOTE*: pvList will be modified and validated by the dialog - QPointer dlg = new ResizeVolumeGroupDialog(this, d, pvList); + QPointer dlg = new ResizeVolumeGroupDialog(this, d, pvList, operationStack().previewDevices(), operationStack().operations()); if (dlg->exec() == QDialog::Accepted) operationStack().push(new ResizeVolumeGroupOperation(*d, pvList)); diff --git a/src/gui/resizevolumegroupdialog.cpp b/src/gui/resizevolumegroupdialog.cpp index 35ec4ab..e0f856f 100644 --- a/src/gui/resizevolumegroupdialog.cpp +++ b/src/gui/resizevolumegroupdialog.cpp @@ -24,6 +24,8 @@ #include #include +#include + #include #include @@ -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& partList) +ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QVector& partList, QList devices, QList 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(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(&p->fileSystem())->innerFS(); + + if (fs->type() == FileSystem::Type::Lvm2_PV) + dialogWidget().listPV().addPartition(*p, false); + } + } + } + } } //update used size and LV infos diff --git a/src/gui/resizevolumegroupdialog.h b/src/gui/resizevolumegroupdialog.h index 138161a..986ffc8 100644 --- a/src/gui/resizevolumegroupdialog.h +++ b/src/gui/resizevolumegroupdialog.h @@ -15,8 +15,7 @@ * along with this program. If not, see .* *************************************************************************/ -#if !defined(RESIZEVOLUMEGROUPDIALOG_H) - +#ifndef RESIZEVOLUMEGROUPDIALOG_H #define RESIZEVOLUMEGROUPDIALOG_H #include @@ -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& partList); + ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QVector& partList, QList devices, QList pendingOps = QList()); protected: void accept() override; @@ -43,7 +43,9 @@ protected: } private: + const QList m_Devices; // List of all devices found on the system VolumeManagerDevice* m_Device; + const QList m_PendingOps; // List of pending operations in KPM }; #endif