diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-06-06 20:15:18 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-06-22 16:18:48 +0900 |
commit | 7150b8e864f0a2b9ba602bb56384f7f521f4098d (patch) | |
tree | 3118132475ee79ba1d78bf53cda7d71c49ed1b00 | |
parent | db75ffed3f1555a99d0c4eb31827990f316d3b3b (diff) | |
download | libquotient-7150b8e864f0a2b9ba602bb56384f7f521f4098d.tar.gz libquotient-7150b8e864f0a2b9ba602bb56384f7f521f4098d.zip |
BaseJob::* facility classes: better construction
Use std::initializer_list instead of QList<> because we actually want to construct from initializer lists; and only enable Data(std::initializer_list) for older Qt's that don't have the same on the level of QJsonObject.
-rw-r--r-- | jobs/basejob.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/jobs/basejob.h b/jobs/basejob.h index 2be4577f..0ec40a7a 100644 --- a/jobs/basejob.h +++ b/jobs/basejob.h @@ -63,7 +63,7 @@ namespace QMatrixClient public: using QUrlQuery::QUrlQuery; Query() = default; - explicit Query(const QList< QPair<QString, QString> >& l) + explicit Query(const std::initializer_list< QPair<QString, QString> >& l) { setQueryItems(l); } @@ -78,11 +78,16 @@ namespace QMatrixClient { public: Data() = default; - explicit Data(const QList< QPair<QString, QString> >& l) + Data(const QJsonObject& o) : QJsonObject(o) { } + Data(QJsonObject&& o) : QJsonObject(std::move(o)) { } +#if (QT_VERSION < QT_VERSION_CHECK(5, 4, 0)) + // This method exists in QJsonObject of newer Qt versions + explicit Data(const std::initializer_list< QPair<QString, QString> >& l) { for (auto i: l) insert(i.first, i.second); } +#endif QByteArray serialize() const { return QJsonDocument(*this).toJson(); |