Temporary Use selected Partition as PV for creating new VG.
This commit is contained in:
parent
9a4e54fb42
commit
a1fe5dff56
|
@ -34,7 +34,7 @@
|
|||
#include <QTreeWidgetItem>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
CreateVolumeDialog::CreateVolumeDialog(QWidget* parent, QString& vgname, QList<Partition*>& pvlist) :
|
||||
CreateVolumeDialog::CreateVolumeDialog(QWidget* parent, QString& vgname, QStringList& pvlist) :
|
||||
VolumeDialog(parent, vgname, pvlist)
|
||||
{
|
||||
setWindowTitle(xi18nc("@title:window", "Cretae new Volume Group"));
|
||||
|
@ -53,7 +53,6 @@ CreateVolumeDialog::~CreateVolumeDialog()
|
|||
|
||||
void CreateVolumeDialog::setupDialog()
|
||||
{
|
||||
VolumeDialog::setupDialog();
|
||||
}
|
||||
|
||||
void CreateVolumeDialog::setupConstraints()
|
||||
|
@ -63,16 +62,25 @@ void CreateVolumeDialog::setupConstraints()
|
|||
|
||||
void CreateVolumeDialog::setupConnections()
|
||||
{
|
||||
VolumeDialog::setupConnections();
|
||||
connect(&dialogWidget().vgName(), &QLineEdit::textChanged, this, &CreateVolumeDialog::onVGNameChanged);
|
||||
connect(&dialogWidget().spinPESize(), static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &CreateVolumeDialog::onSpinPESizeChanged);
|
||||
}
|
||||
|
||||
void CreateVolumeDialog::accept()
|
||||
{
|
||||
QString& tname = targetName();
|
||||
tname = dialogWidget().vgName().text();
|
||||
|
||||
targetPVList() << dialogWidget().listPV().selectedText();
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void CreateVolumeDialog::reject()
|
||||
{
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void CreateVolumeDialog::onVGNameChanged(const QString& vgname)
|
||||
{
|
||||
Q_UNUSED(vgname);
|
||||
|
|
|
@ -26,11 +26,12 @@ class CreateVolumeDialog : public VolumeDialog
|
|||
Q_DISABLE_COPY(CreateVolumeDialog)
|
||||
|
||||
public:
|
||||
CreateVolumeDialog(QWidget* parent, QString& vgname, QList<Partition*>& pvlist);
|
||||
CreateVolumeDialog(QWidget* parent, QString& vgname, QStringList& pvlist);
|
||||
~CreateVolumeDialog();
|
||||
|
||||
protected:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
void setupDialog() override;
|
||||
void setupConstraints() override;
|
||||
void setupConnections() override;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "gui/listphysicalvolumes.h"
|
||||
|
||||
#include <core/lvmdevice.h>
|
||||
#include <fs/lvm2_pv.h>
|
||||
|
||||
#include <util/globallog.h>
|
||||
#include <util/capacity.h>
|
||||
|
@ -40,11 +40,13 @@ ListPhysicalVolumes::ListPhysicalVolumes(QWidget* parent) :
|
|||
Ui::ListPhysicalVolumesBase()
|
||||
{
|
||||
setupUi(this);
|
||||
listPhysicalVolumes().addItem(new ListPhysicalVolumeWidgetItem(QStringLiteral("TESTING STRING")));
|
||||
QStringList pvlist = FS::lvm2_pv::getFreePV();
|
||||
foreach (QString pvnode, pvlist) {
|
||||
listPhysicalVolumes().addItem(new ListPhysicalVolumeWidgetItem(pvnode));
|
||||
}
|
||||
}
|
||||
|
||||
void selectionToggled(const QString& pvnode)
|
||||
void onSelectionToggled()
|
||||
{
|
||||
Q_UNUSED(pvnode);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,13 +29,18 @@ class KActionCollection;
|
|||
|
||||
class ListPhysicalVolumes : public QWidget, public Ui::ListPhysicalVolumesBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ListPhysicalVolumes)
|
||||
|
||||
public:
|
||||
ListPhysicalVolumes(QWidget* parent = nullptr);
|
||||
|
||||
void selectionToggled(const QString& pvnode);
|
||||
void selectionToggled(const QString& pvnode, bool checked);
|
||||
|
||||
void onSelectionToggled();
|
||||
|
||||
QString selectedText() {
|
||||
return listPhysicalVolumes().currentItem()->text();
|
||||
}
|
||||
|
||||
protected:
|
||||
QListWidget& listPhysicalVolumes() {
|
||||
|
@ -46,6 +51,7 @@ protected:
|
|||
Q_ASSERT(m_ListPhysicalVolumes);
|
||||
return *m_ListPhysicalVolumes;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
#include "gui/volumedialog.h"
|
||||
#include "gui/volumewidget.h"
|
||||
|
||||
#include <core/partitiontable.h>
|
||||
#include <core/lvmdevice.h>
|
||||
#include <fs/lvm2_pv.h>
|
||||
|
||||
#include <util/capacity.h>
|
||||
#include <util/helpers.h>
|
||||
|
@ -37,10 +39,11 @@
|
|||
@param parent pointer to the parent widget
|
||||
@param d the Device to show properties for
|
||||
*/
|
||||
VolumeDialog::VolumeDialog(QWidget* parent, QString& vgname, QList<Partition*>& pvlist) :
|
||||
VolumeDialog::VolumeDialog(QWidget* parent, QString& vgname, QStringList& pvlist) :
|
||||
QDialog(parent),
|
||||
m_DialogWidget(new VolumeWidget(this)),
|
||||
m_OriginalName(vgname)
|
||||
m_TargetName(vgname),
|
||||
m_TargetPVList(pvlist)
|
||||
{
|
||||
Q_UNUSED(pvlist);
|
||||
mainLayout = new QVBoxLayout(this);
|
||||
|
@ -54,8 +57,6 @@ VolumeDialog::VolumeDialog(QWidget* parent, QString& vgname, QList<Partition*>&
|
|||
updateOkButtonStatus();
|
||||
cancelButton->setFocus();
|
||||
cancelButton->setDefault(true);
|
||||
connect(dialogButtonBox, &QDialogButtonBox::accepted, this, &VolumeDialog::accept);
|
||||
connect(dialogButtonBox, &QDialogButtonBox::rejected, this, &VolumeDialog::reject);
|
||||
|
||||
setupDialog();
|
||||
setupConstraints();
|
||||
|
@ -71,13 +72,23 @@ VolumeDialog::~VolumeDialog()
|
|||
|
||||
void VolumeDialog::setupDialog()
|
||||
{
|
||||
dialogWidget().vgName().text() = originalName();
|
||||
dialogWidget().vgName().text() = targetName();
|
||||
|
||||
dialogWidget().volumeType().addItem(QStringLiteral("LVM"));
|
||||
dialogWidget().volumeType().addItem(QStringLiteral("RAID"));
|
||||
dialogWidget().volumeType().setCurrentIndex(0);
|
||||
|
||||
setMinimumSize(dialogWidget().size());
|
||||
resize(dialogWidget().size());
|
||||
|
||||
updatePartTable();
|
||||
}
|
||||
|
||||
void VolumeDialog::setupConnections()
|
||||
{
|
||||
connect(dialogButtonBox, &QDialogButtonBox::accepted, this, &VolumeDialog::accept);
|
||||
connect(dialogButtonBox, &QDialogButtonBox::rejected, this, &VolumeDialog::reject);
|
||||
connect(&dialogWidget().volumeType(), static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &VolumeDialog::onVolumeTypeChanged);
|
||||
}
|
||||
|
||||
void VolumeDialog::setupConstraints()
|
||||
|
@ -106,6 +117,16 @@ void VolumeDialog::updateSizeInfos()
|
|||
{
|
||||
}
|
||||
|
||||
void VolumeDialog::updatePartitionList()
|
||||
{
|
||||
}
|
||||
|
||||
void VolumeDialog::onPartitionListChanged()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void VolumeDialog::onVolumeTypeChanged(int index)
|
||||
{
|
||||
updatePartitionList();
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class VolumeDialog : public QDialog
|
|||
Q_DISABLE_COPY(VolumeDialog)
|
||||
|
||||
public:
|
||||
VolumeDialog(QWidget* parent, QString& vgname, QList<Partition*>& pvlist);
|
||||
VolumeDialog(QWidget* parent, QString& vgname, QStringList& pvlist);
|
||||
~VolumeDialog();
|
||||
|
||||
protected:
|
||||
|
@ -46,6 +46,9 @@ protected:
|
|||
virtual void updateOkButtonStatus();
|
||||
virtual void updatePartTable();
|
||||
virtual void updateSizeInfos();
|
||||
virtual void updatePartitionList();
|
||||
|
||||
virtual void onVolumeTypeChanged(int index);
|
||||
|
||||
VolumeWidget& dialogWidget() {
|
||||
Q_ASSERT(m_DialogWidget);
|
||||
|
@ -56,8 +59,20 @@ protected:
|
|||
return *m_DialogWidget;
|
||||
}
|
||||
|
||||
const QString originalName() const {
|
||||
return m_OriginalName;
|
||||
QString& targetName() {
|
||||
return m_TargetName;
|
||||
}
|
||||
|
||||
const QString& targetName() const {
|
||||
return m_TargetName;
|
||||
}
|
||||
|
||||
QStringList& targetPVList() {
|
||||
return m_TargetPVList;
|
||||
}
|
||||
|
||||
const QStringList& targetPVList() const {
|
||||
return m_TargetPVList;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -65,7 +80,8 @@ protected:
|
|||
|
||||
protected:
|
||||
VolumeWidget* m_DialogWidget;
|
||||
QString m_OriginalName;
|
||||
QString& m_TargetName;
|
||||
QStringList& m_TargetPVList;
|
||||
|
||||
QDialogButtonBox* dialogButtonBox;
|
||||
QPushButton* okButton;
|
||||
|
|
Loading…
Reference in New Issue