Use QStringLiteral
This commit is contained in:
@@ -80,10 +80,10 @@ QUrl SubsonicBaseRequest::CreateUrl(const QUrl &server_url, const SubsonicSettin
|
||||
QUrl url(server_url);
|
||||
|
||||
if (!url.path().isEmpty() && url.path().right(1) == "/") {
|
||||
url.setPath(url.path() + QString("rest/") + ressource_name + QString(".view"));
|
||||
url.setPath(url.path() + QStringLiteral("rest/") + ressource_name + QStringLiteral(".view"));
|
||||
}
|
||||
else {
|
||||
url.setPath(url.path() + QString("/rest/") + ressource_name + QString(".view"));
|
||||
url.setPath(url.path() + QStringLiteral("/rest/") + ressource_name + QStringLiteral(".view"));
|
||||
}
|
||||
|
||||
url.setQuery(url_query);
|
||||
@@ -137,7 +137,7 @@ QByteArray SubsonicBaseRequest::GetReplyData(QNetworkReply *reply) {
|
||||
else {
|
||||
if (reply->error() != QNetworkReply::NoError && reply->error() < 200) {
|
||||
// This is a network error, there is nothing more to do.
|
||||
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||
Error(QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -148,24 +148,24 @@ QByteArray SubsonicBaseRequest::GetReplyData(QNetworkReply *reply) {
|
||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &parse_error);
|
||||
if (parse_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (!json_obj.isEmpty() && json_obj.contains("error")) {
|
||||
QJsonValue json_error = json_obj["error"];
|
||||
if (!json_obj.isEmpty() && json_obj.contains(QStringLiteral("error"))) {
|
||||
QJsonValue json_error = json_obj[QStringLiteral("error")];
|
||||
if (json_error.isObject()) {
|
||||
json_obj = json_error.toObject();
|
||||
if (!json_obj.isEmpty() && json_obj.contains("code") && json_obj.contains("message")) {
|
||||
int code = json_obj["code"].toInt();
|
||||
QString message = json_obj["message"].toString();
|
||||
error = QString("%1 (%2)").arg(message).arg(code);
|
||||
if (!json_obj.isEmpty() && json_obj.contains(QStringLiteral("code")) && json_obj.contains(QStringLiteral("message"))) {
|
||||
int code = json_obj[QStringLiteral("code")].toInt();
|
||||
QString message = json_obj[QStringLiteral("message")].toString();
|
||||
error = QStringLiteral("%1 (%2)").arg(message).arg(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error.isEmpty()) {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
error = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||
error = QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||
}
|
||||
else {
|
||||
error = QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
|
||||
error = QStringLiteral("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
|
||||
}
|
||||
}
|
||||
Error(error);
|
||||
@@ -182,34 +182,34 @@ QJsonObject SubsonicBaseRequest::ExtractJsonObj(QByteArray &data) {
|
||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||
|
||||
if (json_error.error != QJsonParseError::NoError) {
|
||||
Error("Reply from server missing Json data.", data);
|
||||
Error(QStringLiteral("Reply from server missing Json data."), data);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
if (json_doc.isEmpty()) {
|
||||
Error("Received empty Json document.", data);
|
||||
Error(QStringLiteral("Received empty Json document."), data);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
if (!json_doc.isObject()) {
|
||||
Error("Json document is not an object.", json_doc);
|
||||
Error(QStringLiteral("Json document is not an object."), json_doc);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
QJsonObject json_obj = json_doc.object();
|
||||
if (json_obj.isEmpty()) {
|
||||
Error("Received empty Json object.", json_doc);
|
||||
Error(QStringLiteral("Received empty Json object."), json_doc);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
if (!json_obj.contains("subsonic-response")) {
|
||||
Error("Json reply is missing subsonic-response.", json_obj);
|
||||
if (!json_obj.contains(QStringLiteral("subsonic-response"))) {
|
||||
Error(QStringLiteral("Json reply is missing subsonic-response."), json_obj);
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
QJsonValue json_response = json_obj["subsonic-response"];
|
||||
QJsonValue json_response = json_obj[QStringLiteral("subsonic-response")];
|
||||
if (!json_response.isObject()) {
|
||||
Error("Json response is not an object.", json_response);
|
||||
Error(QStringLiteral("Json response is not an object."), json_response);
|
||||
return QJsonObject();
|
||||
}
|
||||
json_obj = json_response.toObject();
|
||||
|
||||
Reference in New Issue
Block a user