Convert pvList to std::vector.
We do not need to insert elements at arbitrary locations, so vector should be sufficient. Postpone changes in kpmcore till later to avoid breaking API.
This commit is contained in:
parent
6889a3b17c
commit
e3c14dbbb4
|
@ -30,7 +30,7 @@
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
|
|
||||||
CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& partList, qint32& peSize, QList<Device*> devices)
|
CreateVolumeGroupDialog::CreateVolumeGroupDialog(QWidget* parent, QString& vgName, std::vector<const Partition*>& partList, qint32& peSize, QList<Device*> devices)
|
||||||
: VolumeGroupDialog(parent, vgName, partList)
|
: VolumeGroupDialog(parent, vgName, partList)
|
||||||
, m_PESize(peSize)
|
, m_PESize(peSize)
|
||||||
, m_Devices(devices)
|
, m_Devices(devices)
|
||||||
|
@ -66,7 +66,7 @@ void CreateVolumeGroupDialog::accept()
|
||||||
QString& tname = targetName();
|
QString& tname = targetName();
|
||||||
tname = dialogWidget().vgName().text();
|
tname = dialogWidget().vgName().text();
|
||||||
|
|
||||||
targetPVList() << dialogWidget().listPV().checkedItems();
|
targetPVList().insert(targetPVList().end(), dialogWidget().listPV().checkedItems().begin(), dialogWidget().listPV().checkedItems().end());
|
||||||
|
|
||||||
qint32& pesize = peSize();
|
qint32& pesize = peSize();
|
||||||
pesize = dialogWidget().spinPESize().value();
|
pesize = dialogWidget().spinPESize().value();
|
||||||
|
|
|
@ -31,7 +31,7 @@ class CreateVolumeGroupDialog : public VolumeGroupDialog
|
||||||
Q_DISABLE_COPY(CreateVolumeGroupDialog)
|
Q_DISABLE_COPY(CreateVolumeGroupDialog)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CreateVolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& pvList, qint32& peSize, QList<Device*> devices);
|
CreateVolumeGroupDialog(QWidget* parent, QString& vgName, std::vector<const Partition*>& pvList, qint32& peSize, QList<Device*> devices);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#include <util/globallog.h>
|
#include <util/globallog.h>
|
||||||
#include <util/capacity.h>
|
#include <util/capacity.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ListPhysicalVolumes::ListPhysicalVolumes(QWidget* parent) :
|
ListPhysicalVolumes::ListPhysicalVolumes(QWidget* parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
Ui::ListPhysicalVolumesBase()
|
Ui::ListPhysicalVolumesBase()
|
||||||
|
@ -37,13 +35,13 @@ void ListPhysicalVolumes::addPartition(const Partition& p, bool checked)
|
||||||
listPhysicalVolumes().addItem(item);
|
listPhysicalVolumes().addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<const Partition *> ListPhysicalVolumes::checkedItems()
|
std::vector<const Partition *> ListPhysicalVolumes::checkedItems()
|
||||||
{
|
{
|
||||||
QList<const Partition *> partitionList;
|
std::vector<const Partition *> partitionList;
|
||||||
for (int i = 0; i < listPhysicalVolumes().count(); i++) {
|
for (int i = 0; i < listPhysicalVolumes().count(); i++) {
|
||||||
ListPhysicalVolumeWidgetItem* item = dynamic_cast<ListPhysicalVolumeWidgetItem*>(listPhysicalVolumes().item(i));
|
ListPhysicalVolumeWidgetItem* item = dynamic_cast<ListPhysicalVolumeWidgetItem*>(listPhysicalVolumes().item(i));
|
||||||
if(item && item->checkState() == Qt::Checked)
|
if(item && item->checkState() == Qt::Checked)
|
||||||
partitionList.append(item->partition());
|
partitionList.push_back(item->partition());
|
||||||
}
|
}
|
||||||
return partitionList;
|
return partitionList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include <core/partition.h>
|
#include <core/partition.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
|
@ -48,7 +50,7 @@ public:
|
||||||
|
|
||||||
void addPartition(const Partition& p, bool checked);
|
void addPartition(const Partition& p, bool checked);
|
||||||
|
|
||||||
QList<const Partition *> checkedItems();
|
std::vector<const Partition *> checkedItems();
|
||||||
|
|
||||||
QListWidget& listPhysicalVolumes() {
|
QListWidget& listPhysicalVolumes() {
|
||||||
Q_ASSERT(m_ListPhysicalVolumes);
|
Q_ASSERT(m_ListPhysicalVolumes);
|
||||||
|
|
|
@ -1101,12 +1101,12 @@ void MainWindow::onExportPartitionTable()
|
||||||
void MainWindow::onCreateNewVolumeGroup()
|
void MainWindow::onCreateNewVolumeGroup()
|
||||||
{
|
{
|
||||||
QString vgName;
|
QString vgName;
|
||||||
QList<const Partition*> pvList;
|
std::vector<const Partition*> pvList;
|
||||||
qint32 peSize = 4;
|
qint32 peSize = 4;
|
||||||
// *NOTE*: vgName & pvList will be modified and validated by the dialog
|
// *NOTE*: vgName & pvList will be modified and validated by the dialog
|
||||||
QPointer<CreateVolumeGroupDialog> dlg = new CreateVolumeGroupDialog(this, vgName, pvList, peSize, operationStack().previewDevices());
|
QPointer<CreateVolumeGroupDialog> dlg = new CreateVolumeGroupDialog(this, vgName, pvList, peSize, operationStack().previewDevices());
|
||||||
if (dlg->exec() == QDialog::Accepted)
|
if (dlg->exec() == QDialog::Accepted)
|
||||||
operationStack().push(new CreateVolumeGroupOperation(vgName, pvList, peSize));
|
operationStack().push(new CreateVolumeGroupOperation(vgName, QList<const Partition*>::fromVector(QVector<const Partition*>::fromStdVector(pvList)), peSize));
|
||||||
|
|
||||||
delete dlg;
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
@ -1116,12 +1116,12 @@ void MainWindow::onResizeVolumeGroup()
|
||||||
if (pmWidget().selectedDevice()->type() == Device::LVM_Device) {
|
if (pmWidget().selectedDevice()->type() == Device::LVM_Device) {
|
||||||
LvmDevice* d = dynamic_cast<LvmDevice*>(pmWidget().selectedDevice());
|
LvmDevice* d = dynamic_cast<LvmDevice*>(pmWidget().selectedDevice());
|
||||||
|
|
||||||
QList<const Partition*> pvList;
|
std::vector<const Partition*> pvList;
|
||||||
// *NOTE*: pvList will be modified and validated by the dialog
|
// *NOTE*: pvList will be modified and validated by the dialog
|
||||||
|
|
||||||
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList);
|
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList);
|
||||||
if (dlg->exec() == QDialog::Accepted)
|
if (dlg->exec() == QDialog::Accepted)
|
||||||
operationStack().push(new ResizeVolumeGroupOperation(*d, pvList));
|
operationStack().push(new ResizeVolumeGroupOperation(*d, QList<const Partition*>::fromVector(QVector<const Partition*>::fromStdVector(pvList))));
|
||||||
|
|
||||||
delete dlg;
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
@param parent pointer to the parent widget
|
@param parent pointer to the parent widget
|
||||||
@param d the Device to show properties for
|
@param d the Device to show properties for
|
||||||
*/
|
*/
|
||||||
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, QList<const Partition*>& partList)
|
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice* d, std::vector<const Partition*>& partList)
|
||||||
: VolumeGroupDialog(parent, d->name(), partList)
|
: VolumeGroupDialog(parent, d->name(), partList)
|
||||||
, m_Device(d)
|
, m_Device(d)
|
||||||
{
|
{
|
||||||
|
@ -83,6 +83,6 @@ void ResizeVolumeGroupDialog::setupConstraints()
|
||||||
|
|
||||||
void ResizeVolumeGroupDialog::accept()
|
void ResizeVolumeGroupDialog::accept()
|
||||||
{
|
{
|
||||||
targetPVList() << dialogWidget().listPV().checkedItems();
|
targetPVList().insert(targetPVList().end(), dialogWidget().listPV().checkedItems().begin(), dialogWidget().listPV().checkedItems().end());
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ResizeVolumeGroupDialog : public VolumeGroupDialog
|
||||||
Q_DISABLE_COPY(ResizeVolumeGroupDialog)
|
Q_DISABLE_COPY(ResizeVolumeGroupDialog)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QList<const Partition*>& partList);
|
ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, std::vector<const Partition*>& partList);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "gui/treelog.h"
|
#include "gui/treelog.h"
|
||||||
|
|
||||||
#include "gui/partitionmanagerwidget.h"
|
#include "gui/partitionmanagerwidget.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <util/globallog.h>
|
#include <util/globallog.h>
|
||||||
#include <util/helpers.h>
|
#include <util/helpers.h>
|
||||||
|
@ -38,8 +38,6 @@
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KMessageBox>
|
#include <KMessageBox>
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
/** Creates a new TreeLog instance.
|
/** Creates a new TreeLog instance.
|
||||||
@param parent the parent widget
|
@param parent the parent widget
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
@param vgName Volume Group name
|
@param vgName Volume Group name
|
||||||
@param pvList List of LVM Physical Volumes used to create Volume Group
|
@param pvList List of LVM Physical Volumes used to create Volume Group
|
||||||
*/
|
*/
|
||||||
VolumeGroupDialog::VolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& pvList) :
|
VolumeGroupDialog::VolumeGroupDialog(QWidget* parent, QString& vgName, std::vector<const Partition*>& pvList) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
m_DialogWidget(new VolumeGroupWidget(this)),
|
m_DialogWidget(new VolumeGroupWidget(this)),
|
||||||
m_TargetName(vgName),
|
m_TargetName(vgName),
|
||||||
|
@ -131,7 +131,7 @@ void VolumeGroupDialog::updateSectorInfos()
|
||||||
|
|
||||||
void VolumeGroupDialog::updateSizeInfos()
|
void VolumeGroupDialog::updateSizeInfos()
|
||||||
{
|
{
|
||||||
const QList <const Partition *> checkedPartitions = dialogWidget().listPV().checkedItems();
|
const std::vector<const Partition *> checkedPartitions = dialogWidget().listPV().checkedItems();
|
||||||
m_TotalSize = 0;
|
m_TotalSize = 0;
|
||||||
for (const auto &p : checkedPartitions)
|
for (const auto &p : checkedPartitions)
|
||||||
m_TotalSize += p->capacity() - p->capacity() % (dialogWidget().spinPESize().value() * Capacity::unitFactor(Capacity::Byte, Capacity::MiB)); // subtract space which is too small to hold PE
|
m_TotalSize += p->capacity() - p->capacity() % (dialogWidget().spinPESize().value() * Capacity::unitFactor(Capacity::Byte, Capacity::MiB)); // subtract space which is too small to hold PE
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#define VOLUMEGROUPDIALOG__H
|
#define VOLUMEGROUPDIALOG__H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -33,7 +35,7 @@ class VolumeGroupDialog : public QDialog
|
||||||
Q_DISABLE_COPY(VolumeGroupDialog)
|
Q_DISABLE_COPY(VolumeGroupDialog)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& pvList);
|
VolumeGroupDialog(QWidget* parent, QString& vgName, std::vector<const Partition*>& pvList);
|
||||||
~VolumeGroupDialog();
|
~VolumeGroupDialog();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -65,11 +67,11 @@ protected:
|
||||||
return m_TargetName;
|
return m_TargetName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<const Partition*>& targetPVList() {
|
std::vector<const Partition*>& targetPVList() {
|
||||||
return m_TargetPVList;
|
return m_TargetPVList;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<const Partition*>& targetPVList() const {
|
const std::vector<const Partition*>& targetPVList() const {
|
||||||
return m_TargetPVList;
|
return m_TargetPVList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ protected:
|
||||||
protected:
|
protected:
|
||||||
VolumeGroupWidget* m_DialogWidget;
|
VolumeGroupWidget* m_DialogWidget;
|
||||||
QString& m_TargetName;
|
QString& m_TargetName;
|
||||||
QList<const Partition*>& m_TargetPVList;
|
std::vector<const Partition*>& m_TargetPVList;
|
||||||
bool m_IsValidSize;
|
bool m_IsValidSize;
|
||||||
bool m_IsValidName;
|
bool m_IsValidName;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue