partitionmanager/src/gui/resizevolumegroupdialog.cpp

76 lines
2.9 KiB
C++
Raw Normal View History

2016-07-09 01:12:31 +01:00
/*************************************************************************
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/
2016-09-04 12:25:43 +01:00
#include "gui/resizevolumegroupdialog.h"
#include "gui/volumegroupwidget.h"
2016-07-09 01:12:31 +01:00
#include <core/lvmdevice.h>
#include <core/volumemanagerdevice.h>
#include <core/partitiontable.h>
2016-07-09 01:12:31 +01:00
#include <fs/lvm2_pv.h>
#include <util/capacity.h>
#include <util/helpers.h>
2016-08-23 16:40:16 +01:00
#include <KConfigGroup>
2016-07-09 01:12:31 +01:00
#include <KLocalizedString>
#include <KSharedConfig>
2016-09-04 12:25:43 +01:00
/** Creates a new ResizeVolumeGroupDialog
2016-07-09 01:12:31 +01:00
@param parent pointer to the parent widget
@param dev the Device to show properties for
2016-07-09 01:12:31 +01:00
*/
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, const QList<Device*>& devices, QString& vgName, QStringList& partList, VolumeManagerDevice& d) :
VolumeGroupDialog(parent, vgName, partList),
m_Devices(devices),
m_Device(d)
2016-07-09 01:12:31 +01:00
{
setWindowTitle(xi18nc("@title:window", "Resize Volume Group"));
setupDialog();
setupConstraints();
KConfigGroup kcg(KSharedConfig::openConfig(), "resizeVolumeDialog");
restoreGeometry(kcg.readEntry<QByteArray>("Geometry", QByteArray()));
}
2016-09-04 12:25:43 +01:00
void ResizeVolumeGroupDialog::setupDialog()
2016-07-09 01:12:31 +01:00
{
if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) {
dialogWidget().listPV().addPartitionList(device().deviceNodes(), true);
for (const auto &p : FS::lvm2_pv::getFreePV(m_Devices)) {
if (!LvmDevice::s_DirtyPVs.contains(p->deviceNode())) {
dialogWidget().listPV().addPartition(p->deviceNode(), false);
}
}
}
2016-07-09 01:12:31 +01:00
}
2016-09-04 12:25:43 +01:00
void ResizeVolumeGroupDialog::setupConstraints()
2016-07-09 01:12:31 +01:00
{
dialogWidget().vgName().setEnabled(false);
dialogWidget().spinPESize().setEnabled(false);
dialogWidget().volumeType().setEnabled(false);
2016-09-04 12:25:43 +01:00
VolumeGroupDialog::setupConstraints();
2016-07-09 01:12:31 +01:00
}
2016-09-04 12:25:43 +01:00
void ResizeVolumeGroupDialog::accept()
2016-07-09 01:12:31 +01:00
{
targetPVList() << dialogWidget().listPV().checkedItems();
QDialog::accept();
}