Resizing Volume Group preview.

This commit is contained in:
Chantara Tith 2016-08-08 06:40:34 +07:00 committed by Andrius Štikonas
parent 467759d0a9
commit f115383d8c
2 changed files with 22 additions and 1 deletions

View File

@ -41,7 +41,9 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& dev, const QSt
m_ShrinkVolumeGroupJob(nullptr),
m_MovePhysicalVolumeJob(nullptr)
{
const QStringList clist = LvmDevice::getPVs(dev.name());
const QStringList clist = currentList();
m_TargetSize = FS::lvm2_pv::getPVSize(targetList());
m_CurrentSize = FS::lvm2_pv::getPVSize(currentList());
QStringList toRemoveList = clist;
foreach (QString path, partlist) {
@ -111,8 +113,17 @@ bool ResizeVolumeGroupOperation::targets(const Partition& part) const
void ResizeVolumeGroupOperation::preview()
{
//asumming that targetSize is larger than the allocated space.
device().setTotalLogical(targetSize() / device().logicalSize());
device().partitionTable()->setFirstUsableSector(PartitionTable::defaultFirstUsable(device(), PartitionTable::vmd));
device().partitionTable()->setLastUsableSector(PartitionTable::defaultLastUsable(device(), PartitionTable::vmd));
device().partitionTable()->updateUnallocated(device());
}
void ResizeVolumeGroupOperation::undo()
{
device().setTotalLogical(currentSize() / device().logicalSize());
device().partitionTable()->setFirstUsableSector(PartitionTable::defaultFirstUsable(device(), PartitionTable::vmd));
device().partitionTable()->setLastUsableSector(PartitionTable::defaultLastUsable(device(), PartitionTable::vmd));
device().partitionTable()->updateUnallocated(device());
}

View File

@ -72,6 +72,14 @@ protected:
return m_CurrentList;
}
qint64 targetSize() const {
return m_TargetSize;
}
qint64 currentSize() const {
return m_CurrentSize;
}
ResizeVolumeGroupJob* growVolumeGroupJob() {
return m_GrowVolumeGroupJob;
}
@ -89,6 +97,8 @@ private:
const QStringList m_TargetList;
const QStringList m_CurrentList;
qint64 m_TargetSize;
qint64 m_CurrentSize;
ResizeVolumeGroupJob *m_GrowVolumeGroupJob;
ResizeVolumeGroupJob *m_ShrinkVolumeGroupJob;