Decouple Sector and Size informations update.
This commit is contained in:
parent
c8844c91e9
commit
2ec6857064
|
@ -86,5 +86,5 @@ void CreateVolumeDialog::onSpinPESizeChanged(int newsize)
|
||||||
{
|
{
|
||||||
Q_UNUSED(newsize);
|
Q_UNUSED(newsize);
|
||||||
updateOkButtonStatus();
|
updateOkButtonStatus();
|
||||||
updateSizeInfos();
|
updateSectorInfos();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,9 @@ VolumeDialog::VolumeDialog(QWidget* parent, QString& vgname, QStringList& pvlist
|
||||||
m_TargetName(vgname),
|
m_TargetName(vgname),
|
||||||
m_TargetPVList(pvlist),
|
m_TargetPVList(pvlist),
|
||||||
m_IsValidSize(false),
|
m_IsValidSize(false),
|
||||||
m_TotalUsedSize(0)
|
m_TotalSize(0),
|
||||||
|
m_TotalUsedSize(0),
|
||||||
|
m_ExtentSize(0)
|
||||||
{
|
{
|
||||||
Q_UNUSED(pvlist);
|
Q_UNUSED(pvlist);
|
||||||
mainLayout = new QVBoxLayout(this);
|
mainLayout = new QVBoxLayout(this);
|
||||||
|
@ -80,6 +82,7 @@ void VolumeDialog::setupDialog()
|
||||||
dialogWidget().volumeType().addItem(QStringLiteral("RAID"));
|
dialogWidget().volumeType().addItem(QStringLiteral("RAID"));
|
||||||
dialogWidget().volumeType().setCurrentIndex(0);
|
dialogWidget().volumeType().setCurrentIndex(0);
|
||||||
|
|
||||||
|
//update used size and LV infos
|
||||||
qint32 totalLV = 0;
|
qint32 totalLV = 0;
|
||||||
QString vgname = dialogWidget().vgName().text();
|
QString vgname = dialogWidget().vgName().text();
|
||||||
if (!vgname.isEmpty()) {
|
if (!vgname.isEmpty()) {
|
||||||
|
@ -134,28 +137,28 @@ void VolumeDialog::updatePartTable()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VolumeDialog::updateSectorInfos()
|
||||||
|
{
|
||||||
|
qint32 totalSectors = 0;
|
||||||
|
// we can't use LvmDevice mothod here because pv that is not in any VG will return 0
|
||||||
|
m_ExtentSize = dialogWidget().spinPESize().value() * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||||
|
if (m_ExtentSize > 0) {
|
||||||
|
totalSectors = m_TotalSize / m_ExtentSize;
|
||||||
|
}
|
||||||
|
dialogWidget().totalSectors().setText(QString::number(totalSectors));
|
||||||
|
}
|
||||||
|
|
||||||
void VolumeDialog::updateSizeInfos()
|
void VolumeDialog::updateSizeInfos()
|
||||||
{
|
{
|
||||||
qint64 totalSize = 0;
|
|
||||||
qint32 totalSectors = 0;
|
|
||||||
qint32 peSize = 0;
|
|
||||||
|
|
||||||
// we can't use LvmDevice mothod here because pv that is not in any VG will return 0
|
|
||||||
peSize = dialogWidget().spinPESize().value() * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
|
||||||
|
|
||||||
QStringList checkedPartitions = dialogWidget().listPV().checkedItems();
|
QStringList checkedPartitions = dialogWidget().listPV().checkedItems();
|
||||||
if (!checkedPartitions.isEmpty()) {
|
if (!checkedPartitions.isEmpty()) {
|
||||||
totalSize = FS::lvm2_pv::getPVSize(checkedPartitions);
|
m_TotalSize = FS::lvm2_pv::getPVSize(checkedPartitions);
|
||||||
if (peSize > 0) {
|
|
||||||
totalSectors = totalSize / peSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
dialogWidget().totalSize().setText(Capacity::formatByteSize(m_TotalSize));
|
||||||
dialogWidget().totalSize().setText(Capacity::formatByteSize(totalSize));
|
|
||||||
dialogWidget().totalSectors().setText(QString::number(totalSectors));
|
|
||||||
|
|
||||||
//Probably a bad design for updating state here; the state should be changed inside the update button function.
|
//Probably a bad design for updating state here; the state should be changed inside the update button function.
|
||||||
m_IsValidSize = totalSize > m_TotalUsedSize;
|
m_IsValidSize = m_TotalSize > m_TotalUsedSize;
|
||||||
|
updateSectorInfos();
|
||||||
updateOkButtonStatus();
|
updateOkButtonStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +170,6 @@ void VolumeDialog::onPartitionListChanged()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VolumeDialog::onVolumeTypeChanged(int index)
|
void VolumeDialog::onVolumeTypeChanged(int index)
|
||||||
{
|
{
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(index)
|
||||||
|
|
|
@ -46,6 +46,7 @@ protected:
|
||||||
virtual void updateOkButtonStatus();
|
virtual void updateOkButtonStatus();
|
||||||
virtual void updatePartTable();
|
virtual void updatePartTable();
|
||||||
virtual void updateSizeInfos();
|
virtual void updateSizeInfos();
|
||||||
|
virtual void updateSectorInfos();
|
||||||
virtual void updatePartitionList();
|
virtual void updatePartitionList();
|
||||||
|
|
||||||
virtual void onVolumeTypeChanged(int index);
|
virtual void onVolumeTypeChanged(int index);
|
||||||
|
@ -87,7 +88,10 @@ protected:
|
||||||
QString& m_TargetName;
|
QString& m_TargetName;
|
||||||
QStringList& m_TargetPVList;
|
QStringList& m_TargetPVList;
|
||||||
bool m_IsValidSize;
|
bool m_IsValidSize;
|
||||||
|
|
||||||
|
qint64 m_TotalSize;
|
||||||
qint64 m_TotalUsedSize;
|
qint64 m_TotalUsedSize;
|
||||||
|
qint32 m_ExtentSize;
|
||||||
|
|
||||||
QDialogButtonBox* dialogButtonBox;
|
QDialogButtonBox* dialogButtonBox;
|
||||||
QPushButton* okButton;
|
QPushButton* okButton;
|
||||||
|
|
Loading…
Reference in New Issue