From 29e2a13d1260f16c7732ae9e74f38ef17ee879a8 Mon Sep 17 00:00:00 2001 From: Akira Ohgaki <akiraohgaki@gmail.com> Date: Fri, 26 May 2017 07:14:30 +0900 Subject: [PATCH] C++11 style --- app/src/handlers/confighandler.cpp | 4 ++-- app/src/handlers/itemhandler.cpp | 6 +++--- app/src/handlers/ocsapihandler.cpp | 12 ++++++------ app/src/websockets/websocketserver.cpp | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/handlers/confighandler.cpp b/app/src/handlers/confighandler.cpp index 88ad828..bcb3cd8 100644 --- a/app/src/handlers/confighandler.cpp +++ b/app/src/handlers/confighandler.cpp @@ -23,14 +23,14 @@ QJsonObject ConfigHandler::getAppConfigInstallTypes() { if (appConfigInstallTypes_.isEmpty()) { QJsonObject installTypes = appConfig_.get("install_types"); - foreach (const QString &key, installTypes.keys()) { + for (const QString &key : installTypes.keys()) { QJsonObject installtype = installTypes[key].toObject(); installtype["destination"] = convertPathString(installtype["destination"].toString()); installtype["generic_destination"] = convertPathString(installtype["generic_destination"].toString()); installTypes[key] = installtype; } QJsonObject installTypesAlias = appConfig_.get("install_types_alias"); - foreach (const QString &key, installTypesAlias.keys()) { + for (const QString &key : installTypesAlias.keys()) { QJsonObject installTypeAlias = installTypesAlias[key].toObject(); QString baseKey = installTypeAlias["base"].toString(); if (installTypes.contains(baseKey)) { diff --git a/app/src/handlers/itemhandler.cpp b/app/src/handlers/itemhandler.cpp index e7e7c82..6fe9a26 100644 --- a/app/src/handlers/itemhandler.cpp +++ b/app/src/handlers/itemhandler.cpp @@ -135,7 +135,7 @@ void ItemHandler::uninstall(const QString &itemKey) #ifdef QTLIB_UNIX destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["destination"].toString()); - foreach (const QJsonValue &filename, installedItem["files"].toArray()) { + for (const QJsonValue &filename : installedItem["files"].toArray()) { QFileInfo fileInfo(destDir.path() + "/" + filename.toString()); // plasmapkg: Installation process has should be saved plasmapkg into destination directory @@ -180,7 +180,7 @@ void ItemHandler::uninstall(const QString &itemKey) #else destDir.setPath(configHandler_->getAppConfigInstallTypes()[installType].toObject()["generic_destination"].toString()); - foreach (const QJsonValue &filename, installedItem["files"].toArray()) { + for (const QJsonValue &filename : installedItem["files"].toArray()) { QFileInfo fileInfo(destDir.path() + "/" + filename.toString()); if (fileInfo.isDir()) { qtlib::Dir(fileInfo.filePath()).remove(); @@ -392,7 +392,7 @@ void ItemHandler::installDownloadedFile(qtlib::NetworkResource *resource) destDir.make(); QJsonArray installedFiles; - foreach (const QFileInfo &fileInfo, tempDestDir.list()) { + for (const QFileInfo &fileInfo : tempDestDir.list()) { installedFiles.append(QJsonValue(fileInfo.fileName())); if (fileInfo.isDir()) { qtlib::Dir(fileInfo.filePath()).move(destDir.path() + "/" + fileInfo.fileName()); diff --git a/app/src/handlers/ocsapihandler.cpp b/app/src/handlers/ocsapihandler.cpp index 310ed88..eb5f075 100644 --- a/app/src/handlers/ocsapihandler.cpp +++ b/app/src/handlers/ocsapihandler.cpp @@ -14,7 +14,7 @@ bool OcsApiHandler::addProviders(const QString &providerFileUrl) { QJsonArray providers = qtlib::OcsApi::getProviderFile(QUrl(providerFileUrl)); if (!providers.isEmpty()) { - foreach (const QJsonValue &providerValue, providers) { + for (const QJsonValue &providerValue : providers) { QJsonObject provider = providerValue.toObject(); if (provider.contains("location")) { // Use location (API base URL) as unique key @@ -42,7 +42,7 @@ bool OcsApiHandler::updateAllCategories(bool force) { QJsonObject providers = configHandler_->getUsrConfigProviders(); if (!providers.isEmpty()) { - foreach (const QString &providerKey, providers.keys()) { + for (const QString &providerKey : providers.keys()) { updateCategories(providerKey, force); } return true; @@ -68,7 +68,7 @@ bool OcsApiHandler::updateCategories(const QString &providerKey, bool force) // Data type variation workaround, convert object to array QJsonArray responseData; if (response["data"].isObject()) { - foreach (const QJsonValue &dataValue, response["data"].toObject()) { + for (const QJsonValue &dataValue : response["data"].toObject()) { responseData.append(dataValue); } } @@ -85,7 +85,7 @@ bool OcsApiHandler::updateCategories(const QString &providerKey, bool force) } QJsonObject newProviderCategories; - foreach (const QJsonValue &dataValue, responseData) { + for (const QJsonValue &dataValue : responseData) { QJsonObject data = dataValue.toObject(); // Data type variation workaround, convert int to string @@ -152,13 +152,13 @@ QJsonObject OcsApiHandler::getContents(const QString &providerKeys, const QStrin QJsonObject providers = configHandler_->getUsrConfigProviders(); QJsonObject categories = configHandler_->getUsrConfigCategories(); - foreach (const QString &providerKey, providers.keys()) { + for (const QString &providerKey : providers.keys()) { if (!providerKeyList.isEmpty() && !providerKeyList.contains(providerKey)) { continue; } QStringList categoryIdList; QJsonObject providerCategories = categories[providerKey].toObject(); - foreach (const QString &categoryKey, providerCategories.keys()) { + for (const QString &categoryKey : providerCategories.keys()) { if (!categoryKeyList.isEmpty() && !categoryKeyList.contains(categoryKey)) { continue; } diff --git a/app/src/websockets/websocketserver.cpp b/app/src/websockets/websocketserver.cpp index 2ccc371..672bb73 100644 --- a/app/src/websockets/websocketserver.cpp +++ b/app/src/websockets/websocketserver.cpp @@ -346,7 +346,7 @@ void WebSocketServer::sendMessage(const QString &id, const QString &func, const QByteArray binaryMessage = qtlib::Json(object).toJson(); QString textMessage = QString::fromUtf8(binaryMessage); - foreach (QWebSocket *wsClient, wsClients_) { + for (QWebSocket *wsClient : wsClients_) { wsClient->sendTextMessage(textMessage); //wsClient->sendBinaryMessage(binaryMessage); } -- GitLab