Use cached values for resizing volume groups.
This commit is contained in:
parent
9a337e72f4
commit
fea271330d
|
@ -72,11 +72,11 @@ void CreateVolumeGroupDialog::accept()
|
|||
QDialog::accept();
|
||||
}
|
||||
|
||||
void CreateVolumeGroupDialog::onVGNameChanged(const QString& vgname)
|
||||
void CreateVolumeGroupDialog::onVGNameChanged(const QString& vgName)
|
||||
{
|
||||
for (const auto &d : m_Devices) {
|
||||
if (dynamic_cast<LvmDevice*>(d)) {
|
||||
if (d->name() == vgname) {
|
||||
if (d->name() == vgName) {
|
||||
m_IsValidName = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1116,15 +1116,14 @@ void MainWindow::onCreateNewVolumeGroup()
|
|||
void MainWindow::onResizeVolumeGroup()
|
||||
{
|
||||
if (pmWidget().selectedDevice()->type() == Device::LVM_Device) {
|
||||
LvmDevice* tmpDev = dynamic_cast<LvmDevice*>(pmWidget().selectedDevice());
|
||||
LvmDevice* d = dynamic_cast<LvmDevice*>(pmWidget().selectedDevice());
|
||||
|
||||
QString* vgName = new QString(tmpDev->name()); // This line only purpose is to make volumeGroupDialog happy
|
||||
QList<const Partition*> pvList;
|
||||
// *NOTE*: pvList will be modified and validated by the dialog
|
||||
|
||||
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, *vgName, pvList, *tmpDev, operationStack().physicalVolumes());
|
||||
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList, operationStack().physicalVolumes());
|
||||
if (dlg->exec() == QDialog::Accepted)
|
||||
operationStack().push(new ResizeVolumeGroupOperation(*tmpDev, pvList));
|
||||
operationStack().push(new ResizeVolumeGroupOperation(*d, pvList));
|
||||
|
||||
delete dlg;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
@param parent pointer to the parent widget
|
||||
@param d the Device to show properties for
|
||||
*/
|
||||
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& partList, VolumeManagerDevice& d, FS::lvm2_pv::PhysicalVolumes physicalVolumes)
|
||||
: VolumeGroupDialog(parent, vgName, partList)
|
||||
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QList<const Partition*>& partList, FS::lvm2_pv::PhysicalVolumes physicalVolumes)
|
||||
: VolumeGroupDialog(parent, d->name(), partList)
|
||||
, m_Device(d)
|
||||
, m_PhysicalVolumes(physicalVolumes)
|
||||
{
|
||||
|
@ -52,12 +52,23 @@ void ResizeVolumeGroupDialog::setupDialog()
|
|||
{
|
||||
if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) {
|
||||
for (const auto &p : m_PhysicalVolumes) {
|
||||
if (p.first == device().name())
|
||||
if (p.first == device()->name())
|
||||
dialogWidget().listPV().addPartition(*p.second, true);
|
||||
else if (p.first == QString() && !LvmDevice::s_DirtyPVs.contains(p.second)) // TODO: Remove LVM PVs in current VG
|
||||
dialogWidget().listPV().addPartition(*p.second, false);
|
||||
}
|
||||
}
|
||||
|
||||
//update used size and LV infos
|
||||
qint32 totalLV = 0;
|
||||
LvmDevice *lvmDevice = dynamic_cast<LvmDevice *>(device());
|
||||
if (lvmDevice != nullptr) {
|
||||
m_TotalUsedSize = lvmDevice->allocatedPE() * lvmDevice->peSize();
|
||||
totalLV = lvmDevice->partitionTable()->children().count();
|
||||
}
|
||||
|
||||
dialogWidget().totalUsedSize().setText(Capacity::formatByteSize(m_TotalUsedSize));
|
||||
dialogWidget().totalLV().setText(QString::number(totalLV));
|
||||
}
|
||||
|
||||
void ResizeVolumeGroupDialog::setupConstraints()
|
||||
|
|
|
@ -31,19 +31,19 @@ class ResizeVolumeGroupDialog : public VolumeGroupDialog
|
|||
Q_DISABLE_COPY(ResizeVolumeGroupDialog)
|
||||
|
||||
public:
|
||||
ResizeVolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& partList, VolumeManagerDevice& d, FS::lvm2_pv::PhysicalVolumes physicalVolumes);
|
||||
ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QList<const Partition*>& partList, FS::lvm2_pv::PhysicalVolumes physicalVolumes);
|
||||
|
||||
protected:
|
||||
void accept() override;
|
||||
void setupDialog() override;
|
||||
void setupConstraints() override;
|
||||
|
||||
VolumeManagerDevice& device() const {
|
||||
VolumeManagerDevice* device() const {
|
||||
return m_Device;
|
||||
}
|
||||
|
||||
private:
|
||||
VolumeManagerDevice& m_Device;
|
||||
VolumeManagerDevice* m_Device;
|
||||
const FS::lvm2_pv::PhysicalVolumes m_PhysicalVolumes; // List of all devices found on the system
|
||||
};
|
||||
|
||||
|
|
|
@ -79,19 +79,6 @@ void VolumeGroupDialog::setupDialog()
|
|||
dialogWidget().volumeType().addItem(QStringLiteral("RAID"));
|
||||
dialogWidget().volumeType().setCurrentIndex(0);
|
||||
|
||||
//update used size and LV infos
|
||||
qint32 totalLV = 0;
|
||||
QString vgname = dialogWidget().vgName().text();
|
||||
if (!vgname.isEmpty()) {
|
||||
m_TotalUsedSize = LvmDevice::getAllocatedPE(vgname) * LvmDevice::getPeSize(vgname);
|
||||
QStringList lvlist = LvmDevice::getLVs(vgname);
|
||||
if (!lvlist.isEmpty() ) {
|
||||
totalLV = lvlist.count();
|
||||
}
|
||||
}
|
||||
dialogWidget().totalUsedSize().setText(Capacity::formatByteSize(m_TotalUsedSize));
|
||||
dialogWidget().totalLV().setText(QString::number(totalLV));
|
||||
|
||||
setMinimumSize(dialogWidget().size());
|
||||
resize(dialogWidget().size());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue