Store list of physical volumes in a global variable.

This commit is contained in:
Andrius Štikonas 2016-11-03 13:26:23 +00:00
parent 97aedd1806
commit 46ae0c73a8
5 changed files with 10 additions and 12 deletions

View File

@ -20,6 +20,8 @@
#include <core/lvmdevice.h> #include <core/lvmdevice.h>
#include <fs/lvm2_pv.h>
#include <util/capacity.h> #include <util/capacity.h>
#include <util/helpers.h> #include <util/helpers.h>
@ -27,10 +29,9 @@
#include <KLocalizedString> #include <KLocalizedString>
#include <KSharedConfig> #include <KSharedConfig>
CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& pvList, qint32& peSize, QList<LvmPV> physicalVolumes, QList<Device*> devices) CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& pvList, qint32& peSize, QList<Device*> devices)
: VolumeGroupDialog(parent, vgName, pvList) : VolumeGroupDialog(parent, vgName, pvList)
, m_PESize(peSize) , m_PESize(peSize)
, m_PhysicalVolumes(physicalVolumes)
, m_Devices(devices) , m_Devices(devices)
{ {
setWindowTitle(xi18nc("@title:window", "Create new Volume Group")); setWindowTitle(xi18nc("@title:window", "Create new Volume Group"));
@ -48,7 +49,7 @@ CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgNam
void CreateVolumeGroupDialog::setupDialog() void CreateVolumeGroupDialog::setupDialog()
{ {
for (const auto &p : m_PhysicalVolumes) for (const auto &p : LVM::pvList) // FIXME: qAsConst
if (p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition())) if (p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition()))
dialogWidget().listPV().addPartition(*p.partition(), false); dialogWidget().listPV().addPartition(*p.partition(), false);
} }

View File

@ -31,7 +31,7 @@ class CreateVolumeGroupDialog : public VolumeGroupDialog
Q_DISABLE_COPY(CreateVolumeGroupDialog) Q_DISABLE_COPY(CreateVolumeGroupDialog)
public: public:
CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& pvList, qint32& peSize, QList<LvmPV> physicalVolumes, QList<Device*> devices); CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& pvList, qint32& peSize, QList<Device*> devices);
protected: protected:
void accept() override; void accept() override;
@ -49,7 +49,6 @@ protected:
qint32& m_PESize; qint32& m_PESize;
private: private:
const QList<LvmPV> m_PhysicalVolumes; // List of all LVM Physical Volumes found on the system
const QList<Device*> m_Devices; // List of all devices found on the system const QList<Device*> m_Devices; // List of all devices found on the system
}; };

View File

@ -1106,7 +1106,7 @@ void MainWindow::onCreateNewVolumeGroup()
QList<const Partition*> pvList; QList<const Partition*> pvList;
qint32 peSize = 4; qint32 peSize = 4;
// *NOTE*: vgName & pvList will be modified and validated by the dialog // *NOTE*: vgName & pvList will be modified and validated by the dialog
QPointer<CreateVolumeGroupDialog> dlg = new CreateVolumeGroupDialog(this, vgName, pvList, peSize, operationStack().physicalVolumes(), operationStack().previewDevices()); QPointer<CreateVolumeGroupDialog> dlg = new CreateVolumeGroupDialog(this, vgName, pvList, peSize, operationStack().previewDevices());
if (dlg->exec() == QDialog::Accepted) if (dlg->exec() == QDialog::Accepted)
operationStack().push(new CreateVolumeGroupOperation(vgName, pvList, peSize)); operationStack().push(new CreateVolumeGroupOperation(vgName, pvList, peSize));
@ -1121,7 +1121,7 @@ void MainWindow::onResizeVolumeGroup()
QList<const Partition*> pvList; QList<const Partition*> pvList;
// *NOTE*: pvList will be modified and validated by the dialog // *NOTE*: pvList will be modified and validated by the dialog
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList, operationStack().physicalVolumes()); QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList);
if (dlg->exec() == QDialog::Accepted) if (dlg->exec() == QDialog::Accepted)
operationStack().push(new ResizeVolumeGroupOperation(*d, pvList)); operationStack().push(new ResizeVolumeGroupOperation(*d, pvList));

View File

@ -34,10 +34,9 @@
@param parent pointer to the parent widget @param parent pointer to the parent widget
@param d the Device to show properties for @param d the Device to show properties for
*/ */
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QList<const Partition*>& partList, QList<LvmPV> physicalVolumes) ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QList<const Partition*>& partList)
: VolumeGroupDialog(parent, d->name(), partList) : VolumeGroupDialog(parent, d->name(), partList)
, m_Device(d) , m_Device(d)
, m_PhysicalVolumes(physicalVolumes)
{ {
setWindowTitle(xi18nc("@title:window", "Resize Volume Group")); setWindowTitle(xi18nc("@title:window", "Resize Volume Group"));
@ -51,7 +50,7 @@ ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerD
void ResizeVolumeGroupDialog::setupDialog() void ResizeVolumeGroupDialog::setupDialog()
{ {
if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) { if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) {
for (const auto &p : m_PhysicalVolumes) { for (const auto &p : LVM::pvList) { // FIXME: qAsConst
if (p.vgName() == device()->name()) if (p.vgName() == device()->name())
dialogWidget().listPV().addPartition(*p.partition(), true); dialogWidget().listPV().addPartition(*p.partition(), true);
else if (p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition())) // TODO: Remove LVM PVs in current VG else if (p.vgName() == QString() && !LvmDevice::s_DirtyPVs.contains(p.partition())) // TODO: Remove LVM PVs in current VG

View File

@ -31,7 +31,7 @@ class ResizeVolumeGroupDialog : public VolumeGroupDialog
Q_DISABLE_COPY(ResizeVolumeGroupDialog) Q_DISABLE_COPY(ResizeVolumeGroupDialog)
public: public:
ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QList<const Partition*>& partList, QList<LvmPV> physicalVolumes); ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QList<const Partition*>& partList);
protected: protected:
void accept() override; void accept() override;
@ -44,7 +44,6 @@ protected:
private: private:
VolumeManagerDevice* m_Device; VolumeManagerDevice* m_Device;
const QList<LvmPV> m_PhysicalVolumes; // List of all devices found on the system
}; };
#endif #endif