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