2016-06-30 00:17:05 +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/createvolumegroupdialog.h"
|
|
|
|
#include "gui/volumegroupwidget.h"
|
2016-06-30 00:17:05 +01:00
|
|
|
|
|
|
|
#include <core/lvmdevice.h>
|
|
|
|
|
|
|
|
#include <util/capacity.h>
|
|
|
|
#include <util/helpers.h>
|
|
|
|
|
2016-08-23 16:40:16 +01:00
|
|
|
#include <KConfigGroup>
|
2016-06-30 00:17:05 +01:00
|
|
|
#include <KLocalizedString>
|
|
|
|
#include <KSharedConfig>
|
|
|
|
|
2016-09-10 22:10:11 +01:00
|
|
|
CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, FS::lvm2_pv::PhysicalVolumes physicalVolumes, QString& vgName, QStringList& pvList, qint32& peSize)
|
|
|
|
: VolumeGroupDialog(parent, vgName, pvList)
|
|
|
|
, m_PESize(peSize)
|
|
|
|
, m_SystemVGList(LvmDevice::getVGs())
|
|
|
|
, m_PhysicalVolumes(physicalVolumes)
|
2016-06-30 00:17:05 +01:00
|
|
|
{
|
2016-07-25 16:48:54 +01:00
|
|
|
setWindowTitle(xi18nc("@title:window", "Create new Volume Group"));
|
2016-06-30 00:17:05 +01:00
|
|
|
|
|
|
|
setupDialog();
|
2016-07-03 23:23:54 +01:00
|
|
|
setupConstraints();
|
2016-06-30 00:17:05 +01:00
|
|
|
setupConnections();
|
2016-07-15 22:39:12 +01:00
|
|
|
|
|
|
|
// disable volume type and PE size for now, until the features are implemented.
|
|
|
|
dialogWidget().volumeType().setEnabled(false);
|
2016-06-30 00:17:05 +01:00
|
|
|
|
|
|
|
KConfigGroup kcg(KSharedConfig::openConfig(), "createVolumeDialog");
|
|
|
|
restoreGeometry(kcg.readEntry<QByteArray>("Geometry", QByteArray()));
|
|
|
|
}
|
|
|
|
|
2016-09-04 12:25:43 +01:00
|
|
|
void CreateVolumeGroupDialog::setupDialog()
|
2016-06-30 00:17:05 +01:00
|
|
|
{
|
2016-09-11 00:19:58 +01:00
|
|
|
for (const auto &p : m_PhysicalVolumes)
|
|
|
|
if (p.first == QString() && !LvmDevice::s_DirtyPVs.contains(p.second->deviceNode()))
|
|
|
|
dialogWidget().listPV().addPartition(*p.second, false);
|
2016-06-30 00:17:05 +01:00
|
|
|
}
|
|
|
|
|
2016-09-04 12:25:43 +01:00
|
|
|
void CreateVolumeGroupDialog::setupConnections()
|
2016-06-30 00:17:05 +01:00
|
|
|
{
|
2016-09-04 12:25:43 +01:00
|
|
|
connect(&dialogWidget().vgName(), &QLineEdit::textChanged, this, &CreateVolumeGroupDialog::onVGNameChanged);
|
|
|
|
connect(&dialogWidget().spinPESize(), static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &CreateVolumeGroupDialog::onSpinPESizeChanged);
|
2016-07-02 09:27:20 +01:00
|
|
|
}
|
|
|
|
|
2016-09-04 12:25:43 +01:00
|
|
|
void CreateVolumeGroupDialog::accept()
|
2016-07-02 09:27:20 +01:00
|
|
|
{
|
2016-07-03 18:15:50 +01:00
|
|
|
QString& tname = targetName();
|
|
|
|
tname = dialogWidget().vgName().text();
|
|
|
|
|
2016-07-03 23:23:54 +01:00
|
|
|
targetPVList() << dialogWidget().listPV().checkedItems();
|
2016-07-03 18:15:50 +01:00
|
|
|
|
2016-07-18 01:07:53 +01:00
|
|
|
qint32& pesize = peSize();
|
|
|
|
pesize = dialogWidget().spinPESize().value();
|
|
|
|
|
2016-07-02 09:27:20 +01:00
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
2016-09-04 12:25:43 +01:00
|
|
|
void CreateVolumeGroupDialog::onVGNameChanged(const QString& vgname)
|
2016-07-02 09:27:20 +01:00
|
|
|
{
|
2016-08-08 04:49:41 +01:00
|
|
|
if (m_SystemVGList.contains(vgname)) {
|
|
|
|
m_IsValidName = false;
|
|
|
|
} else {
|
|
|
|
m_IsValidName = true;
|
|
|
|
}
|
2016-07-02 09:27:20 +01:00
|
|
|
updateOkButtonStatus();
|
|
|
|
}
|
|
|
|
|
2016-09-04 12:25:43 +01:00
|
|
|
void CreateVolumeGroupDialog::onSpinPESizeChanged(int newsize)
|
2016-07-02 09:27:20 +01:00
|
|
|
{
|
|
|
|
Q_UNUSED(newsize);
|
|
|
|
updateOkButtonStatus();
|
2016-08-01 16:19:19 +01:00
|
|
|
updateSectorInfos();
|
2016-06-30 00:17:05 +01:00
|
|
|
}
|