Avoid calling lvm command to list Volume Groups in CreateNewVolumeGroup dialog.
This commit is contained in:
parent
007c2faf11
commit
e2afd2c683
|
@ -27,11 +27,11 @@
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
|
|
||||||
CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, FS::lvm2_pv::PhysicalVolumes physicalVolumes, QString& vgName, QStringList& pvList, qint32& peSize)
|
CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QStringList& pvList, qint32& peSize, FS::lvm2_pv::PhysicalVolumes physicalVolumes, QList<Device*> devices)
|
||||||
: VolumeGroupDialog(parent, vgName, pvList)
|
: VolumeGroupDialog(parent, vgName, pvList)
|
||||||
, m_PESize(peSize)
|
, m_PESize(peSize)
|
||||||
, m_SystemVGList(LvmDevice::getVGs())
|
|
||||||
, m_PhysicalVolumes(physicalVolumes)
|
, m_PhysicalVolumes(physicalVolumes)
|
||||||
|
, m_Devices(devices)
|
||||||
{
|
{
|
||||||
setWindowTitle(xi18nc("@title:window", "Create new Volume Group"));
|
setWindowTitle(xi18nc("@title:window", "Create new Volume Group"));
|
||||||
|
|
||||||
|
@ -74,11 +74,16 @@ void CreateVolumeGroupDialog::accept()
|
||||||
|
|
||||||
void CreateVolumeGroupDialog::onVGNameChanged(const QString& vgname)
|
void CreateVolumeGroupDialog::onVGNameChanged(const QString& vgname)
|
||||||
{
|
{
|
||||||
if (m_SystemVGList.contains(vgname)) {
|
for (const auto &d : m_Devices) {
|
||||||
|
if (dynamic_cast<LvmDevice*>(d)) {
|
||||||
|
if (d->name() == vgname) {
|
||||||
m_IsValidName = false;
|
m_IsValidName = false;
|
||||||
} else {
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
m_IsValidName = true;
|
m_IsValidName = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateOkButtonStatus();
|
updateOkButtonStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#define CREATEVOLUMEGROUPDIALOG__H
|
#define CREATEVOLUMEGROUPDIALOG__H
|
||||||
|
|
||||||
|
#include <core/device.h>
|
||||||
#include <fs/lvm2_pv.h>
|
#include <fs/lvm2_pv.h>
|
||||||
|
|
||||||
#include "gui/volumegroupdialog.h"
|
#include "gui/volumegroupdialog.h"
|
||||||
|
@ -30,7 +31,7 @@ class CreateVolumeGroupDialog : public VolumeGroupDialog
|
||||||
Q_DISABLE_COPY(CreateVolumeGroupDialog)
|
Q_DISABLE_COPY(CreateVolumeGroupDialog)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CreateVolumeGroupDialog(QWidget* parent, FS::lvm2_pv::PhysicalVolumes physicalVolumes, QString& vgName, QStringList& pvList, qint32& peSize);
|
CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QStringList& pvList, qint32& peSize, FS::lvm2_pv::PhysicalVolumes physicalVolumes, QList<Device*> devices);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
|
@ -48,8 +49,8 @@ protected:
|
||||||
qint32& m_PESize;
|
qint32& m_PESize;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList m_SystemVGList;
|
const FS::lvm2_pv::PhysicalVolumes m_PhysicalVolumes; // List of all LVM Physical Volumes found on the system
|
||||||
const FS::lvm2_pv::PhysicalVolumes m_PhysicalVolumes; // List of all devices found on the system
|
const QList<Device*> m_Devices; // List of all devices found on the system
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1106,7 +1106,7 @@ void MainWindow::onCreateNewVolumeGroup()
|
||||||
QStringList* pvlist = new QStringList();
|
QStringList* pvlist = new QStringList();
|
||||||
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, operationStack().physicalVolumes(), *vgname, *pvlist, pesize);
|
QPointer<CreateVolumeGroupDialog> dlg = new CreateVolumeGroupDialog(this, *vgname, *pvlist, pesize, operationStack().physicalVolumes(), 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));
|
||||||
}
|
}
|
||||||
|
@ -1153,7 +1153,7 @@ void MainWindow::onResizeVolumeGroup()
|
||||||
QStringList* pvList = new QStringList();
|
QStringList* pvList = new QStringList();
|
||||||
// *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, operationStack().physicalVolumes(), *vgName, *pvList, *tmpDev);
|
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, *vgName, *pvList, *tmpDev, operationStack().physicalVolumes());
|
||||||
if (dlg->exec() == QDialog::Accepted) {
|
if (dlg->exec() == QDialog::Accepted) {
|
||||||
operationStack().push(new ResizeVolumeGroupOperation(*tmpDev, *pvList));
|
operationStack().push(new ResizeVolumeGroupOperation(*tmpDev, *pvList));
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
@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, FS::lvm2_pv::PhysicalVolumes physicalVolumes, QString& vgName, QStringList& partList, VolumeManagerDevice& d)
|
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, QString& vgName, QStringList& partList, VolumeManagerDevice& d, FS::lvm2_pv::PhysicalVolumes physicalVolumes)
|
||||||
: VolumeGroupDialog(parent, vgName, partList)
|
: VolumeGroupDialog(parent, vgName, partList)
|
||||||
, m_Device(d)
|
, m_Device(d)
|
||||||
, m_PhysicalVolumes(physicalVolumes)
|
, m_PhysicalVolumes(physicalVolumes)
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ResizeVolumeGroupDialog : public VolumeGroupDialog
|
||||||
Q_DISABLE_COPY(ResizeVolumeGroupDialog)
|
Q_DISABLE_COPY(ResizeVolumeGroupDialog)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ResizeVolumeGroupDialog(QWidget* parent, FS::lvm2_pv::PhysicalVolumes physicalVolumes, QString& vgName, QStringList& partList, VolumeManagerDevice& d);
|
ResizeVolumeGroupDialog(QWidget* parent, QString& vgName, QStringList& partList, VolumeManagerDevice& d, FS::lvm2_pv::PhysicalVolumes physicalVolumes);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
|
|
Loading…
Reference in New Issue