From ff3d0346ebeb72b8083b2193a2fee7e4cceb6565 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 9 Dec 2020 15:14:00 +0800 Subject: [PATCH] Fix coding style --- src/webui/api/logcontroller.cpp | 32 +++++++++++++++----------------- src/webui/api/logcontroller.h | 2 +- src/webui/api/rsscontroller.h | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/webui/api/logcontroller.cpp b/src/webui/api/logcontroller.cpp index aeea35316..52dd1776f 100644 --- a/src/webui/api/logcontroller.cpp +++ b/src/webui/api/logcontroller.cpp @@ -76,18 +76,18 @@ void LogController::mainAction() for (const Log::Msg &msg : asConst(logger->getMessages(lastKnownId))) { - if (!((msg.type == Log::NORMAL && isNormal) - || (msg.type == Log::INFO && isInfo) - || (msg.type == Log::WARNING && isWarning) - || (msg.type == Log::CRITICAL && isCritical))) + if (!(((msg.type == Log::NORMAL) && isNormal) + || ((msg.type == Log::INFO) && isInfo) + || ((msg.type == Log::WARNING) && isWarning) + || ((msg.type == Log::CRITICAL) && isCritical))) continue; msgList.append(QJsonObject { - {KEY_LOG_ID, msg.id}, - {KEY_LOG_TIMESTAMP, msg.timestamp}, - {KEY_LOG_MSG_TYPE, msg.type}, - {KEY_LOG_MSG_MESSAGE, msg.message} + {QLatin1String(KEY_LOG_ID), msg.id}, + {QLatin1String(KEY_LOG_TIMESTAMP), msg.timestamp}, + {QLatin1String(KEY_LOG_MSG_TYPE), msg.type}, + {QLatin1String(KEY_LOG_MSG_MESSAGE), msg.message} }); } @@ -106,10 +106,8 @@ void LogController::mainAction() // - last_known_id (int): exclude messages with id <= 'last_known_id' (default -1) void LogController::peersAction() { - int lastKnownId; - bool ok; - - lastKnownId = params()["last_known_id"].toInt(&ok); + bool ok = false; + int lastKnownId = params()["last_known_id"].toInt(&ok); if (!ok) lastKnownId = -1; @@ -120,11 +118,11 @@ void LogController::peersAction() { peerList.append(QJsonObject { - {KEY_LOG_ID, peer.id}, - {KEY_LOG_TIMESTAMP, peer.timestamp}, - {KEY_LOG_PEER_IP, peer.ip}, - {KEY_LOG_PEER_BLOCKED, peer.blocked}, - {KEY_LOG_PEER_REASON, peer.reason} + {QLatin1String(KEY_LOG_ID), peer.id}, + {QLatin1String(KEY_LOG_TIMESTAMP), peer.timestamp}, + {QLatin1String(KEY_LOG_PEER_IP), peer.ip}, + {QLatin1String(KEY_LOG_PEER_BLOCKED), peer.blocked}, + {QLatin1String(KEY_LOG_PEER_REASON), peer.reason} }); } diff --git a/src/webui/api/logcontroller.h b/src/webui/api/logcontroller.h index 281d2e220..ebf048f9f 100644 --- a/src/webui/api/logcontroller.h +++ b/src/webui/api/logcontroller.h @@ -30,7 +30,7 @@ #include "apicontroller.h" -class LogController : public APIController +class LogController final : public APIController { Q_OBJECT Q_DISABLE_COPY(LogController) diff --git a/src/webui/api/rsscontroller.h b/src/webui/api/rsscontroller.h index ff99a685d..ec94dcbc0 100644 --- a/src/webui/api/rsscontroller.h +++ b/src/webui/api/rsscontroller.h @@ -30,7 +30,7 @@ #include "apicontroller.h" -class RSSController : public APIController +class RSSController final : public APIController { Q_OBJECT Q_DISABLE_COPY(RSSController)