diff --git a/src/events/imagepackevent.cpp b/src/events/imagepackevent.cpp index 6a909bd21..2fd2977bd 100644 --- a/src/events/imagepackevent.cpp +++ b/src/events/imagepackevent.cpp @@ -10,10 +10,10 @@ ImagePackEventContent::ImagePackEventContent(const QJsonObject &json) { if (json.contains(QStringLiteral("pack"))) { pack = ImagePackEventContent::Pack{ - fromJson>(json["pack"_ls].toObject()["display_name"_ls]), - fromJson>(json["pack"_ls].toObject()["avatar_url"_ls]), - fromJson>(json["pack"_ls].toObject()["usage"_ls]), - fromJson>(json["pack"_ls].toObject()["attribution"_ls]), + fromJson>(json["pack"_ls].toObject()["display_name"_ls]), + fromJson>(json["pack"_ls].toObject()["avatar_url"_ls]), + fromJson>(json["pack"_ls].toObject()["usage"_ls]), + fromJson>(json["pack"_ls].toObject()["attribution"_ls]), }; } else { pack = none; @@ -21,7 +21,7 @@ ImagePackEventContent::ImagePackEventContent(const QJsonObject &json) const auto &keys = json["images"_ls].toObject().keys(); for (const auto &k : keys) { - Omittable info; + std::optional info; if (json["images"_ls][k].toObject().contains(QStringLiteral("info"))) { info = EventContent::ImageInfo(QUrl(json["images"_ls][k]["url"_ls].toString()), json["images"_ls][k]["info"_ls].toObject(), k); } else { @@ -30,9 +30,9 @@ ImagePackEventContent::ImagePackEventContent(const QJsonObject &json) images += ImagePackImage{ k, fromJson(json["images"_ls][k]["url"_ls].toString()), - fromJson>(json["images"_ls][k]["body"_ls]), + fromJson>(json["images"_ls][k]["body"_ls]), info, - fromJson>(json["images"_ls][k]["usage"_ls]), + fromJson>(json["images"_ls][k]["usage"_ls]), }; } } diff --git a/src/events/imagepackevent.h b/src/events/imagepackevent.h index 780d1bcb2..cae4ab189 100644 --- a/src/events/imagepackevent.h +++ b/src/events/imagepackevent.h @@ -26,10 +26,10 @@ public: * @brief Defines the properties of an image pack. */ struct Pack { - Quotient::Omittable displayName; /**< The display name of the pack. */ - Quotient::Omittable avatarUrl; /**< The source mxc URL for the pack avatar. */ - Quotient::Omittable usage; /**< An array of the usages for this pack. Possible usages are "emoticon" and "sticker". */ - Quotient::Omittable attribution; /**< The attribution for the pack author(s). */ + std::optional displayName; /**< The display name of the pack. */ + std::optional avatarUrl; /**< The source mxc URL for the pack avatar. */ + std::optional usage; /**< An array of the usages for this pack. Possible usages are "emoticon" and "sticker". */ + std::optional attribution; /**< The attribution for the pack author(s). */ }; /** @@ -38,14 +38,14 @@ public: struct ImagePackImage { QString shortcode; /**< The shortcode for the image. */ QUrl url; /**< The mxc URL for this image. */ - Quotient::Omittable body; /**< An optional text body for this image. */ - Quotient::Omittable info; /**< The ImageInfo object used for the info block of m.sticker events. */ + std::optional body; /**< An optional text body for this image. */ + std::optional info; /**< The ImageInfo object used for the info block of m.sticker events. */ /** * @brief An array of the usages for this image. * * The possible values match those of the usage key of a pack object. */ - Quotient::Omittable usage; + std::optional usage; }; /** @@ -53,7 +53,7 @@ public: * * @sa Pack */ - Quotient::Omittable pack; + std::optional pack; /** * @brief Return a vector of images in the pack. diff --git a/src/jobs/neochatchangepasswordjob.cpp b/src/jobs/neochatchangepasswordjob.cpp index dec09ef8f..9be9fa7b8 100644 --- a/src/jobs/neochatchangepasswordjob.cpp +++ b/src/jobs/neochatchangepasswordjob.cpp @@ -5,7 +5,7 @@ using namespace Quotient; -NeochatChangePasswordJob::NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Omittable &auth) +NeochatChangePasswordJob::NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const std::optional &auth) : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), "/_matrix/client/r0/account/password") { QJsonObject _data; diff --git a/src/jobs/neochatchangepasswordjob.h b/src/jobs/neochatchangepasswordjob.h index ac4d76d25..b890b1375 100644 --- a/src/jobs/neochatchangepasswordjob.h +++ b/src/jobs/neochatchangepasswordjob.h @@ -4,10 +4,9 @@ #pragma once #include -#include class NeochatChangePasswordJob : public Quotient::BaseJob { public: - explicit NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const Quotient::Omittable &auth = Quotient::none); + explicit NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const std::optional &auth = std::nullopt); }; diff --git a/src/jobs/neochatdeactivateaccountjob.cpp b/src/jobs/neochatdeactivateaccountjob.cpp index 398a7df72..081e2ed8f 100644 --- a/src/jobs/neochatdeactivateaccountjob.cpp +++ b/src/jobs/neochatdeactivateaccountjob.cpp @@ -5,7 +5,7 @@ using namespace Quotient; -NeoChatDeactivateAccountJob::NeoChatDeactivateAccountJob(const Omittable &auth) +NeoChatDeactivateAccountJob::NeoChatDeactivateAccountJob(const std::optional &auth) : BaseJob(HttpVerb::Post, QStringLiteral("DisableDeviceJob"), "_matrix/client/v3/account/deactivate") { QJsonObject data; diff --git a/src/jobs/neochatdeactivateaccountjob.h b/src/jobs/neochatdeactivateaccountjob.h index ff2e9f4ec..a0140f813 100644 --- a/src/jobs/neochatdeactivateaccountjob.h +++ b/src/jobs/neochatdeactivateaccountjob.h @@ -4,10 +4,9 @@ #pragma once #include -#include class NeoChatDeactivateAccountJob : public Quotient::BaseJob { public: - explicit NeoChatDeactivateAccountJob(const Quotient::Omittable &auth = Quotient::none); + explicit NeoChatDeactivateAccountJob(const std::optional &auth = std::nullopt); }; diff --git a/src/jobs/neochatdeletedevicejob.cpp b/src/jobs/neochatdeletedevicejob.cpp index 0283d41f2..08771cc08 100644 --- a/src/jobs/neochatdeletedevicejob.cpp +++ b/src/jobs/neochatdeletedevicejob.cpp @@ -5,7 +5,7 @@ using namespace Quotient; -NeochatDeleteDeviceJob::NeochatDeleteDeviceJob(const QString &deviceId, const Omittable &auth) +NeochatDeleteDeviceJob::NeochatDeleteDeviceJob(const QString &deviceId, const std::optional &auth) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteDeviceJob"), QStringLiteral("/_matrix/client/r0/devices/%1").arg(deviceId).toLatin1()) { QJsonObject _data; diff --git a/src/jobs/neochatdeletedevicejob.h b/src/jobs/neochatdeletedevicejob.h index 9b9e72e07..2eed9496e 100644 --- a/src/jobs/neochatdeletedevicejob.h +++ b/src/jobs/neochatdeletedevicejob.h @@ -4,10 +4,9 @@ #pragma once #include -#include class NeochatDeleteDeviceJob : public Quotient::BaseJob { public: - explicit NeochatDeleteDeviceJob(const QString &deviceId, const Quotient::Omittable &auth = Quotient::none); + explicit NeochatDeleteDeviceJob(const QString &deviceId, const std::optional &auth = std::nullopt); }; diff --git a/src/models/spacechildrenmodel.cpp b/src/models/spacechildrenmodel.cpp index d5e5df5cb..1ce120336 100644 --- a/src/models/spacechildrenmodel.cpp +++ b/src/models/spacechildrenmodel.cpp @@ -87,7 +87,7 @@ void SpaceChildrenModel::refreshModel() m_rootItem = new SpaceTreeItem(dynamic_cast(m_space->connection()), nullptr, m_space->id(), m_space->displayName(), m_space->canonicalAlias()); endResetModel(); - auto job = m_space->connection()->callApi(m_space->id(), Quotient::none, Quotient::none, 1); + auto job = m_space->connection()->callApi(m_space->id(), std::nullopt, std::nullopt, 1); m_currentJobs.append(job); connect(job, &Quotient::BaseJob::success, this, [this, job]() { insertChildren(job->rooms()); @@ -136,7 +136,7 @@ void SpaceChildrenModel::insertChildren(std::vector 0) { - auto job = m_space->connection()->callApi(children[i].roomId, Quotient::none, Quotient::none, 1); + auto job = m_space->connection()->callApi(children[i].roomId, std::nullopt, std::nullopt, 1); m_currentJobs.append(job); connect(job, &Quotient::BaseJob::success, this, [this, parent, insertRow, job]() { insertChildren(job->rooms(), index(insertRow, 0, parent)); diff --git a/src/registration.cpp b/src/registration.cpp index e20d44d26..11303cf9f 100644 --- a/src/registration.cpp +++ b/src/registration.cpp @@ -63,7 +63,7 @@ QString Registration::recaptchaSiteKey() const void Registration::registerAccount() { setStatus(Working); - Omittable authData = none; + std::optional authData = none; if (nextStep() == "m.login.recaptcha"_ls) { authData = QJsonObject{ {"type"_ls, "m.login.recaptcha"_ls}, @@ -244,12 +244,12 @@ void Registration::setPassword(const QString &password) } NeoChatRegisterJob::NeoChatRegisterJob(const QString &kind, - const Omittable &auth, + const std::optional &auth, const QString &username, const QString &password, const QString &deviceId, const QString &initialDeviceDisplayName, - Omittable inhibitLogin) + std::optional inhibitLogin) : BaseJob(HttpVerb::Post, "RegisterJob"_ls, QByteArrayLiteral("/_matrix/client/r0/register"), false) { QJsonObject _data; diff --git a/src/registration.h b/src/registration.h index aea7bbd44..f0053968e 100644 --- a/src/registration.h +++ b/src/registration.h @@ -27,12 +27,12 @@ class NeoChatRegisterJob : public Quotient::BaseJob { public: explicit NeoChatRegisterJob(const QString &kind = QStringLiteral("user"), - const Quotient::Omittable &auth = Quotient::none, + const std::optional &auth = std::nullopt, const QString &username = {}, const QString &password = {}, const QString &deviceId = {}, const QString &initialDeviceDisplayName = {}, - Quotient::Omittable inhibitLogin = Quotient::none); + std::optional inhibitLogin = std::nullopt); QString userId() const {