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 <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)
|
||||
, m_PESize(peSize)
|
||||
, m_Devices(devices)
|
||||
|
@ -66,7 +66,7 @@ void CreateVolumeGroupDialog::accept()
|
|||
QString& tname = targetName();
|
||||
tname = dialogWidget().vgName().text();
|
||||
|
||||
targetPVList() << dialogWidget().listPV().checkedItems();
|
||||
targetPVList().insert(targetPVList().end(), dialogWidget().listPV().checkedItems().begin(), dialogWidget().listPV().checkedItems().end());
|
||||
|
||||
qint32& pesize = peSize();
|
||||
pesize = dialogWidget().spinPESize().value();
|
||||
|
|
|
@ -31,7 +31,7 @@ class CreateVolumeGroupDialog : public VolumeGroupDialog
|
|||
Q_DISABLE_COPY(CreateVolumeGroupDialog)
|
||||
|
||||
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:
|
||||
void accept() override;
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
#include <util/globallog.h>
|
||||
#include <util/capacity.h>
|
||||
|
||||
|
||||
|
||||
ListPhysicalVolumes::ListPhysicalVolumes(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
Ui::ListPhysicalVolumesBase()
|
||||
|
@ -37,13 +35,13 @@ void ListPhysicalVolumes::addPartition(const Partition& p, bool checked)
|
|||
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++) {
|
||||
ListPhysicalVolumeWidgetItem* item = dynamic_cast<ListPhysicalVolumeWidgetItem*>(listPhysicalVolumes().item(i));
|
||||
if(item && item->checkState() == Qt::Checked)
|
||||
partitionList.append(item->partition());
|
||||
partitionList.push_back(item->partition());
|
||||
}
|
||||
return partitionList;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include <core/partition.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class Device;
|
||||
|
@ -48,7 +50,7 @@ public:
|
|||
|
||||
void addPartition(const Partition& p, bool checked);
|
||||
|
||||
QList<const Partition *> checkedItems();
|
||||
std::vector<const Partition *> checkedItems();
|
||||
|
||||
QListWidget& listPhysicalVolumes() {
|
||||
Q_ASSERT(m_ListPhysicalVolumes);
|
||||
|
|
|
@ -1101,12 +1101,12 @@ void MainWindow::onExportPartitionTable()
|
|||
void MainWindow::onCreateNewVolumeGroup()
|
||||
{
|
||||
QString vgName;
|
||||
QList<const Partition*> pvList;
|
||||
std::vector<const Partition*> pvList;
|
||||
qint32 peSize = 4;
|
||||
// *NOTE*: vgName & pvList will be modified and validated by the dialog
|
||||
QPointer<CreateVolumeGroupDialog> dlg = new CreateVolumeGroupDialog(this, vgName, pvList, peSize, operationStack().previewDevices());
|
||||
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;
|
||||
}
|
||||
|
@ -1116,12 +1116,12 @@ void MainWindow::onResizeVolumeGroup()
|
|||
if (pmWidget().selectedDevice()->type() == Device::LVM_Device) {
|
||||
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
|
||||
|
||||
QPointer<ResizeVolumeGroupDialog> dlg = new ResizeVolumeGroupDialog(this, d, pvList);
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
@param parent pointer to the parent widget
|
||||
@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)
|
||||
, m_Device(d)
|
||||
{
|
||||
|
@ -83,6 +83,6 @@ void ResizeVolumeGroupDialog::setupConstraints()
|
|||
|
||||
void ResizeVolumeGroupDialog::accept()
|
||||
{
|
||||
targetPVList() << dialogWidget().listPV().checkedItems();
|
||||
targetPVList().insert(targetPVList().end(), dialogWidget().listPV().checkedItems().begin(), dialogWidget().listPV().checkedItems().end());
|
||||
QDialog::accept();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class ResizeVolumeGroupDialog : public VolumeGroupDialog
|
|||
Q_DISABLE_COPY(ResizeVolumeGroupDialog)
|
||||
|
||||
public:
|
||||
ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, QList<const Partition*>& partList);
|
||||
ResizeVolumeGroupDialog(QWidget* parent, VolumeManagerDevice *d, std::vector<const Partition*>& partList);
|
||||
|
||||
protected:
|
||||
void accept() override;
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "gui/treelog.h"
|
||||
|
||||
#include "gui/partitionmanagerwidget.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <util/globallog.h>
|
||||
#include <util/helpers.h>
|
||||
|
@ -38,8 +38,6 @@
|
|||
#include <KLocalizedString>
|
||||
#include <KMessageBox>
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/** Creates a new TreeLog instance.
|
||||
@param parent the parent widget
|
||||
*/
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
@param vgName Volume Group name
|
||||
@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),
|
||||
m_DialogWidget(new VolumeGroupWidget(this)),
|
||||
m_TargetName(vgName),
|
||||
|
@ -131,7 +131,7 @@ void VolumeGroupDialog::updateSectorInfos()
|
|||
|
||||
void VolumeGroupDialog::updateSizeInfos()
|
||||
{
|
||||
const QList <const Partition *> checkedPartitions = dialogWidget().listPV().checkedItems();
|
||||
const std::vector<const Partition *> checkedPartitions = dialogWidget().listPV().checkedItems();
|
||||
m_TotalSize = 0;
|
||||
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
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#define VOLUMEGROUPDIALOG__H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
@ -33,7 +35,7 @@ class VolumeGroupDialog : public QDialog
|
|||
Q_DISABLE_COPY(VolumeGroupDialog)
|
||||
|
||||
public:
|
||||
VolumeGroupDialog(QWidget* parent, QString& vgName, QList<const Partition*>& pvList);
|
||||
VolumeGroupDialog(QWidget* parent, QString& vgName, std::vector<const Partition*>& pvList);
|
||||
~VolumeGroupDialog();
|
||||
|
||||
protected:
|
||||
|
@ -65,11 +67,11 @@ protected:
|
|||
return m_TargetName;
|
||||
}
|
||||
|
||||
QList<const Partition*>& targetPVList() {
|
||||
std::vector<const Partition*>& targetPVList() {
|
||||
return m_TargetPVList;
|
||||
}
|
||||
|
||||
const QList<const Partition*>& targetPVList() const {
|
||||
const std::vector<const Partition*>& targetPVList() const {
|
||||
return m_TargetPVList;
|
||||
}
|
||||
|
||||
|
@ -87,7 +89,7 @@ protected:
|
|||
protected:
|
||||
VolumeGroupWidget* m_DialogWidget;
|
||||
QString& m_TargetName;
|
||||
QList<const Partition*>& m_TargetPVList;
|
||||
std::vector<const Partition*>& m_TargetPVList;
|
||||
bool m_IsValidSize;
|
||||
bool m_IsValidName;
|
||||
|
||||
|
|
Loading…
Reference in New Issue