Drop use of qt foreach

This commit is contained in:
Anton Thomasson 2022-05-22 11:00:32 +02:00
parent ba2a826b56
commit 6ba065b4b1
5 changed files with 20 additions and 20 deletions

View file

@ -93,7 +93,7 @@ void IppDiscovery::sendQuery(quint16 qtype, QStringList addrs) {
QTime now = QTime::currentTime();
QTime aWhileAgo = now.addSecs(-1);
foreach(QString oq, _outstandingQueries.keys())
for(QString oq : _outstandingQueries.keys())
{
if(_outstandingQueries[oq] < aWhileAgo)
{ // Housekeeping for _outstandingQueries
@ -121,7 +121,7 @@ void IppDiscovery::sendQuery(quint16 qtype, QStringList addrs) {
query << _transactionid++ << flags << questions << (quint16)0 << (quint16)0 << (quint16)0;
foreach(QString addr, addrs)
for(QString addr : addrs)
{
_outstandingQueries.insert(addr, now);
@ -187,7 +187,7 @@ void IppDiscovery::update()
QList<QPair<QString,QString>> ippsIpRps;
QString target, rp;
foreach(QString it, _ipps)
for(QString it : _ipps)
{
quint16 port = _ports[it];
target = _targets[it];
@ -208,7 +208,7 @@ void IppDiscovery::update()
}
}
foreach(QString it, _ipp)
for(QString it : _ipp)
{
quint16 port = _ports[it];
target = _targets[it];
@ -236,7 +236,7 @@ void IppDiscovery::update()
// TODO?: replace this with some logica that can bpoth add and remove
// and it can consider _favourites, so we can drop cleanUpdate
foreach(QString f, found)
for(QString f : found)
{
if(!this->stringList().contains(f))
{
@ -252,7 +252,7 @@ void IppDiscovery::update()
void IppDiscovery::updateAndQueryPtrs(QStringList& ptrs, QStringList new_ptrs)
{
new_ptrs.removeDuplicates();
foreach(QString ptr, new_ptrs)
for(QString ptr : new_ptrs)
{
if(!ptrs.contains(ptr))
{
@ -385,7 +385,7 @@ void IppDiscovery::readPendingDatagrams()
QStringList unresolvedAddrs;
foreach(QString t, new_targets)
for(QString t : new_targets)
{
// If target does not resolve to an address, query about it
if(!_AAs.contains(t))

View file

@ -159,7 +159,7 @@ QJsonArray IppMsg::get_unnamed_attributes(Bytestream& data)
QJsonArray untag_values(QJsonArray taggedValues)
{
QJsonArray res;
foreach(QJsonValue it, taggedValues)
for(QJsonValue it : taggedValues)
{
res.append(it.toObject()["value"]);
}
@ -297,7 +297,7 @@ Bytestream IppMsg::encode(Operation op)
"attributes-natural-language",
"printer-uri",
"requesting-user-name"};
foreach(QString key, InitialAttrs)
for(QString key : InitialAttrs)
{
QJsonObject val = _opAttrs.take(key).toObject();
encode_attr(ipp, val["tag"].toInt(), key, val["value"]);
@ -381,7 +381,7 @@ void IppMsg::encode_attr(Bytestream& msg, quint8 tag, QString name, QJsonValue v
if(value.isObject())
{
QJsonObject collection = value.toObject();
foreach(QString key, collection.keys())
for(QString key : collection.keys())
{
encode_attr(msg, collection[key].toObject()["tag"].toInt(), key,
collection[key].toObject()["value"], true);

View file

@ -310,7 +310,7 @@ void IppPrinter::getStringsFinished(CURLcode res, Bytestream data)
// "media-type.com.epson-coated" = "Epson Photo Quality Ink Jet";
QRegularExpression re("^\\\"(.*)\\\"\\s*=\\s*\\\"(.*)\\\";");
QList<QByteArray> bl = ba.split('\n');
foreach(QByteArray l, bl)
for(QByteArray l : bl)
{
QRegularExpressionMatch match = re.match(l);
if(match.hasMatch())
@ -412,7 +412,7 @@ void IppPrinter::adjustRasterSettings(QString documentFormat, QJsonObject& jobAt
quint32 diff = std::numeric_limits<quint32>::max();
quint32 AdjustedHwResX = Params.hwResW;
quint32 AdjustedHwResY = Params.hwResH;
foreach(QJsonValue res, _attrs["pwg-raster-document-resolution-supported"].toObject()["value"].toArray())
for(QJsonValue res : _attrs["pwg-raster-document-resolution-supported"].toObject()["value"].toArray())
{
QJsonObject resObj = res.toObject();
if(resObj["units"] != 3)
@ -439,12 +439,12 @@ void IppPrinter::adjustRasterSettings(QString documentFormat, QJsonObject& jobAt
quint32 AdjustedHwRes = Params.hwResW;
QJsonArray urfSupported = _attrs["urf-supported"].toObject()["value"].toArray();
foreach(QJsonValue us, urfSupported)
for(QJsonValue us : urfSupported)
{
if(us.toString().startsWith("RS"))
{ //RS300[-600]
QStringList resolutions = us.toString().mid(2).split("-");
foreach(QString res, resolutions)
for(QString res : resolutions)
{
int intRes = res.toInt();
quint32 tmpDiff = std::abs(int(Params.hwResW - intRes));
@ -782,7 +782,7 @@ bool IppPrinter::identify() {
bool IppPrinter::correctSuffix()
{
foreach(QJsonValue u, _attrs["printer-uri-supported"].toObject()["value"].toArray())
for(QJsonValue u : _attrs["printer-uri-supported"].toObject()["value"].toArray())
{
QUrl url(u.toString());
if(url.path() == _url.path())
@ -796,7 +796,7 @@ bool IppPrinter::correctSuffix()
QStringList IppPrinter::suffixes()
{
QStringList res;
foreach(QJsonValue u, _attrs["printer-uri-supported"].toObject()["value"].toArray())
for(QJsonValue u : _attrs["printer-uri-supported"].toObject()["value"].toArray())
{
QUrl url(u.toString());
if(!res.contains(url.path()))

View file

@ -40,7 +40,7 @@ Overrider* Overrider::instance()
bool Overrider::apply(QJsonObject& attrs)
{
bool applied = false;
foreach(const QString& key, _overrides.keys())
for(const QString& key : _overrides.keys())
{
if(attrs.contains(key))
{
@ -48,7 +48,7 @@ bool Overrider::apply(QJsonObject& attrs)
if(match != "" && _overrides[key].toObject().contains(match))
{
QJsonObject overrideden_data = _overrides[key].toObject()[match].toObject();
foreach(const QString& o_key, overrideden_data.keys())
for(const QString& o_key : overrideden_data.keys())
{
attrs.insert(o_key, overrideden_data[o_key]);
}

View file

@ -174,7 +174,7 @@ try {
QStringList lines;
foreach(QString rnline, allText.split("\r\n"))
for(QString rnline : allText.split("\r\n"))
{
lines.append(rnline.split("\n"));
}
@ -508,7 +508,7 @@ try {
bool first = true;
int pageCount = 0;
foreach(QString page, pages)
for(QString page : pages)
{
if(!first)
{