From 06b3dc9cc8edce801aa2a5d44f9152d06ec32541 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 19 Apr 2023 23:34:49 +0800 Subject: [PATCH] Modernise PropfindJob with new for and const auto Signed-off-by: Claudio Cambra --- src/libsync/networkjobs.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 1dfaa4900..152e95fa7 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -555,7 +555,7 @@ PropfindJob::PropfindJob(AccountPtr account, const QString &path, QObject *paren void PropfindJob::start() { - QList properties = _properties; + const auto properties = _properties; if (properties.isEmpty()) { qCWarning(lcLsColJob) << "Propfind with no properties!"; @@ -567,21 +567,21 @@ void PropfindJob::start() req.setPriority(QNetworkRequest::HighPriority); req.setRawHeader("Depth", "0"); QByteArray propStr; - foreach (const QByteArray &prop, properties) { + for (const auto &prop : properties) { if (prop.contains(':')) { - int colIdx = prop.lastIndexOf(":"); + const auto colIdx = prop.lastIndexOf(":"); propStr += " <" + prop.mid(colIdx + 1) + " xmlns=\"" + prop.left(colIdx) + "\" />\n"; } else { propStr += " \n"; } } - QByteArray xml = "\n" - "\n" - " \n" - + propStr + " \n" - "\n"; + const auto xml = QByteArray("\n" + "\n" + " \n" + + propStr + " \n" + "\n"); - auto *buf = new QBuffer(this); + const auto buf = new QBuffer(this); buf->setData(xml); buf->open(QIODevice::ReadOnly); sendRequest("PROPFIND", makeDavUrl(path()), req, buf); @@ -604,7 +604,7 @@ bool PropfindJob::finished() qCInfo(lcPropfindJob) << "PROPFIND of" << reply()->request().url() << "FINISHED WITH STATUS" << replyStatusString(); - int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + const auto http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (http_result_code == 207) { // Parse DAV response @@ -616,7 +616,7 @@ bool PropfindJob::finished() QStack curElement; while (!reader.atEnd()) { - QXmlStreamReader::TokenType type = reader.readNext(); + const auto type = reader.readNext(); if (type == QXmlStreamReader::StartElement) { if (!curElement.isEmpty() && curElement.top() == QLatin1String("prop")) { items.insert(reader.name().toString(), reader.readElementText(QXmlStreamReader::SkipChildElements)); -- 2.30.2