diff --git a/src/eventhandler.cpp b/src/eventhandler.cpp index e013e4369..4d644dea8 100644 --- a/src/eventhandler.cpp +++ b/src/eventhandler.cpp @@ -254,7 +254,7 @@ QString EventHandler::rawMessageBody(const Quotient::RoomMessageEvent &event) QString body; if (event.hasTextContent() && event.content()) { - body = static_cast(event.content())->body; + body = static_cast(event.content())->body; } else { body = event.plainBody(); } @@ -478,7 +478,7 @@ QString EventHandler::getMessageBody(const RoomMessageEvent &event, Qt::TextForm QString body; if (event.hasTextContent() && event.content()) { - body = static_cast(event.content())->body; + body = static_cast(event.content())->body; } else { body = event.plainBody(); } diff --git a/src/events/imagepackevent.cpp b/src/events/imagepackevent.cpp index 6a909bd21..bad6290e9 100644 --- a/src/events/imagepackevent.cpp +++ b/src/events/imagepackevent.cpp @@ -3,6 +3,7 @@ #include "imagepackevent.h" #include +#include using namespace Quotient; @@ -16,16 +17,16 @@ ImagePackEventContent::ImagePackEventContent(const QJsonObject &json) fromJson>(json["pack"_ls].toObject()["attribution"_ls]), }; } else { - pack = none; + pack = std::nullopt; } 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 { - info = none; + info = std::nullopt; } images += ImagePackImage{ k, 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/neochatadd3pidjob.h b/src/jobs/neochatadd3pidjob.h index af17faba2..4c6fb3094 100644 --- a/src/jobs/neochatadd3pidjob.h +++ b/src/jobs/neochatadd3pidjob.h @@ -9,5 +9,5 @@ class NeochatAdd3PIdJob : public Quotient::BaseJob { public: - explicit NeochatAdd3PIdJob(const QString &clientSecret, const QString &sid, const Quotient::Omittable &auth = Quotient::none); + explicit NeochatAdd3PIdJob(const QString &clientSecret, const QString &sid, const Quotient::Omittable &auth = {}); }; diff --git a/src/jobs/neochatchangepasswordjob.h b/src/jobs/neochatchangepasswordjob.h index ac4d76d25..e4bad59ae 100644 --- a/src/jobs/neochatchangepasswordjob.h +++ b/src/jobs/neochatchangepasswordjob.h @@ -4,10 +4,11 @@ #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 Quotient::Omittable &auth = {}); }; diff --git a/src/jobs/neochatdeactivateaccountjob.h b/src/jobs/neochatdeactivateaccountjob.h index ff2e9f4ec..26e997f4c 100644 --- a/src/jobs/neochatdeactivateaccountjob.h +++ b/src/jobs/neochatdeactivateaccountjob.h @@ -9,5 +9,5 @@ class NeoChatDeactivateAccountJob : public Quotient::BaseJob { public: - explicit NeoChatDeactivateAccountJob(const Quotient::Omittable &auth = Quotient::none); + explicit NeoChatDeactivateAccountJob(const Quotient::Omittable &auth = {}); }; diff --git a/src/jobs/neochatdeletedevicejob.h b/src/jobs/neochatdeletedevicejob.h index 9b9e72e07..ff775db09 100644 --- a/src/jobs/neochatdeletedevicejob.h +++ b/src/jobs/neochatdeletedevicejob.h @@ -9,5 +9,5 @@ class NeochatDeleteDeviceJob : public Quotient::BaseJob { public: - explicit NeochatDeleteDeviceJob(const QString &deviceId, const Quotient::Omittable &auth = Quotient::none); + explicit NeochatDeleteDeviceJob(const QString &deviceId, const Quotient::Omittable &auth = {}); }; diff --git a/src/models/searchmodel.cpp b/src/models/searchmodel.cpp index cb8c6fca0..268d90a26 100644 --- a/src/models/searchmodel.cpp +++ b/src/models/searchmodel.cpp @@ -44,7 +44,7 @@ void SearchModel::search() } RoomEventFilter filter; - filter.unreadThreadNotifications = none; + filter.unreadThreadNotifications = std::nullopt; filter.lazyLoadMembers = true; filter.includeRedundantMembers = false; filter.notRooms = QStringList(); @@ -58,7 +58,7 @@ void SearchModel::search() .orderBy = "recent"_ls, .eventContext = SearchJob::IncludeEventContext{3, 3, true}, .includeState = false, - .groupings = none, + .groupings = 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 d4692f48f..f2160905f 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; + Omittable authData; if (nextStep() == "m.login.recaptcha"_ls) { authData = QJsonObject{ {"type"_ls, "m.login.recaptcha"_ls}, @@ -186,6 +186,7 @@ void Registration::testHomeserver() delete m_testServerJob; } m_testServerJob = m_connection->callApi("user"_ls, none, "user"_ls, QString(), QString(), QString(), false); + connect(m_testServerJob.data(), &BaseJob::finished, this, [this]() { if (m_testServerJob->error() == BaseJob::StatusCode::ContentAccessError) { setStatus(ServerNoRegistration); diff --git a/src/registration.h b/src/registration.h index aea7bbd44..ccf61d02f 100644 --- a/src/registration.h +++ b/src/registration.h @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -27,12 +28,12 @@ class NeoChatRegisterJob : public Quotient::BaseJob { public: explicit NeoChatRegisterJob(const QString &kind = QStringLiteral("user"), - const Quotient::Omittable &auth = Quotient::none, + const Quotient::Omittable &auth = {}, const QString &username = {}, const QString &password = {}, const QString &deviceId = {}, const QString &initialDeviceDisplayName = {}, - Quotient::Omittable inhibitLogin = Quotient::none); + Quotient::Omittable inhibitLogin = {}); QString userId() const { diff --git a/src/spacehierarchycache.cpp b/src/spacehierarchycache.cpp index d8089a962..98567b924 100644 --- a/src/spacehierarchycache.cpp +++ b/src/spacehierarchycache.cpp @@ -62,7 +62,7 @@ void SpaceHierarchyCache::populateSpaceHierarchy(const QString &spaceId) } m_nextBatchTokens[spaceId] = QString(); - auto job = m_connection->callApi(spaceId, none, none, none, *m_nextBatchTokens[spaceId]); + auto job = m_connection->callApi(spaceId, std::nullopt, std::nullopt, std::nullopt, *m_nextBatchTokens[spaceId]); auto group = KConfigGroup(KSharedConfig::openStateConfig("SpaceHierarchy"_ls), "Cache"_ls); m_spaceHierarchy.insert(spaceId, group.readEntry(spaceId, QStringList())); @@ -91,7 +91,7 @@ void SpaceHierarchyCache::addBatch(const QString &spaceId, Quotient::GetSpaceHie const auto nextBatchToken = job->nextBatch(); if (!nextBatchToken.isEmpty() && nextBatchToken != *m_nextBatchTokens[spaceId]) { *m_nextBatchTokens[spaceId] = nextBatchToken; - auto nextJob = m_connection->callApi(spaceId, none, none, none, *m_nextBatchTokens[spaceId]); + auto nextJob = m_connection->callApi(spaceId, std::nullopt, std::nullopt, std::nullopt, *m_nextBatchTokens[spaceId]); connect(nextJob, &BaseJob::success, this, [this, nextJob, spaceId]() { addBatch(spaceId, nextJob); });