From 2e0c074a9b47e62cbbb7297dcc00976bbfea77a3 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Thu, 27 Jun 2024 20:19:01 +0200 Subject: [PATCH] Port away from Quotient::Omittable --- src/definitions.h | 10 ++++++++++ src/events/imagepackevent.h | 18 ++++++++++-------- src/jobs/neochatadd3pidjob.h | 4 +++- src/jobs/neochatchangepasswordjob.h | 4 +++- src/jobs/neochatdeactivateaccountjob.h | 4 +++- src/jobs/neochatdeletedevicejob.h | 4 +++- src/models/searchmodel.cpp | 4 ++-- src/models/spacechildrenmodel.cpp | 5 +++-- src/registration.h | 6 ++++-- 9 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 src/definitions.h diff --git a/src/definitions.h b/src/definitions.h new file mode 100644 index 000000000..eae8c3149 --- /dev/null +++ b/src/definitions.h @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 Tobias Fella +// SPDX-License-Identifier: LGPL-2.0-or-later + +#if Quotient_VERSION_MINOR > 8 +#define Omittable std::optional +#define none Quotient::none +#else +#define Omittable Quotient::Omittable +#define none std::nullopt +#endif diff --git a/src/events/imagepackevent.h b/src/events/imagepackevent.h index 780d1bcb2..86fcb65f6 100644 --- a/src/events/imagepackevent.h +++ b/src/events/imagepackevent.h @@ -7,6 +7,8 @@ #include #include +#include "definitions.h" + namespace Quotient { /** @@ -26,10 +28,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). */ + Omittable displayName; /**< The display name of the pack. */ + Omittable avatarUrl; /**< The source mxc URL for the pack avatar. */ + Omittable usage; /**< An array of the usages for this pack. Possible usages are "emoticon" and "sticker". */ + Omittable attribution; /**< The attribution for the pack author(s). */ }; /** @@ -38,14 +40,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. */ + Omittable body; /**< An optional text body for this image. */ + Omittable 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; + Omittable usage; }; /** @@ -53,7 +55,7 @@ public: * * @sa Pack */ - Quotient::Omittable pack; + Omittable pack; /** * @brief Return a vector of images in the pack. diff --git a/src/jobs/neochatadd3pidjob.h b/src/jobs/neochatadd3pidjob.h index af17faba2..dfeaf97ea 100644 --- a/src/jobs/neochatadd3pidjob.h +++ b/src/jobs/neochatadd3pidjob.h @@ -6,8 +6,10 @@ #include #include +#include "definitions.h" + 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 Omittable &auth = {}); }; diff --git a/src/jobs/neochatchangepasswordjob.h b/src/jobs/neochatchangepasswordjob.h index ac4d76d25..0fc2033a1 100644 --- a/src/jobs/neochatchangepasswordjob.h +++ b/src/jobs/neochatchangepasswordjob.h @@ -6,8 +6,10 @@ #include #include +#include "definitions.h" + 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 Omittable &auth = {}); }; diff --git a/src/jobs/neochatdeactivateaccountjob.h b/src/jobs/neochatdeactivateaccountjob.h index ff2e9f4ec..3cbca9d48 100644 --- a/src/jobs/neochatdeactivateaccountjob.h +++ b/src/jobs/neochatdeactivateaccountjob.h @@ -6,8 +6,10 @@ #include #include +#include "definitions.h" + class NeoChatDeactivateAccountJob : public Quotient::BaseJob { public: - explicit NeoChatDeactivateAccountJob(const Quotient::Omittable &auth = Quotient::none); + explicit NeoChatDeactivateAccountJob(const Omittable &auth = {}); }; diff --git a/src/jobs/neochatdeletedevicejob.h b/src/jobs/neochatdeletedevicejob.h index 9b9e72e07..8cf10e32b 100644 --- a/src/jobs/neochatdeletedevicejob.h +++ b/src/jobs/neochatdeletedevicejob.h @@ -6,8 +6,10 @@ #include #include +#include "definitions.h" + class NeochatDeleteDeviceJob : public Quotient::BaseJob { public: - explicit NeochatDeleteDeviceJob(const QString &deviceId, const Quotient::Omittable &auth = Quotient::none); + explicit NeochatDeleteDeviceJob(const QString &deviceId, const Omittable &auth = {}); }; diff --git a/src/models/searchmodel.cpp b/src/models/searchmodel.cpp index cb8c6fca0..d250781de 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 = {}; 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 = {}, }; diff --git a/src/models/spacechildrenmodel.cpp b/src/models/spacechildrenmodel.cpp index d5e5df5cb..849f994cb 100644 --- a/src/models/spacechildrenmodel.cpp +++ b/src/models/spacechildrenmodel.cpp @@ -6,6 +6,7 @@ #include #include +#include "definitions.h" #include "neochatconnection.h" #include "neochatroom.h" @@ -87,7 +88,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(), none, none, 1); m_currentJobs.append(job); connect(job, &Quotient::BaseJob::success, this, [this, job]() { insertChildren(job->rooms()); @@ -136,7 +137,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, none, none, 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.h b/src/registration.h index aea7bbd44..7bda2003d 100644 --- a/src/registration.h +++ b/src/registration.h @@ -16,6 +16,8 @@ #include #include +#include "definitions.h" + namespace Quotient { class CheckUsernameAvailabilityJob; @@ -27,12 +29,12 @@ class NeoChatRegisterJob : public Quotient::BaseJob { public: explicit NeoChatRegisterJob(const QString &kind = QStringLiteral("user"), - const Quotient::Omittable &auth = Quotient::none, + const Omittable &auth = {}, const QString &username = {}, const QString &password = {}, const QString &deviceId = {}, const QString &initialDeviceDisplayName = {}, - Quotient::Omittable inhibitLogin = Quotient::none); + Omittable inhibitLogin = {}); QString userId() const {