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>
|
2016-08-08 00:47:05 +01:00
|
|
|
#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
|
2016-09-08 01:42:13 +01:00
|
|
|
@param d the Device to show properties for
|
2016-07-09 01:12:31 +01:00
|
|
|
*/
|
2016-09-18 01:55:14 +01:00
|
|
|
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& partList, VolumeManagerDevice& d, FS::lvm2_pv::PhysicalVolumes physicalVolumes)
|
2016-09-10 22:10:11 +01:00
|
|
|
: VolumeGroupDialog(parent, vgName, partList)
|
|
|
|
, m_Device(d)
|
|
|
|
, m_PhysicalVolumes(physicalVolumes)
|
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
|
|
|
{
|
2016-08-08 00:47:05 +01:00
|
|
|
if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) {
|
2016-09-10 22:10:11 +01:00
|
|
|
for (const auto &p : m_PhysicalVolumes) {
|
2016-09-11 00:19:58 +01:00
|
|
|
if (p.first == device().name())
|
|
|
|
dialogWidget().listPV().addPartition(*p.second, true);
|
2016-09-18 01:55:14 +01:00
|
|
|
else if (p.first == QString() && !LvmDevice::s_DirtyPVs.contains(p.second)) // TODO: Remove LVM PVs in current VG
|
2016-09-11 00:19:58 +01:00
|
|
|
dialogWidget().listPV().addPartition(*p.second, false);
|
2016-08-08 08:04:55 +01:00
|
|
|
}
|
2016-08-08 00:47:05 +01:00
|
|
|
}
|
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();
|
|
|
|
}
|