More work on C++11 for loops.
This commit is contained in:
parent
799d213530
commit
16a2d063e3
|
@ -65,10 +65,10 @@ void DeviceScanner::scan()
|
|||
const QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices();
|
||||
const QList<LvmDevice*> lvmList = LvmDevice::scanSystemLVM();
|
||||
|
||||
for (Device * d : deviceList)
|
||||
for (auto const &d : deviceList)
|
||||
operationStack().addDevice(d);
|
||||
|
||||
for (Device * d : lvmList)
|
||||
for (auto const &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);
|
||||
|
||||
for (Partition* p : scanPartitions(pTable)) {
|
||||
for (const auto &p : scanPartitions(pTable)) {
|
||||
LVSizeMap()->insert(p->partitionPath(), p->length());
|
||||
pTable->append(p);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void LvmDevice::initPartitions()
|
|||
const QList<Partition*> LvmDevice::scanPartitions(PartitionTable* pTable) const
|
||||
{
|
||||
QList<Partition*> pList;
|
||||
for (QString lvPath : lvPathList()) {
|
||||
for (const auto &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;
|
||||
for (QString vgname : getVGs()) {
|
||||
for (const auto &vgname : getVGs()) {
|
||||
lvmList.append(new LvmDevice(vgname));
|
||||
}
|
||||
return lvmList;
|
||||
|
@ -221,7 +221,7 @@ const QStringList LvmDevice::getVGs()
|
|||
QString output = getField(QStringLiteral("vg_name"));
|
||||
if (!output.isEmpty()) {
|
||||
const QStringList vgnameList = output.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
for (QString vgname : vgnameList) {
|
||||
for (const auto &vgname : vgnameList) {
|
||||
vgList.append(vgname.trimmed());
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ QStringList LvmDevice::getPVs(const QString& vgname)
|
|||
|
||||
if (cmdOutput.size()) {
|
||||
const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
for (QString devPath : tempPathList) {
|
||||
for (const auto &devPath : tempPathList) {
|
||||
devPathList.append(devPath.trimmed());
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ QStringList LvmDevice::getLVs(const QString& vgname)
|
|||
|
||||
if (cmdOutput.size()) {
|
||||
const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||
for (QString lvPath : tempPathList) {
|
||||
for (const auto &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()) {
|
||||
for (QString destPath : destinations) {
|
||||
for (const auto &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;
|
||||
for (QString pvnode : pvlist) {
|
||||
for (const auto &pvnode : pvlist) {
|
||||
args << pvnode.trimmed();
|
||||
}
|
||||
ExternalCommand cmd(report, QStringLiteral("lvm"), args);
|
||||
|
|
|
@ -96,7 +96,7 @@ qint32 OperationRunner::numJobs() const
|
|||
{
|
||||
qint32 result = 0;
|
||||
|
||||
for (const Operation * op : operationStack().operations())
|
||||
for (auto const &op : operationStack().operations())
|
||||
result += op->jobs().size();
|
||||
|
||||
return result;
|
||||
|
|
|
@ -457,7 +457,7 @@ bool OperationStack::contains(const Partition* p) const
|
|||
{
|
||||
Q_ASSERT(p);
|
||||
|
||||
for (Operation * o : operations()) {
|
||||
for (auto const &o : operations()) {
|
||||
if (o->targets(*p))
|
||||
return true;
|
||||
|
||||
|
@ -499,19 +499,19 @@ void OperationStack::clearDevices()
|
|||
@param p pointer to the Partition to find a Device for
|
||||
@return the Device or nullptr if none could be found
|
||||
*/
|
||||
Device* OperationStack::findDeviceForPartition(const Partition* p)
|
||||
const Device* OperationStack::findDeviceForPartition(const Partition* p)
|
||||
{
|
||||
QReadLocker lockDevices(&lock());
|
||||
|
||||
foreach(Device * d, previewDevices()) {
|
||||
foreach(const Device *d, previewDevices()) {
|
||||
if (d->partitionTable() == nullptr)
|
||||
continue;
|
||||
|
||||
foreach(const Partition * part, d->partitionTable()->children()) {
|
||||
for (auto const &part : d->partitionTable()->children()) {
|
||||
if (part == p)
|
||||
return d;
|
||||
|
||||
for (const Partition * child : part->children())
|
||||
for (auto const &child : part->children())
|
||||
if (child == p)
|
||||
return d;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
return m_Operations; /**< @return the list of operations */
|
||||
}
|
||||
|
||||
Device* findDeviceForPartition(const Partition* p);
|
||||
const Device* findDeviceForPartition(const Partition* p);
|
||||
|
||||
QReadWriteLock& lock() {
|
||||
return m_Lock;
|
||||
|
|
|
@ -106,7 +106,7 @@ Partition::Partition(const Partition& other) :
|
|||
m_State(other.m_State)
|
||||
{
|
||||
setPartitionPath(other.m_PartitionPath);
|
||||
for (const Partition * child : other.children()) {
|
||||
for (auto const &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 (const Partition * child : other.children()) {
|
||||
for (auto const &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 (const Partition * p : children())
|
||||
for (auto const &p : children())
|
||||
if (!p->roles().has(PartitionRole::Unallocated))
|
||||
result += p->length();
|
||||
|
||||
|
@ -215,7 +215,7 @@ void Partition::adjustLogicalNumbers(qint32 deletedNumber, qint32 insertedNumber
|
|||
if (!roles().has(PartitionRole::Extended))
|
||||
return;
|
||||
|
||||
foreach(Partition * p, children()) {
|
||||
foreach(auto const &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 (const Partition * child : children())
|
||||
for (auto const &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 (const Partition * child : children())
|
||||
for (auto const &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 (const Partition * child : children())
|
||||
for (auto const &child : children())
|
||||
if (!child->roles().has(PartitionRole::Unallocated))
|
||||
return true;
|
||||
|
||||
|
@ -365,7 +365,7 @@ QTextStream& operator<<(QTextStream& stream, const Partition& p)
|
|||
{
|
||||
QStringList flagList;
|
||||
|
||||
for (const PartitionTable::Flag & f : PartitionTable::flagList()) {
|
||||
for (auto const &f : PartitionTable::flagList()) {
|
||||
if (p.activeFlags() & f)
|
||||
flagList.append(PartitionTable::flagName(f));
|
||||
}
|
||||
|
|
|
@ -139,9 +139,9 @@ void PartitionNode::clearChildren()
|
|||
*/
|
||||
Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& role)
|
||||
{
|
||||
foreach(Partition * p, children()) {
|
||||
foreach(auto & p, children()) {
|
||||
// (women and) children first. ;-)
|
||||
foreach(Partition * child, p->children())
|
||||
foreach(auto &child, p->children())
|
||||
if ((child->roles().roles() & role.roles()) && s >= child->firstSector() && s <= child->lastSector())
|
||||
return child;
|
||||
|
||||
|
@ -157,8 +157,8 @@ Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& r
|
|||
*/
|
||||
const Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& role) const
|
||||
{
|
||||
for (const Partition * p : children()) {
|
||||
for (const Partition * child : p->children())
|
||||
for (const auto *p : children()) {
|
||||
for (auto const &child : p->children())
|
||||
if ((child->roles().roles() & role.roles()) && s >= child->firstSector() && s <= child->lastSector())
|
||||
return child;
|
||||
|
||||
|
@ -190,7 +190,7 @@ qint32 PartitionNode::highestMountedChild() const
|
|||
{
|
||||
qint32 result = -1;
|
||||
|
||||
for (const Partition * p : children())
|
||||
for (const auto * p : children())
|
||||
if (p->number() > result && p->isMounted())
|
||||
result = p->number();
|
||||
|
||||
|
@ -200,7 +200,7 @@ qint32 PartitionNode::highestMountedChild() const
|
|||
/** @return true if any of the partition's children are mounted */
|
||||
bool PartitionNode::isChildMounted() const
|
||||
{
|
||||
for (const Partition * child : children())
|
||||
for (const auto * child : children())
|
||||
if (child->isMounted() || (child->hasChildren() && child->isChildMounted()))
|
||||
return true;
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ qint64 PartitionTable::freeSectorsAfter(const Partition& p) const
|
|||
qint64 PartitionTable::freeSectors() const
|
||||
{
|
||||
qint64 sectors = 0;
|
||||
for (const Partition * p : children()) {
|
||||
for (auto const &p : children()) {
|
||||
if (p->roles().has(PartitionRole::Unallocated)) {
|
||||
sectors += p->length();
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ qint64 PartitionTable::freeSectors() const
|
|||
/** @return true if the PartitionTable has an extended Partition */
|
||||
bool PartitionTable::hasExtended() const
|
||||
{
|
||||
for (int i = 0; i < children().size(); i++)
|
||||
if (children()[i]->roles().has(PartitionRole::Extended))
|
||||
for (auto const &p : children())
|
||||
if (p->roles().has(PartitionRole::Extended))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -114,9 +114,9 @@ bool PartitionTable::hasExtended() const
|
|||
/** @return pointer to the PartitionTable's extended Partition or nullptr if none exists */
|
||||
Partition* PartitionTable::extended() const
|
||||
{
|
||||
for (int i = 0; i < children().size(); i++)
|
||||
if (children()[i]->roles().has(PartitionRole::Extended))
|
||||
return children()[i];
|
||||
for (auto const &p : children())
|
||||
if (p->roles().has(PartitionRole::Extended))
|
||||
return p;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ int PartitionTable::numPrimaries() const
|
|||
{
|
||||
int result = 0;
|
||||
|
||||
for (const Partition * p : children())
|
||||
for (auto const &p : children())
|
||||
if (p->roles().has(PartitionRole::Primary) || p->roles().has(PartitionRole::Extended))
|
||||
result++;
|
||||
|
||||
|
@ -360,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;
|
||||
for (Partition* child : children()) {
|
||||
for (auto &child : children()) {
|
||||
qint64 totalSector = child->length();
|
||||
child->setFirstSector(lastEnd);
|
||||
child->setLastSector(lastEnd + totalSector - 1);
|
||||
|
@ -368,7 +368,7 @@ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64
|
|||
lastEnd += totalSector;
|
||||
}
|
||||
} else {
|
||||
foreach(Partition * child, p->children()) {
|
||||
foreach(auto &child, p->children()) {
|
||||
p->insert(createUnallocated(d, *p, lastEnd, child->firstSector() - 1));
|
||||
|
||||
if (child->roles().has(PartitionRole::Extended))
|
||||
|
@ -444,45 +444,45 @@ static struct {
|
|||
|
||||
PartitionTable::TableType PartitionTable::nameToTableType(const QString& n)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(tableTypes) / sizeof(tableTypes[0]); i++)
|
||||
if (n == tableTypes[i].name)
|
||||
return tableTypes[i].type;
|
||||
for (const auto &type : tableTypes)
|
||||
if (n == type.name)
|
||||
return type.type;
|
||||
|
||||
return PartitionTable::unknownTableType;
|
||||
}
|
||||
|
||||
QString PartitionTable::tableTypeToName(TableType l)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(tableTypes) / sizeof(tableTypes[0]); i++)
|
||||
if (l == tableTypes[i].type)
|
||||
return tableTypes[i].name;
|
||||
for (const auto &type : tableTypes)
|
||||
if (l == type.type)
|
||||
return type.name;
|
||||
|
||||
return xi18nc("@item partition table name", "unknown");
|
||||
}
|
||||
|
||||
qint64 PartitionTable::maxPrimariesForTableType(TableType l)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(tableTypes) / sizeof(tableTypes[0]); i++)
|
||||
if (l == tableTypes[i].type)
|
||||
return tableTypes[i].maxPrimaries;
|
||||
for (const auto &type : tableTypes)
|
||||
if (l == type.type)
|
||||
return type.maxPrimaries;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool PartitionTable::tableTypeSupportsExtended(TableType l)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(tableTypes) / sizeof(tableTypes[0]); i++)
|
||||
if (l == tableTypes[i].type)
|
||||
return tableTypes[i].canHaveExtended;
|
||||
for (const auto &type : tableTypes)
|
||||
if (l == type.type)
|
||||
return type.canHaveExtended;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PartitionTable::tableTypeIsReadOnly(TableType l)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(tableTypes) / sizeof(tableTypes[0]); i++)
|
||||
if (l == tableTypes[i].type)
|
||||
return tableTypes[i].isReadOnly;
|
||||
for (const auto &type : tableTypes)
|
||||
if (l == type.type)
|
||||
return type.isReadOnly;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ bool PartitionTable::isSectorBased(const Device& d) const
|
|||
|
||||
// see if we have more cylinder aligned partitions than sector
|
||||
// aligned ones.
|
||||
for (const Partition * p : children()) {
|
||||
for (const auto &p : children()) {
|
||||
if (p->firstSector() % PartitionAlignment::sectorAlignment(diskDevice) == 0)
|
||||
numSectorAligned++;
|
||||
else if (p->firstSector() % diskDevice.cylinderSize() == 0)
|
||||
|
@ -544,12 +544,12 @@ QTextStream& operator<<(QTextStream& stream, const PartitionTable& ptable)
|
|||
|
||||
QList<const Partition*> partitions;
|
||||
|
||||
for (const Partition * p : ptable.children()) {
|
||||
for (auto const &p : ptable.children()) {
|
||||
if (!p->roles().has(PartitionRole::Unallocated)) {
|
||||
partitions.append(p);
|
||||
|
||||
if (p->roles().has(PartitionRole::Extended))
|
||||
for (const Partition * child : p->children()) {
|
||||
for (auto const &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(const Partition * p, partitions)
|
||||
foreach(auto const &p, partitions)
|
||||
stream << *p;
|
||||
|
||||
return stream;
|
||||
|
|
|
@ -37,7 +37,7 @@ VolumeManagerDevice::VolumeManagerDevice(const QString& name,
|
|||
QString VolumeManagerDevice::prettyDeviceNodeList() const
|
||||
{
|
||||
QString rval;
|
||||
for (QString devNode : deviceNodeList()) {
|
||||
for (const auto &devNode : deviceNodeList()) {
|
||||
rval += devNode + QStringLiteral(",");
|
||||
}
|
||||
|
||||
|
|
|
@ -84,9 +84,8 @@ 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()));
|
||||
|
||||
for (FileSystem * fs : FileSystemFactory::map()) {
|
||||
for (const auto &fs : FileSystemFactory::map())
|
||||
fs->init();
|
||||
}
|
||||
|
||||
CoreBackendManager::self()->backend()->initFSSupport();
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ qint64 lvm2_pv::getTotalPE(const QString& deviceNode)
|
|||
qint64 lvm2_pv::getTotalPE(const QStringList& deviceNodeList)
|
||||
{
|
||||
qint64 sum = 0;
|
||||
for (QString deviceNode : deviceNodeList) {
|
||||
for (const auto &deviceNode : deviceNodeList) {
|
||||
qint64 totalPE = getTotalPE(deviceNode);
|
||||
if (totalPE < 0) {
|
||||
sum = -1;
|
||||
|
|
|
@ -56,13 +56,13 @@ void PartWidget::init(const Partition* p)
|
|||
void PartWidget::updateChildren()
|
||||
{
|
||||
if (partition()) {
|
||||
foreach(QWidget * w, childWidgets()) {
|
||||
foreach(auto &w, childWidgets()) {
|
||||
w->setVisible(false);
|
||||
w->deleteLater();
|
||||
w->setParent(nullptr);
|
||||
}
|
||||
|
||||
for (const Partition * child : partition()->children()) {
|
||||
for (const auto &child : partition()->children()) {
|
||||
QWidget* w = new PartWidget(this, child);
|
||||
w->setVisible(true);
|
||||
}
|
||||
|
|
|
@ -107,21 +107,21 @@ void PartWidgetBase::positionChildren(const QWidget* destWidget, const Partition
|
|||
return;
|
||||
|
||||
qint64 totalLength = 0;
|
||||
for (const Partition * p : partitions)
|
||||
for (const auto &p : partitions)
|
||||
totalLength += p->length();
|
||||
|
||||
if (totalLength < 1)
|
||||
return;
|
||||
|
||||
// calculate unleveled width for each child and store it
|
||||
for (int i = 0; i < partitions.size(); i++) {
|
||||
childrenWidth.append(partitions[i]->length() * destWidgetWidth / totalLength);
|
||||
for (const auto &p : partitions) {
|
||||
childrenWidth.append(p->length() * destWidgetWidth / totalLength);
|
||||
|
||||
// Calculate the minimum width for the widget. This is easy for primary and logical partitions: they
|
||||
// just have a fixed min width (configured in m_MinWidth). But for extended partitions things
|
||||
// are not quite as simple. We need to calc the sum of the min widths for each child, taking
|
||||
// spacing and borders into account, and add our own min width.
|
||||
qint32 min = (minWidth() + 2 * borderWidth() + spacing()) * partitions[i]->children().size() - spacing() + 2 * borderWidth();
|
||||
qint32 min = (minWidth() + 2 * borderWidth() + spacing()) * p->children().size() - spacing() + 2 * borderWidth();
|
||||
|
||||
// if it's too small, this partition is a primary or logical so just use the configured value
|
||||
if (min < minWidth())
|
||||
|
@ -146,7 +146,7 @@ QList<PartWidget*> PartWidgetBase::childWidgets()
|
|||
{
|
||||
QList<PartWidget*> rval;
|
||||
|
||||
for (QObject * o : children())
|
||||
for (auto &o : children())
|
||||
if (PartWidget* w = qobject_cast<PartWidget*>(o))
|
||||
rval.append(w);
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new CreateVolumeGroupJob
|
||||
@param vgname
|
||||
@parem pvList
|
||||
@param vgname LVM Volume Group name
|
||||
@param pvlist List of LVM Physical Volumes
|
||||
*/
|
||||
CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgname, const QStringList& pvlist, const qint32 pesize) :
|
||||
Job(),
|
||||
|
@ -51,7 +51,7 @@ bool CreateVolumeGroupJob::run(Report& parent)
|
|||
QString CreateVolumeGroupJob::description() const
|
||||
{
|
||||
QString tmp = QString();
|
||||
for (const QString name : pvList()) {
|
||||
for (const auto &name : pvList()) {
|
||||
tmp += QStringLiteral("\n") + name;
|
||||
}
|
||||
return xi18nc("@info/plain", "Create new Volume Group: <filename>%1</filename> with PV: %2", vgName(), tmp);
|
||||
|
|
|
@ -41,9 +41,9 @@ bool DeactivateLogicalVolumeJob::run(Report& parent)
|
|||
Report* report = jobStarted(parent);
|
||||
|
||||
if (device().type() == Device::LVM_Device) {
|
||||
for (const Partition* part : device().partitionTable()->children()) {
|
||||
if (!part->roles().has(PartitionRole::Unallocated)) {
|
||||
if (!LvmDevice::deactivateLV(*report, dynamic_cast<const LvmDevice&>(device()), *part)) {
|
||||
for (const auto &p : device().partitionTable()->children()) {
|
||||
if (!p->roles().has(PartitionRole::Unallocated)) {
|
||||
if (!LvmDevice::deactivateLV(*report, dynamic_cast<const LvmDevice&>(device()), *p)) {
|
||||
rval = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,13 +39,13 @@ bool MovePhysicalVolumeJob::run(Report& parent)
|
|||
Report* report = jobStarted(parent);
|
||||
|
||||
QStringList destinations = LvmDevice::getPVs(device().name());
|
||||
for (const QString partPath : partList()) {
|
||||
for (const auto &partPath : partList()) {
|
||||
if (destinations.contains(partPath)) {
|
||||
destinations.removeAll(partPath);
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString partPath : partList()) {
|
||||
for (const auto &partPath : partList()) {
|
||||
rval = LvmDevice::movePV(*report, device(), partPath, destinations);
|
||||
if (rval == false) {
|
||||
break;
|
||||
|
@ -60,7 +60,7 @@ bool MovePhysicalVolumeJob::run(Report& parent)
|
|||
QString MovePhysicalVolumeJob::description() const
|
||||
{
|
||||
QString tmp = QString();
|
||||
for (const QString path : partList()) {
|
||||
for (const auto &path : partList()) {
|
||||
tmp += path + QStringLiteral(",");
|
||||
}
|
||||
return xi18nc("@info/plain", "Move used PE in %1 on %2 to other available Physical Volumes", tmp, device().name());
|
||||
|
|
|
@ -39,7 +39,7 @@ bool ResizeVolumeGroupJob::run(Report& parent)
|
|||
|
||||
Report* report = jobStarted(parent);
|
||||
|
||||
for (const QString pvpath : partList()) {
|
||||
for (const auto &pvpath : partList()) {
|
||||
if (type() == ResizeVolumeGroupJob::Grow) {
|
||||
rval = LvmDevice::insertPV(*report, device(), pvpath);
|
||||
} else if (type() == ResizeVolumeGroupJob::Shrink) {
|
||||
|
@ -58,7 +58,7 @@ bool ResizeVolumeGroupJob::run(Report& parent)
|
|||
QString ResizeVolumeGroupJob::description() const
|
||||
{
|
||||
QString tmp = QString();
|
||||
for (const QString path : partList()) {
|
||||
for (const auto &path : partList()) {
|
||||
tmp += path + QStringLiteral(",");
|
||||
}
|
||||
if (type() == ResizeVolumeGroupJob::Grow) {
|
||||
|
|
|
@ -70,7 +70,7 @@ bool SetPartFlagsJob::run(Report& parent)
|
|||
if (backendPartition) {
|
||||
quint32 count = 0;
|
||||
|
||||
for (const PartitionTable::Flag & f : PartitionTable::flagList()) {
|
||||
for (const auto &f : PartitionTable::flagList()) {
|
||||
emit progress(++count);
|
||||
|
||||
const bool state = (flags() & f) ? true : false;
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new CreateVolumeGroupOperation.
|
||||
@param d the Device to create the new PartitionTable on
|
||||
@param t the type for the new PartitionTable
|
||||
*/
|
||||
CreateVolumeGroupOperation::CreateVolumeGroupOperation(const QString& vgname, const QStringList& pvlist, const qint32 pesize) :
|
||||
Operation(),
|
||||
|
@ -56,7 +54,7 @@ void CreateVolumeGroupOperation::preview()
|
|||
|
||||
void CreateVolumeGroupOperation::undo()
|
||||
{
|
||||
for(QString pvpath : PVList()) {
|
||||
for(const auto &pvpath : PVList()) {
|
||||
if (LvmDevice::s_DirtyPVs.contains(pvpath)) {
|
||||
LvmDevice::s_DirtyPVs.removeAll(pvpath);
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new RemoveVolumeGroupOperation.
|
||||
@param d the Device to create the new PartitionTable on
|
||||
@param t the type for the new PartitionTable
|
||||
*/
|
||||
DeactivateVolumeGroupOperation::DeactivateVolumeGroupOperation(VolumeManagerDevice& dev) :
|
||||
Operation(),
|
||||
|
|
|
@ -146,7 +146,7 @@ qint32 Operation::totalProgress() const
|
|||
{
|
||||
qint32 result = 0;
|
||||
|
||||
for (const Job * job : jobs())
|
||||
for (const auto &job : jobs())
|
||||
result += job->numSteps();
|
||||
|
||||
return result;
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new RemoveVolumeGroupOperation.
|
||||
@param d the Device to create the new PartitionTable on
|
||||
@param t the type for the new PartitionTable
|
||||
*/
|
||||
RemoveVolumeGroupOperation::RemoveVolumeGroupOperation(VolumeManagerDevice& dev) :
|
||||
Operation(),
|
||||
|
|
|
@ -80,7 +80,7 @@ QString Report::toHtml() const
|
|||
if (children().size() == 0)
|
||||
s += QStringLiteral("<br/>\n");
|
||||
else
|
||||
for (Report * child : children())
|
||||
for (const auto &child : children())
|
||||
s += child->toHtml();
|
||||
|
||||
if (!status().isEmpty())
|
||||
|
@ -109,7 +109,7 @@ QString Report::toText() const
|
|||
if (!output().isEmpty())
|
||||
s += output() + QStringLiteral("\n");
|
||||
|
||||
for (const Report * child : children())
|
||||
for (const auto &child : children())
|
||||
s += child->toText();
|
||||
|
||||
return s;
|
||||
|
|
Loading…
Reference in New Issue