Clean-up methods with default values in JSON classes

Task-number: QTBUG-85700
Change-Id: I46e7c58e4cc94cf19cd9f11e03d2a498cd0c8922
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Sona Kurazyan 2020-07-24 11:29:30 +02:00
parent 062bee3a2a
commit 089d72d7d9
3 changed files with 5 additions and 24 deletions

View File

@ -450,18 +450,6 @@ QVariant QJsonDocument::toVariant() const
return QJsonObject(container).toVariantMap();
}
/*!
Converts the QJsonDocument to an indented, UTF-8 encoded JSON document.
\sa fromJson()
*/
#if !defined(QT_JSON_READONLY) || defined(Q_CLANG_QDOC)
QByteArray QJsonDocument::toJson() const
{
return toJson(Indented);
}
#endif
/*!
\enum QJsonDocument::JsonFormat
\since 5.1

View File

@ -136,8 +136,7 @@ public:
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = nullptr);
#if !defined(QT_JSON_READONLY) || defined(Q_CLANG_QDOC)
QByteArray toJson() const; //### Merge in Qt6
QByteArray toJson(JsonFormat format) const;
QByteArray toJson(JsonFormat format = Indented) const;
#endif
bool isEmpty() const;

View File

@ -180,19 +180,13 @@ public:
inline bool isObject() const { return type() == QJsonValue::Object; }
inline bool isUndefined() const { return type() == QJsonValue::Undefined; }
inline bool toBool() const { return toValue().toBool(); }
inline int toInt() const { return toValue().toInt(); }
inline double toDouble() const { return toValue().toDouble(); }
inline QString toString() const { return toValue().toString(); }
inline bool toBool(bool defaultValue = false) const { return toValue().toBool(defaultValue); }
inline int toInt(int defaultValue = 0) const { return toValue().toInt(defaultValue); }
inline double toDouble(double defaultValue = 0) const { return toValue().toDouble(defaultValue); }
inline QString toString(const QString &defaultValue = {}) const { return toValue().toString(defaultValue); }
QJsonArray toArray() const;
QJsonObject toObject() const;
// ### Qt 6: Add default values
inline bool toBool(bool defaultValue) const { return toValue().toBool(defaultValue); }
inline int toInt(int defaultValue) const { return toValue().toInt(defaultValue); }
inline double toDouble(double defaultValue) const { return toValue().toDouble(defaultValue); }
inline QString toString(const QString &defaultValue) const { return toValue().toString(defaultValue); }
inline bool operator==(const QJsonValue &other) const { return toValue() == other; }
inline bool operator!=(const QJsonValue &other) const { return toValue() != other; }