Convert to C++11 for loop where it is safe (avoid detaching Qt objects).
This commit is contained in:
parent
9ed640084d
commit
a10c8d3aaa
|
@ -62,13 +62,13 @@ void DeviceScanner::scan()
|
|||
|
||||
clear();
|
||||
|
||||
QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices();
|
||||
QList<LvmDevice*> lvmList = LvmDevice::scanSystemLVM();
|
||||
const QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices();
|
||||
const QList<LvmDevice*> lvmList = LvmDevice::scanSystemLVM();
|
||||
|
||||
foreach(Device * d, deviceList)
|
||||
for (Device * d : deviceList)
|
||||
operationStack().addDevice(d);
|
||||
|
||||
foreach(Device * d, lvmList)
|
||||
for (Device * d : lvmList)
|
||||
operationStack().addDevice(d);
|
||||
|
||||
operationStack().sortDevices();
|
||||
|
|
|
@ -71,7 +71,7 @@ void LvmDevice::initPartitions()
|
|||
qint64 lastusable = totalPE() - 1;
|
||||
PartitionTable* pTable = new PartitionTable(PartitionTable::vmd, firstUsable, lastusable);
|
||||
|
||||
foreach (Partition* p, scanPartitions(pTable)) {
|
||||
for (Partition* p : scanPartitions(pTable)) {
|
||||
LVSizeMap()->insert(p->partitionPath(), p->length());
|
||||
pTable->append(p);
|
||||
}
|
||||
|
@ -84,10 +84,10 @@ void LvmDevice::initPartitions()
|
|||
/**
|
||||
* @return sorted Partition(LV) Array
|
||||
*/
|
||||
QList<Partition*> LvmDevice::scanPartitions(PartitionTable* pTable) const
|
||||
const QList<Partition*> LvmDevice::scanPartitions(PartitionTable* pTable) const
|
||||
{
|
||||
QList<Partition*> pList;
|
||||
foreach (QString lvPath, lvPathList()) {
|
||||
for (QString lvPath : lvPathList()) {
|
||||
pList.append(scanPartition(lvPath, pTable));
|
||||
}
|
||||
return pList;
|
||||
|
@ -184,7 +184,7 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl
|
|||
QList<LvmDevice*> LvmDevice::scanSystemLVM()
|
||||
{
|
||||
QList<LvmDevice*> lvmList;
|
||||
foreach (QString vgname, getVGs()) {
|
||||
for (QString vgname : getVGs()) {
|
||||
lvmList.append(new LvmDevice(vgname));
|
||||
}
|
||||
return lvmList;
|
||||
|
@ -205,23 +205,23 @@ qint64 LvmDevice::mappedSector(const QString& lvpath, qint64 sector) const
|
|||
return mSector;
|
||||
}
|
||||
|
||||
QStringList LvmDevice::deviceNodeList() const
|
||||
const QStringList LvmDevice::deviceNodeList() const
|
||||
{
|
||||
return *PVPathList();
|
||||
}
|
||||
|
||||
QStringList LvmDevice::lvPathList() const
|
||||
const QStringList LvmDevice::lvPathList() const
|
||||
{
|
||||
return *LVPathList();
|
||||
}
|
||||
|
||||
QStringList LvmDevice::getVGs()
|
||||
const QStringList LvmDevice::getVGs()
|
||||
{
|
||||
QStringList vgList;
|
||||
QString output = getField(QStringLiteral("vg_name"));
|
||||
if (!output.isEmpty()) {
|
||||
QStringList vgnameList = output.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
foreach(QString vgname, vgnameList) {
|
||||
const QStringList vgnameList = output.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
for (QString vgname : vgnameList) {
|
||||
vgList.append(vgname.trimmed());
|
||||
}
|
||||
}
|
||||
|
@ -234,8 +234,8 @@ QStringList LvmDevice::getPVs(const QString& vgname)
|
|||
QString cmdOutput = getField(QStringLiteral("pv_name"), vgname);
|
||||
|
||||
if (cmdOutput.size()) {
|
||||
QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
foreach(QString devPath, tempPathList) {
|
||||
const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
for (QString devPath : tempPathList) {
|
||||
devPathList.append(devPath.trimmed());
|
||||
}
|
||||
}
|
||||
|
@ -248,8 +248,8 @@ QStringList LvmDevice::getLVs(const QString& vgname)
|
|||
QString cmdOutput = getField(QStringLiteral("lv_path"), vgname);
|
||||
|
||||
if (cmdOutput.size()) {
|
||||
QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
foreach(QString lvPath, tempPathList) {
|
||||
const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
for (QString lvPath : tempPathList) {
|
||||
lvPathList.append(lvPath.trimmed());
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ bool LvmDevice::movePV(Report& report, LvmDevice& dev, const QString& pvPath, co
|
|||
args << QStringLiteral("pvmove");
|
||||
args << pvPath;
|
||||
if (!destinations.isEmpty()) {
|
||||
foreach (QString destPath, destinations) {
|
||||
for (QString destPath : destinations) {
|
||||
args << destPath.trimmed();
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ bool LvmDevice::createVG(Report& report, const QString vgname, const QStringList
|
|||
QStringList args = QStringList();
|
||||
args << QStringLiteral("vgcreate") << QStringLiteral("--physicalextentsize") << QString::number(peSize);
|
||||
args << vgname;
|
||||
foreach (QString pvnode, pvlist) {
|
||||
for (QString pvnode : pvlist) {
|
||||
args << pvnode.trimmed();
|
||||
}
|
||||
ExternalCommand cmd(report, QStringLiteral("lvm"), args);
|
||||
|
@ -464,7 +464,7 @@ bool LvmDevice::deactivateVG(Report& report, const LvmDevice& dev)
|
|||
return deactivate.run(-1) && deactivate.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool LvmDevice::deactivateLV(Report& report, LvmDevice& dev, Partition& part)
|
||||
bool LvmDevice::deactivateLV(Report& report, const LvmDevice& dev, const Partition& part)
|
||||
{
|
||||
Q_UNUSED(dev);
|
||||
ExternalCommand deactivate(report, QStringLiteral("lvm"),
|
||||
|
|
|
@ -49,10 +49,10 @@ public:
|
|||
~LvmDevice();
|
||||
|
||||
public:
|
||||
QList<Partition*> scanPartitions(PartitionTable* pTable) const;
|
||||
const QList<Partition*> scanPartitions(PartitionTable* pTable) const;
|
||||
Partition* scanPartition(const QString& lvPath, PartitionTable* pTable) const;
|
||||
QStringList deviceNodeList() const override;
|
||||
QStringList lvPathList() const;
|
||||
const QStringList deviceNodeList() const override;
|
||||
const QStringList lvPathList() const;
|
||||
static QStringList s_DirtyPVs;
|
||||
|
||||
public:
|
||||
|
@ -69,13 +69,13 @@ public:
|
|||
|
||||
static QStringList getPVs(const QString& vgname);
|
||||
static QStringList getLVs(const QString& vgname);
|
||||
static QStringList getVGs();
|
||||
static const QStringList getVGs();
|
||||
|
||||
static bool removeLV(Report& report, LvmDevice& dev, Partition& part);
|
||||
static bool createLV(Report& report, LvmDevice& dev, Partition& part, const QString& lvname);
|
||||
static bool createLVSnapshot(Report& report, LvmDevice& dev, Partition& lvpart, const QString& name, const qint64 extents = 0);
|
||||
static bool resizeLV(Report& report, LvmDevice& dev, Partition& part);
|
||||
static bool deactivateLV(Report& report, LvmDevice& dev, Partition& part);
|
||||
static bool deactivateLV(Report& report, const LvmDevice& dev, const Partition& part);
|
||||
static bool activateLV(Report& report, LvmDevice& dev, Partition& part);
|
||||
|
||||
static bool removePV(Report& report, LvmDevice& dev, const QString& pvPath);
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
static bool activateVG(Report& report, const LvmDevice& dev);
|
||||
|
||||
protected:
|
||||
void initPartitions();
|
||||
void initPartitions() override;
|
||||
qint64 mappedSector(const QString& lvpath, qint64 sector) const override;
|
||||
|
||||
public:
|
||||
|
@ -108,7 +108,7 @@ public:
|
|||
return m_UUID;
|
||||
}
|
||||
|
||||
QStringList* LVPathList() const {
|
||||
const QStringList* LVPathList() const {
|
||||
return m_LVPathList;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ qint32 OperationRunner::numJobs() const
|
|||
{
|
||||
qint32 result = 0;
|
||||
|
||||
foreach(const Operation * op, operationStack().operations())
|
||||
for (const Operation * op : operationStack().operations())
|
||||
result += op->jobs().size();
|
||||
|
||||
return result;
|
||||
|
|
|
@ -457,7 +457,7 @@ bool OperationStack::contains(const Partition* p) const
|
|||
{
|
||||
Q_ASSERT(p);
|
||||
|
||||
foreach(Operation * o, operations()) {
|
||||
for (Operation * o : operations()) {
|
||||
if (o->targets(*p))
|
||||
return true;
|
||||
|
||||
|
@ -511,9 +511,9 @@ Device* OperationStack::findDeviceForPartition(const Partition* p)
|
|||
if (part == p)
|
||||
return d;
|
||||
|
||||
foreach(const Partition * child, part->children())
|
||||
if (child == p)
|
||||
return d;
|
||||
for (const Partition * child : part->children())
|
||||
if (child == p)
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ Partition::Partition(const Partition& other) :
|
|||
m_State(other.m_State)
|
||||
{
|
||||
setPartitionPath(other.m_PartitionPath);
|
||||
foreach(const Partition * child, other.children()) {
|
||||
for (const Partition * child : other.children()) {
|
||||
Partition* p = new Partition(*child);
|
||||
p->setParent(this);
|
||||
m_Children.append(p);
|
||||
|
@ -121,7 +121,7 @@ Partition& Partition::operator=(const Partition& other)
|
|||
|
||||
clearChildren();
|
||||
|
||||
foreach(const Partition * child, other.children()) {
|
||||
for (const Partition * child : other.children()) {
|
||||
Partition* p = new Partition(*child);
|
||||
p->setParent(this);
|
||||
m_Children.append(p);
|
||||
|
@ -179,7 +179,7 @@ qint64 Partition::sectorsUsed() const
|
|||
return fileSystem().sectorsUsed();
|
||||
|
||||
qint64 result = 0;
|
||||
foreach(const Partition * p, children())
|
||||
for (const Partition * p : children())
|
||||
if (!p->roles().has(PartitionRole::Unallocated))
|
||||
result += p->length();
|
||||
|
||||
|
@ -230,7 +230,7 @@ qint64 Partition::maxFirstSector() const
|
|||
{
|
||||
qint64 rval = -1;
|
||||
|
||||
foreach(const Partition * child, children())
|
||||
for (const Partition * child : children())
|
||||
if (!child->roles().has(PartitionRole::Unallocated) && (child->firstSector() < rval || rval == -1))
|
||||
rval = child->firstSector();
|
||||
|
||||
|
@ -242,7 +242,7 @@ qint64 Partition::minLastSector() const
|
|||
{
|
||||
qint64 rval = -1;
|
||||
|
||||
foreach(const Partition * child, children())
|
||||
for (const Partition * child : children())
|
||||
if (!child->roles().has(PartitionRole::Unallocated) && child->lastSector() > rval)
|
||||
rval = child->lastSector();
|
||||
|
||||
|
@ -252,7 +252,7 @@ qint64 Partition::minLastSector() const
|
|||
/** @return true if the Partition has children */
|
||||
bool Partition::hasChildren() const
|
||||
{
|
||||
foreach(const Partition * child, children())
|
||||
for (const Partition * child : children())
|
||||
if (!child->roles().has(PartitionRole::Unallocated))
|
||||
return true;
|
||||
|
||||
|
@ -365,7 +365,7 @@ QTextStream& operator<<(QTextStream& stream, const Partition& p)
|
|||
{
|
||||
QStringList flagList;
|
||||
|
||||
foreach(const PartitionTable::Flag & f, PartitionTable::flagList()) {
|
||||
for (const PartitionTable::Flag & f : PartitionTable::flagList()) {
|
||||
if (p.activeFlags() & f)
|
||||
flagList.append(PartitionTable::flagName(f));
|
||||
}
|
||||
|
|
|
@ -142,8 +142,8 @@ Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& r
|
|||
foreach(Partition * p, children()) {
|
||||
// (women and) children first. ;-)
|
||||
foreach(Partition * child, p->children())
|
||||
if ((child->roles().roles() & role.roles()) && s >= child->firstSector() && s <= child->lastSector())
|
||||
return child;
|
||||
if ((child->roles().roles() & role.roles()) && s >= child->firstSector() && s <= child->lastSector())
|
||||
return child;
|
||||
|
||||
if ((p->roles().roles() & role.roles()) && s >= p->firstSector() && s <= p->lastSector())
|
||||
return p;
|
||||
|
@ -157,10 +157,10 @@ Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& r
|
|||
*/
|
||||
const Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& role) const
|
||||
{
|
||||
foreach(const Partition * p, children()) {
|
||||
foreach(const Partition * child, p->children())
|
||||
if ((child->roles().roles() & role.roles()) && s >= child->firstSector() && s <= child->lastSector())
|
||||
return child;
|
||||
for (const Partition * p : children()) {
|
||||
for (const Partition * child : p->children())
|
||||
if ((child->roles().roles() & role.roles()) && s >= child->firstSector() && s <= child->lastSector())
|
||||
return child;
|
||||
|
||||
if ((p->roles().roles() & role.roles()) && s >= p->firstSector() && s <= p->lastSector())
|
||||
return p;
|
||||
|
@ -190,9 +190,9 @@ qint32 PartitionNode::highestMountedChild() const
|
|||
{
|
||||
qint32 result = -1;
|
||||
|
||||
foreach(const Partition * p, children())
|
||||
if (p->number() > result && p->isMounted())
|
||||
result = p->number();
|
||||
for (const Partition * p : children())
|
||||
if (p->number() > result && p->isMounted())
|
||||
result = p->number();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -200,9 +200,9 @@ qint32 PartitionNode::highestMountedChild() const
|
|||
/** @return true if any of the partition's children are mounted */
|
||||
bool PartitionNode::isChildMounted() const
|
||||
{
|
||||
foreach(const Partition * child, children())
|
||||
if (child->isMounted() || (child->hasChildren() && child->isChildMounted()))
|
||||
return true;
|
||||
for (const Partition * child : children())
|
||||
if (child->isMounted() || (child->hasChildren() && child->isChildMounted()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -92,9 +92,10 @@ qint64 PartitionTable::freeSectorsAfter(const Partition& p) const
|
|||
qint64 PartitionTable::freeSectors() const
|
||||
{
|
||||
qint64 sectors = 0;
|
||||
foreach(const Partition * p, children())
|
||||
if (p->roles().has(PartitionRole::Unallocated)) {
|
||||
sectors += p->length();
|
||||
for (const Partition * p : children()) {
|
||||
if (p->roles().has(PartitionRole::Unallocated)) {
|
||||
sectors += p->length();
|
||||
}
|
||||
}
|
||||
|
||||
return sectors;
|
||||
|
@ -141,7 +142,7 @@ int PartitionTable::numPrimaries() const
|
|||
{
|
||||
int result = 0;
|
||||
|
||||
foreach(const Partition * p, children())
|
||||
for (const Partition * p : children())
|
||||
if (p->roles().has(PartitionRole::Primary) || p->roles().has(PartitionRole::Extended))
|
||||
result++;
|
||||
|
||||
|
@ -206,7 +207,7 @@ QString PartitionTable::flagName(Flag f)
|
|||
}
|
||||
|
||||
/** @return list of all flags */
|
||||
QList<PartitionTable::Flag> PartitionTable::flagList()
|
||||
const QList<PartitionTable::Flag> PartitionTable::flagList()
|
||||
{
|
||||
QList<PartitionTable::Flag> rval;
|
||||
|
||||
|
@ -359,7 +360,7 @@ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64
|
|||
if (d.type() == Device::LVM_Device && !p->children().isEmpty()) {
|
||||
// rearranging all the partitions sector to keep all the unallocated space at the end
|
||||
lastEnd = 0;
|
||||
foreach (Partition* child, children()) {
|
||||
for (Partition* child : children()) {
|
||||
qint64 totalSector = child->length();
|
||||
child->setFirstSector(lastEnd);
|
||||
child->setLastSector(lastEnd + totalSector - 1);
|
||||
|
@ -505,11 +506,12 @@ bool PartitionTable::isSectorBased(const Device& d) const
|
|||
|
||||
// see if we have more cylinder aligned partitions than sector
|
||||
// aligned ones.
|
||||
foreach(const Partition * p, children())
|
||||
if (p->firstSector() % PartitionAlignment::sectorAlignment(diskDevice) == 0)
|
||||
numSectorAligned++;
|
||||
else if (p->firstSector() % diskDevice.cylinderSize() == 0)
|
||||
numCylinderAligned++;
|
||||
for (const Partition * p : children()) {
|
||||
if (p->firstSector() % PartitionAlignment::sectorAlignment(diskDevice) == 0)
|
||||
numSectorAligned++;
|
||||
else if (p->firstSector() % diskDevice.cylinderSize() == 0)
|
||||
numCylinderAligned++;
|
||||
}
|
||||
|
||||
return numSectorAligned >= numCylinderAligned;
|
||||
}
|
||||
|
@ -542,15 +544,17 @@ QTextStream& operator<<(QTextStream& stream, const PartitionTable& ptable)
|
|||
|
||||
QList<const Partition*> partitions;
|
||||
|
||||
foreach(const Partition * p, ptable.children())
|
||||
for (const Partition * p : ptable.children()) {
|
||||
if (!p->roles().has(PartitionRole::Unallocated)) {
|
||||
partitions.append(p);
|
||||
|
||||
if (p->roles().has(PartitionRole::Extended))
|
||||
foreach(const Partition * child, p->children())
|
||||
if (!child->roles().has(PartitionRole::Unallocated))
|
||||
partitions.append(child);
|
||||
for (const Partition * child : p->children()) {
|
||||
if (!child->roles().has(PartitionRole::Unallocated))
|
||||
partitions.append(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qSort(partitions.begin(), partitions.end(), isPartitionLessThan);
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ public:
|
|||
|
||||
bool isSectorBased(const Device& d) const;
|
||||
|
||||
static QList<Flag> flagList();
|
||||
static const QList<Flag> flagList();
|
||||
static QString flagName(Flag f);
|
||||
static QStringList flagNames(Flags f);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ VolumeManagerDevice::VolumeManagerDevice(const QString& name,
|
|||
QString VolumeManagerDevice::prettyDeviceNodeList() const
|
||||
{
|
||||
QString rval;
|
||||
foreach (QString devNode, deviceNodeList()) {
|
||||
for (QString devNode : deviceNodeList()) {
|
||||
rval += devNode + QStringLiteral(",");
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class LIBKPMCORE_EXPORT VolumeManagerDevice : public Device
|
|||
public:
|
||||
VolumeManagerDevice(const QString& name, const QString& devicenode, const qint32 logicalSize, const qint64 totalLogical, const QString& iconname = QString(), Device::Type type = Device::Unknown_Device);
|
||||
virtual void initPartitions() = 0;
|
||||
virtual QStringList deviceNodeList() const = 0; /** Return list of physical device or partitions that makes up volumeManagerDevice */
|
||||
virtual const QStringList deviceNodeList() const = 0; /** Return list of physical device or partitions that makes up volumeManagerDevice */
|
||||
virtual qint64 mappedSector(const QString& devNode, qint64 sector) const = 0;
|
||||
|
||||
public:
|
||||
|
|
|
@ -84,7 +84,7 @@ void FileSystemFactory::init()
|
|||
m_FileSystems.insert(FileSystem::Xfs, new FS::xfs(-1, -1, -1, QString()));
|
||||
m_FileSystems.insert(FileSystem::Zfs, new FS::zfs(-1, -1, -1, QString()));
|
||||
|
||||
foreach(FileSystem * fs, FileSystemFactory::map()) {
|
||||
for (FileSystem * fs : FileSystemFactory::map()) {
|
||||
fs->init();
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ qint64 lvm2_pv::getTotalPE(const QString& deviceNode)
|
|||
qint64 lvm2_pv::getTotalPE(const QStringList& deviceNodeList)
|
||||
{
|
||||
qint64 sum = 0;
|
||||
foreach (QString deviceNode, deviceNodeList) {
|
||||
for (QString deviceNode : deviceNodeList) {
|
||||
qint64 totalPE = getTotalPE(deviceNode);
|
||||
if (totalPE < 0) {
|
||||
sum = -1;
|
||||
|
@ -224,7 +224,7 @@ qint64 lvm2_pv::getFreePE(const QString& deviceNode)
|
|||
qint64 lvm2_pv::getFreePE(const QStringList& deviceNodeList)
|
||||
{
|
||||
qint64 sum = 0;
|
||||
foreach (QString deviceNode, deviceNodeList) {
|
||||
for (QString deviceNode :deviceNodeList) {
|
||||
qint64 freePE = getFreePE(deviceNode);
|
||||
if (freePE < 0) {
|
||||
sum = -1;
|
||||
|
@ -244,7 +244,7 @@ qint64 lvm2_pv::getAllocatedPE(const QString& deviceNode)
|
|||
qint64 lvm2_pv::getAllocatedPE(const QStringList& deviceNodeList)
|
||||
{
|
||||
qint64 sum = 0;
|
||||
foreach (QString deviceNode, deviceNodeList) {
|
||||
for (QString deviceNode : deviceNodeList) {
|
||||
qint64 allocatedPE = getAllocatedPE(deviceNode);
|
||||
if (allocatedPE < 0) {
|
||||
sum = -1;
|
||||
|
@ -264,7 +264,7 @@ qint64 lvm2_pv::getPVSize(const QString& deviceNode)
|
|||
qint64 lvm2_pv::getPVSize(const QStringList& deviceNodeList)
|
||||
{
|
||||
qint64 sum = 0;
|
||||
foreach (QString deviceNode, deviceNodeList) {
|
||||
for (QString deviceNode : deviceNodeList) {
|
||||
qint64 pvsize = getPVSize(deviceNode);
|
||||
if (pvsize < 0) {
|
||||
sum = -1;
|
||||
|
@ -312,8 +312,8 @@ QStringList lvm2_pv::getFreePV()
|
|||
QStringList rlist;
|
||||
|
||||
QString output = getpvField(QStringLiteral("pv_name"));
|
||||
QStringList pvList = output.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
foreach (QString pvnode, pvList) {
|
||||
const QStringList pvList = output.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
for (QString pvnode : pvList) {
|
||||
if (!isUsed(pvnode.trimmed())) {
|
||||
rlist.append(pvnode.trimmed());
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ void PartWidget::updateChildren()
|
|||
w->setParent(nullptr);
|
||||
}
|
||||
|
||||
foreach(const Partition * child, partition()->children()) {
|
||||
for (const Partition * child : partition()->children()) {
|
||||
QWidget* w = new PartWidget(this, child);
|
||||
w->setVisible(true);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ template<typename T>
|
|||
T sum(const QList<T>& list)
|
||||
{
|
||||
T rval = 0;
|
||||
foreach(const T & val, list)
|
||||
for (const T & val : list)
|
||||
rval += val;
|
||||
return rval;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ void PartWidgetBase::positionChildren(const QWidget* destWidget, const Partition
|
|||
return;
|
||||
|
||||
qint64 totalLength = 0;
|
||||
foreach(const Partition * p, partitions)
|
||||
for (const Partition * p : partitions)
|
||||
totalLength += p->length();
|
||||
|
||||
if (totalLength < 1)
|
||||
|
@ -146,7 +146,7 @@ QList<PartWidget*> PartWidgetBase::childWidgets()
|
|||
{
|
||||
QList<PartWidget*> rval;
|
||||
|
||||
foreach(QObject * o, children())
|
||||
for (QObject * o : children())
|
||||
if (PartWidget* w = qobject_cast<PartWidget*>(o))
|
||||
rval.append(w);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ bool CreateVolumeGroupJob::run(Report& parent)
|
|||
QString CreateVolumeGroupJob::description() const
|
||||
{
|
||||
QString tmp = QString();
|
||||
foreach(QString name, pvList()) {
|
||||
for (const QString name : pvList()) {
|
||||
tmp += QStringLiteral("\n") + name;
|
||||
}
|
||||
return xi18nc("@info/plain", "Create new Volume Group: <filename>%1</filename> with PV: %2", vgName(), tmp);
|
||||
|
|
|
@ -26,10 +26,8 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new DeactivateLogicalVolumeJob
|
||||
@param vgname
|
||||
@parem pvList
|
||||
*/
|
||||
DeactivateLogicalVolumeJob::DeactivateLogicalVolumeJob(VolumeManagerDevice& dev, QStringList lvPaths) :
|
||||
DeactivateLogicalVolumeJob::DeactivateLogicalVolumeJob(const VolumeManagerDevice& dev, const QStringList lvPaths) :
|
||||
Job(),
|
||||
m_Device(dev),
|
||||
m_LVList(lvPaths)
|
||||
|
@ -43,9 +41,9 @@ bool DeactivateLogicalVolumeJob::run(Report& parent)
|
|||
Report* report = jobStarted(parent);
|
||||
|
||||
if (device().type() == Device::LVM_Device) {
|
||||
foreach (Partition* part, device().partitionTable()->children()) {
|
||||
for (const Partition* part : device().partitionTable()->children()) {
|
||||
if (!part->roles().has(PartitionRole::Unallocated)) {
|
||||
if (!LvmDevice::deactivateLV(*report, dynamic_cast<LvmDevice&>(device()), *part)) {
|
||||
if (!LvmDevice::deactivateLV(*report, dynamic_cast<const LvmDevice&>(device()), *part)) {
|
||||
rval = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,16 +30,13 @@ class QString;
|
|||
class DeactivateLogicalVolumeJob : public Job
|
||||
{
|
||||
public:
|
||||
DeactivateLogicalVolumeJob(VolumeManagerDevice& dev, QStringList lvPaths = {});
|
||||
DeactivateLogicalVolumeJob(const VolumeManagerDevice& dev, const QStringList lvPaths = {});
|
||||
|
||||
public:
|
||||
bool run(Report& parent) override;
|
||||
QString description() const override;
|
||||
|
||||
protected:
|
||||
VolumeManagerDevice& device() {
|
||||
return m_Device;
|
||||
}
|
||||
const VolumeManagerDevice& device() const {
|
||||
return m_Device;
|
||||
}
|
||||
|
@ -49,8 +46,8 @@ protected:
|
|||
}
|
||||
|
||||
private:
|
||||
VolumeManagerDevice& m_Device;
|
||||
QStringList m_LVList;
|
||||
const VolumeManagerDevice& m_Device;
|
||||
const QStringList m_LVList;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
/** Deactivate LVM Volume Group
|
||||
@param vgname
|
||||
@parem pvList
|
||||
*/
|
||||
DeactivateVolumeGroupJob::DeactivateVolumeGroupJob(VolumeManagerDevice& dev) :
|
||||
Job(),
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new MovePhysicalVolumeJob
|
||||
@param vgname
|
||||
@parem pvList
|
||||
*/
|
||||
MovePhysicalVolumeJob::MovePhysicalVolumeJob(LvmDevice& dev, const QStringList partlist) :
|
||||
Job(),
|
||||
|
@ -41,13 +39,13 @@ bool MovePhysicalVolumeJob::run(Report& parent)
|
|||
Report* report = jobStarted(parent);
|
||||
|
||||
QStringList destinations = LvmDevice::getPVs(device().name());
|
||||
foreach (QString partPath, partList()) {
|
||||
for (const QString partPath : partList()) {
|
||||
if (destinations.contains(partPath)) {
|
||||
destinations.removeAll(partPath);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (QString partPath, partList()) {
|
||||
for (const QString partPath : partList()) {
|
||||
rval = LvmDevice::movePV(*report, device(), partPath, destinations);
|
||||
if (rval == false) {
|
||||
break;
|
||||
|
@ -62,7 +60,7 @@ bool MovePhysicalVolumeJob::run(Report& parent)
|
|||
QString MovePhysicalVolumeJob::description() const
|
||||
{
|
||||
QString tmp = QString();
|
||||
foreach (QString path, partList()) {
|
||||
for (const QString path : partList()) {
|
||||
tmp += path + QStringLiteral(",");
|
||||
}
|
||||
return xi18nc("@info/plain", "Move used PE in %1 on %2 to other available Physical Volumes", tmp, device().name());
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new RemoveVolumeGroupJob
|
||||
@param vgname
|
||||
@parem pvList
|
||||
*/
|
||||
RemoveVolumeGroupJob::RemoveVolumeGroupJob(VolumeManagerDevice& dev) :
|
||||
Job(),
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new ResizeVolumeGroupJob
|
||||
@param vgname
|
||||
@parem pvList
|
||||
*/
|
||||
ResizeVolumeGroupJob::ResizeVolumeGroupJob(LvmDevice& dev, const QStringList partlist, const Type type) :
|
||||
Job(),
|
||||
|
@ -41,7 +39,7 @@ bool ResizeVolumeGroupJob::run(Report& parent)
|
|||
|
||||
Report* report = jobStarted(parent);
|
||||
|
||||
foreach (QString pvpath, partList()) {
|
||||
for (const QString pvpath : partList()) {
|
||||
if (type() == ResizeVolumeGroupJob::Grow) {
|
||||
rval = LvmDevice::insertPV(*report, device(), pvpath);
|
||||
} else if (type() == ResizeVolumeGroupJob::Shrink) {
|
||||
|
@ -60,7 +58,7 @@ bool ResizeVolumeGroupJob::run(Report& parent)
|
|||
QString ResizeVolumeGroupJob::description() const
|
||||
{
|
||||
QString tmp = QString();
|
||||
foreach (QString path, partList()) {
|
||||
for (const QString path : partList()) {
|
||||
tmp += path + QStringLiteral(",");
|
||||
}
|
||||
if (type() == ResizeVolumeGroupJob::Grow) {
|
||||
|
|
|
@ -70,7 +70,7 @@ bool SetPartFlagsJob::run(Report& parent)
|
|||
if (backendPartition) {
|
||||
quint32 count = 0;
|
||||
|
||||
foreach(const PartitionTable::Flag & f, PartitionTable::flagList()) {
|
||||
for (const PartitionTable::Flag & f : PartitionTable::flagList()) {
|
||||
emit progress(++count);
|
||||
|
||||
const bool state = (flags() & f) ? true : false;
|
||||
|
|
|
@ -56,7 +56,7 @@ void CreateVolumeGroupOperation::preview()
|
|||
|
||||
void CreateVolumeGroupOperation::undo()
|
||||
{
|
||||
foreach(QString pvpath, PVList()) {
|
||||
for(QString pvpath : PVList()) {
|
||||
if (LvmDevice::s_DirtyPVs.contains(pvpath)) {
|
||||
LvmDevice::s_DirtyPVs.removeAll(pvpath);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ protected:
|
|||
return m_CreateVolumeGroupJob;
|
||||
}
|
||||
|
||||
QStringList PVList() {
|
||||
const QStringList PVList() {
|
||||
return m_PVList;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ qint32 Operation::totalProgress() const
|
|||
{
|
||||
qint32 result = 0;
|
||||
|
||||
foreach(const Job * job, jobs())
|
||||
for (const Job * job : jobs())
|
||||
result += job->numSteps();
|
||||
|
||||
return result;
|
||||
|
|
|
@ -46,14 +46,14 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& dev, const QSt
|
|||
m_CurrentSize = FS::lvm2_pv::getPVSize(currentList());
|
||||
|
||||
QStringList toRemoveList = clist;
|
||||
foreach (QString path, partlist) {
|
||||
for (QString path : partlist) {
|
||||
if (toRemoveList.contains(path)) {
|
||||
toRemoveList.removeAll(path);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList toInsertList = partlist;
|
||||
foreach (QString path, clist) {
|
||||
for (QString path : clist) {
|
||||
if (toInsertList.contains(path)) {
|
||||
toInsertList.removeAll(path);
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& dev, const QSt
|
|||
QString ResizeVolumeGroupOperation::description() const
|
||||
{
|
||||
QString tlist = QString();
|
||||
foreach (QString path, targetList()) {
|
||||
for (QString path : targetList()) {
|
||||
tlist += path + QStringLiteral(",");
|
||||
}
|
||||
tlist.chop(1);
|
||||
QString clist = QString();
|
||||
foreach (QString path, currentList()) {
|
||||
for (QString path : currentList()) {
|
||||
clist += path + QStringLiteral(",");
|
||||
}
|
||||
clist.chop(1);
|
||||
|
@ -103,7 +103,7 @@ bool ResizeVolumeGroupOperation::targets(const Device& d) const
|
|||
|
||||
bool ResizeVolumeGroupOperation::targets(const Partition& part) const
|
||||
{
|
||||
foreach (QString partPath, targetList()) {
|
||||
for (QString partPath : targetList()) {
|
||||
if (partPath == part.partitionPath()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ QString Report::toHtml() const
|
|||
if (children().size() == 0)
|
||||
s += QStringLiteral("<br/>\n");
|
||||
else
|
||||
foreach(Report * child, children())
|
||||
for (Report * child : children())
|
||||
s += child->toHtml();
|
||||
|
||||
if (!status().isEmpty())
|
||||
|
@ -109,7 +109,7 @@ QString Report::toText() const
|
|||
if (!output().isEmpty())
|
||||
s += output() + QStringLiteral("\n");
|
||||
|
||||
foreach(Report * child, children())
|
||||
for (const Report * child : children())
|
||||
s += child->toText();
|
||||
|
||||
return s;
|
||||
|
|
Loading…
Reference in New Issue