Convert most of the remaining foreach cases.
This commit is contained in:
parent
9c524c40fe
commit
40ff0861a8
|
@ -65,10 +65,10 @@ void DeviceScanner::scan()
|
|||
const QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices();
|
||||
const QList<LvmDevice*> lvmList = LvmDevice::scanSystemLVM();
|
||||
|
||||
for (auto const &d : deviceList)
|
||||
for (const auto &d : deviceList)
|
||||
operationStack().addDevice(d);
|
||||
|
||||
for (auto const &d : lvmList)
|
||||
for (const auto &d : lvmList)
|
||||
operationStack().addDevice(d);
|
||||
|
||||
operationStack().sortDevices();
|
||||
|
|
|
@ -96,7 +96,7 @@ qint32 OperationRunner::numJobs() const
|
|||
{
|
||||
qint32 result = 0;
|
||||
|
||||
for (auto const &op : operationStack().operations())
|
||||
for (const auto &op : operationStack().operations())
|
||||
result += op->jobs().size();
|
||||
|
||||
return result;
|
||||
|
|
|
@ -457,7 +457,7 @@ bool OperationStack::contains(const Partition* p) const
|
|||
{
|
||||
Q_ASSERT(p);
|
||||
|
||||
for (auto const &o : operations()) {
|
||||
for (const auto &o : operations()) {
|
||||
if (o->targets(*p))
|
||||
return true;
|
||||
|
||||
|
@ -503,15 +503,17 @@ Device* OperationStack::findDeviceForPartition(const Partition* p)
|
|||
{
|
||||
QReadLocker lockDevices(&lock());
|
||||
|
||||
foreach(Device *d, previewDevices()) {
|
||||
const auto devices = previewDevices();
|
||||
for (Device *d : devices) {
|
||||
if (d->partitionTable() == nullptr)
|
||||
continue;
|
||||
|
||||
foreach (auto const *part, d->partitionTable()->children()) {
|
||||
const auto partitions = d->partitionTable()->children();
|
||||
for (const auto *part : partitions) {
|
||||
if (part == p)
|
||||
return d;
|
||||
|
||||
for (auto const &child : part->children())
|
||||
for (const auto &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);
|
||||
for (auto const &child : other.children()) {
|
||||
for (const auto &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();
|
||||
|
||||
for (auto const &child : other.children()) {
|
||||
for (const auto &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;
|
||||
for (auto const &p : children())
|
||||
for (const auto &p : children())
|
||||
if (!p->roles().has(PartitionRole::Unallocated))
|
||||
result += p->length();
|
||||
|
||||
|
@ -210,12 +210,12 @@ qint64 Partition::maximumSectors() const
|
|||
@param deletedNumber the number of a deleted logical or -1 if none has been deleted
|
||||
@param insertedNumber the number of an inserted logical or -1 if none has been inserted
|
||||
*/
|
||||
void Partition::adjustLogicalNumbers(qint32 deletedNumber, qint32 insertedNumber)
|
||||
void Partition::adjustLogicalNumbers(qint32 deletedNumber, qint32 insertedNumber) const
|
||||
{
|
||||
if (!roles().has(PartitionRole::Extended))
|
||||
return;
|
||||
|
||||
foreach(auto const &p, children()) {
|
||||
for (const auto &p : children()) {
|
||||
QString path = p->partitionPath();
|
||||
path.remove(QRegularExpression(QStringLiteral("(\\d+$)")));
|
||||
if (deletedNumber > 4 && p->number() > deletedNumber)
|
||||
|
@ -230,7 +230,7 @@ qint64 Partition::maxFirstSector() const
|
|||
{
|
||||
qint64 rval = -1;
|
||||
|
||||
for (auto const &child : children())
|
||||
for (const auto &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;
|
||||
|
||||
for (auto const &child : children())
|
||||
for (const auto &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
|
||||
{
|
||||
for (auto const &child : children())
|
||||
for (const auto &child : children())
|
||||
if (!child->roles().has(PartitionRole::Unallocated))
|
||||
return true;
|
||||
|
||||
|
@ -365,7 +365,7 @@ QTextStream& operator<<(QTextStream& stream, const Partition& p)
|
|||
{
|
||||
QStringList flagList;
|
||||
|
||||
for (auto const &f : PartitionTable::flagList()) {
|
||||
for (const auto &f : PartitionTable::flagList()) {
|
||||
if (p.activeFlags() & f)
|
||||
flagList.append(PartitionTable::flagName(f));
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ public:
|
|||
bool canMount() const;
|
||||
bool canUnmount() const;
|
||||
|
||||
void adjustLogicalNumbers(qint32 deletedNumber, qint32 insertedNumber);
|
||||
void adjustLogicalNumbers(qint32 deletedNumber, qint32 insertedNumber) const;
|
||||
void checkChildrenMounted();
|
||||
|
||||
void setFirstSector(qint64 s) {
|
||||
|
|
|
@ -139,9 +139,11 @@ void PartitionNode::clearChildren()
|
|||
*/
|
||||
Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& role)
|
||||
{
|
||||
foreach(auto & p, children()) {
|
||||
const auto partitions = children();
|
||||
for (auto &p : partitions) {
|
||||
// (women and) children first. ;-)
|
||||
foreach(auto &child, p->children())
|
||||
const auto pChildren = p->children();
|
||||
for (auto &child : pChildren)
|
||||
if ((child->roles().roles() & role.roles()) && s >= child->firstSector() && s <= child->lastSector())
|
||||
return child;
|
||||
|
||||
|
@ -158,7 +160,7 @@ Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& r
|
|||
const Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& role) const
|
||||
{
|
||||
for (const auto *p : children()) {
|
||||
for (auto const &child : p->children())
|
||||
for (const auto &child : p->children())
|
||||
if ((child->roles().roles() & role.roles()) && s >= child->firstSector() && s <= child->lastSector())
|
||||
return child;
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ qint64 PartitionTable::freeSectorsAfter(const Partition& p) const
|
|||
qint64 PartitionTable::freeSectors() const
|
||||
{
|
||||
qint64 sectors = 0;
|
||||
for (auto const &p : children()) {
|
||||
for (const auto &p : children()) {
|
||||
if (p->roles().has(PartitionRole::Unallocated)) {
|
||||
sectors += p->length();
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ qint64 PartitionTable::freeSectors() const
|
|||
/** @return true if the PartitionTable has an extended Partition */
|
||||
bool PartitionTable::hasExtended() const
|
||||
{
|
||||
for (auto const &p : children())
|
||||
for (const auto &p : children())
|
||||
if (p->roles().has(PartitionRole::Extended))
|
||||
return true;
|
||||
|
||||
|
@ -114,7 +114,7 @@ bool PartitionTable::hasExtended() const
|
|||
/** @return pointer to the PartitionTable's extended Partition or nullptr if none exists */
|
||||
Partition* PartitionTable::extended() const
|
||||
{
|
||||
for (auto const &p : children())
|
||||
for (const auto &p : children())
|
||||
if (p->roles().has(PartitionRole::Extended))
|
||||
return p;
|
||||
|
||||
|
@ -142,7 +142,7 @@ int PartitionTable::numPrimaries() const
|
|||
{
|
||||
int result = 0;
|
||||
|
||||
for (auto const &p : children())
|
||||
for (const auto &p : children())
|
||||
if (p->roles().has(PartitionRole::Primary) || p->roles().has(PartitionRole::Extended))
|
||||
result++;
|
||||
|
||||
|
@ -285,7 +285,6 @@ bool PartitionTable::getUnallocatedRange(const Device& d, PartitionNode& parent,
|
|||
}
|
||||
|
||||
|
||||
|
||||
/** Creates a new unallocated Partition on the given Device.
|
||||
@param device the Device to create the new Partition on
|
||||
@param parent the parent PartitionNode for the new Partition
|
||||
|
@ -360,7 +359,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;
|
||||
for (auto &child : children()) {
|
||||
for (const auto &child : children()) {
|
||||
qint64 totalSector = child->length();
|
||||
child->setFirstSector(lastEnd);
|
||||
child->setLastSector(lastEnd + totalSector - 1);
|
||||
|
@ -368,7 +367,8 @@ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64
|
|||
lastEnd += totalSector;
|
||||
}
|
||||
} else {
|
||||
foreach(auto &child, p->children()) {
|
||||
const auto pChildren = p->children();
|
||||
for (const auto &child : pChildren) {
|
||||
p->insert(createUnallocated(d, *p, lastEnd, child->firstSector() - 1));
|
||||
|
||||
if (child->roles().has(PartitionRole::Extended))
|
||||
|
@ -544,12 +544,12 @@ QTextStream& operator<<(QTextStream& stream, const PartitionTable& ptable)
|
|||
|
||||
QList<const Partition*> partitions;
|
||||
|
||||
for (auto const &p : ptable.children()) {
|
||||
for (const auto &p : ptable.children()) {
|
||||
if (!p->roles().has(PartitionRole::Unallocated)) {
|
||||
partitions.append(p);
|
||||
|
||||
if (p->roles().has(PartitionRole::Extended))
|
||||
for (auto const &child : p->children()) {
|
||||
for (const auto &child : p->children()) {
|
||||
if (!child->roles().has(PartitionRole::Unallocated))
|
||||
partitions.append(child);
|
||||
}
|
||||
|
@ -558,7 +558,7 @@ QTextStream& operator<<(QTextStream& stream, const PartitionTable& ptable)
|
|||
|
||||
qSort(partitions.begin(), partitions.end(), isPartitionLessThan);
|
||||
|
||||
foreach(auto const &p, partitions)
|
||||
foreach(const auto &p, partitions)
|
||||
stream << *p;
|
||||
|
||||
return stream;
|
||||
|
|
|
@ -56,7 +56,7 @@ void PartWidget::init(const Partition* p)
|
|||
void PartWidget::updateChildren()
|
||||
{
|
||||
if (partition()) {
|
||||
foreach(auto &w, childWidgets()) {
|
||||
for (const auto &w : childWidgets()) {
|
||||
w->setVisible(false);
|
||||
w->deleteLater();
|
||||
w->setParent(nullptr);
|
||||
|
|
|
@ -142,7 +142,7 @@ void PartWidgetBase::positionChildren(const QWidget* destWidget, const Partition
|
|||
}
|
||||
}
|
||||
|
||||
QList<PartWidget*> PartWidgetBase::childWidgets()
|
||||
const QList<PartWidget*> PartWidgetBase::childWidgets() const
|
||||
{
|
||||
QList<PartWidget*> rval;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
return m_MinWidth; /**< @return minimum width for a Partition widget */
|
||||
}
|
||||
|
||||
virtual QList<PartWidget*> childWidgets();
|
||||
virtual const QList<PartWidget*> childWidgets() const;
|
||||
|
||||
protected:
|
||||
virtual void positionChildren(const QWidget* destWidget, const PartitionNode::Partitions& partitions, QList<PartWidget*> widgets) const;
|
||||
|
|
|
@ -162,7 +162,8 @@ bool Operation::execute(Report& parent)
|
|||
|
||||
Report* report = parent.newChild(description());
|
||||
|
||||
foreach(Job * job, jobs())
|
||||
const auto Jobs = jobs();
|
||||
for (const auto &job : Jobs)
|
||||
if (!(rval = job->run(*report)))
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue