aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/events/encryptionevent.h2
-rw-r--r--lib/events/event.h23
-rw-r--r--lib/events/roommemberevent.h2
-rw-r--r--lib/events/roommessageevent.h2
-rw-r--r--lib/joinstate.h2
-rw-r--r--lib/room.cpp10
-rw-r--r--lib/syncdata.cpp2
-rw-r--r--lib/util.h65
8 files changed, 20 insertions, 88 deletions
diff --git a/lib/events/encryptionevent.h b/lib/events/encryptionevent.h
index 7bbcc418..cbd3ba4a 100644
--- a/lib/events/encryptionevent.h
+++ b/lib/events/encryptionevent.h
@@ -66,7 +66,7 @@ public:
int rotationPeriodMsgs() const { return content().rotationPeriodMsgs; }
private:
- REGISTER_ENUM(EncryptionType)
+ Q_ENUM(EncryptionType)
};
REGISTER_EVENT_TYPE(EncryptionEvent)
diff --git a/lib/events/event.h b/lib/events/event.h
index d9c8e088..25362786 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -47,11 +47,10 @@ inline TargetEventT* weakPtrCast(const event_ptr_tt<EventT>& ptr)
/// Re-wrap a smart pointer to base into a smart pointer to derived
template <typename TargetT, typename SourceT>
-[[deprecated("Consider using eventCast() or visit() "
- "instead")]] inline event_ptr_tt<TargetT>
-ptrCast(event_ptr_tt<SourceT>&& ptr)
+[[deprecated("Consider using eventCast() or visit() instead")]]
+inline event_ptr_tt<TargetT> ptrCast(event_ptr_tt<SourceT>&& ptr)
{
- return unique_ptr_cast<TargetT>(ptr);
+ return std::unique_ptr<TargetT>(static_cast<TargetT*>(ptr.release()));
}
// === Standard Matrix key names and basicEventJson() ===
@@ -290,19 +289,19 @@ using Events = EventsArray<Event>;
// This macro should be used in a public section of an event class to
// provide matrixTypeId() and typeId().
-#define DEFINE_EVENT_TYPEID(_Id, _Type) \
- static constexpr event_mtype_t matrixTypeId() { return _Id; } \
- static auto typeId() { return Quotient::typeId<_Type>(); } \
+#define DEFINE_EVENT_TYPEID(_Id, _Type) \
+ static constexpr event_mtype_t matrixTypeId() { return _Id; } \
+ static auto typeId() { return Quotient::typeId<_Type>(); } \
// End of macro
// This macro should be put after an event class definition (in .h or .cpp)
// to enable its deserialisation from a /sync and other
// polymorphic event arrays
-#define REGISTER_EVENT_TYPE(_Type) \
- namespace { \
- [[gnu::unused]] static const auto _factoryAdded##_Type = \
- registerEventType<_Type>(); \
- } \
+#define REGISTER_EVENT_TYPE(_Type) \
+ namespace { \
+ [[maybe_unused]] static const auto _factoryAdded##_Type = \
+ registerEventType<_Type>(); \
+ } \
// End of macro
// === is<>(), eventCast<>() and visit<>() ===
diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h
index 43aaa8be..6a34fd7f 100644
--- a/lib/events/roommemberevent.h
+++ b/lib/events/roommemberevent.h
@@ -92,7 +92,7 @@ public:
bool isAvatarUpdate() const;
private:
- REGISTER_ENUM(MembershipType)
+ Q_ENUM(MembershipType)
};
template <>
diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h
index d0dbbfb3..b393382a 100644
--- a/lib/events/roommessageevent.h
+++ b/lib/events/roommessageevent.h
@@ -87,7 +87,7 @@ private:
const QString& jsonMsgType,
EventContent::TypedBase* content);
- REGISTER_ENUM(MsgType)
+ Q_ENUM(MsgType)
};
REGISTER_EVENT_TYPE(RoomMessageEvent)
using MessageEventType = RoomMessageEvent::MsgType;
diff --git a/lib/joinstate.h b/lib/joinstate.h
index 718ae3fd..31c2b6a7 100644
--- a/lib/joinstate.h
+++ b/lib/joinstate.h
@@ -31,7 +31,7 @@ enum class JoinState : unsigned int {
Q_DECLARE_FLAGS(JoinStates, JoinState)
-// We cannot use REGISTER_ENUM outside of a Q_OBJECT and besides, we want
+// We cannot use Q_ENUM outside of a Q_OBJECT and besides, we want
// to use strings that match respective JSON keys.
static const std::array<const char*, 3> JoinStateStrings { { "join", "invite",
"leave" } };
diff --git a/lib/room.cpp b/lib/room.cpp
index d8fee5aa..f70e0b0e 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -1050,22 +1050,12 @@ FileTransferInfo Room::fileTransferInfo(const QString& id) const
total = INT_MAX;
}
-#ifdef BROKEN_INITIALIZER_LISTS
- FileTransferInfo fti;
- fti.status = infoIt->status;
- fti.progress = int(progress);
- fti.total = int(total);
- fti.localDir = QUrl::fromLocalFile(infoIt->localFileInfo.absolutePath());
- fti.localPath = QUrl::fromLocalFile(infoIt->localFileInfo.absoluteFilePath());
- return fti;
-#else
return { infoIt->status,
infoIt->isUpload,
int(progress),
int(total),
QUrl::fromLocalFile(infoIt->localFileInfo.absolutePath()),
QUrl::fromLocalFile(infoIt->localFileInfo.absoluteFilePath()) };
-#endif
}
QUrl Room::fileSource(const QString& id) const
diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp
index 5fcc8dda..5b47b30f 100644
--- a/lib/syncdata.cpp
+++ b/lib/syncdata.cpp
@@ -92,7 +92,7 @@ SyncRoomData::SyncRoomData(const QString& roomId_, JoinState joinState_,
switch (joinState) {
case JoinState::Join:
ephemeral = load<Events>(room_, "ephemeral"_ls);
- FALLTHROUGH;
+ [[fallthrough]];
case JoinState::Leave: {
accountData = load<Events>(room_, "account_data"_ls);
timeline = load<RoomEvents>(room_, "timeline"_ls);
diff --git a/lib/util.h b/lib/util.h
index 12d3f8ba..7c79804b 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -20,73 +20,15 @@
#include <QtCore/QLatin1String>
-#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
-# include <QtCore/QDebug>
-# include <QtCore/QMetaEnum>
-#endif
-
#include <functional>
#include <memory>
-#if __has_cpp_attribute(fallthrough)
-# define FALLTHROUGH [[fallthrough]]
-#elif __has_cpp_attribute(clang::fallthrough)
-# define FALLTHROUGH [[clang::fallthrough]]
-#elif __has_cpp_attribute(gnu::fallthrough)
-# define FALLTHROUGH [[gnu::fallthrough]]
-#else
-# define FALLTHROUGH // -fallthrough
-#endif
-
-// Along the lines of Q_DISABLE_COPY
+// Along the lines of Q_DISABLE_COPY - the upstream version comes in Qt 5.13
#define DISABLE_MOVE(_ClassName) \
_ClassName(_ClassName&&) Q_DECL_EQ_DELETE; \
_ClassName& operator=(_ClassName&&) Q_DECL_EQ_DELETE;
-#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
-// Copy-pasted from Qt 5.10
-template <typename T>
-Q_DECL_CONSTEXPR typename std::add_const<T>::type& qAsConst(T& t) Q_DECL_NOTHROW
-{
- return t;
-}
-// prevent rvalue arguments:
-template <typename T>
-static void qAsConst(const T&&) Q_DECL_EQ_DELETE;
-#endif
-
-// MSVC 2015 and older GCC's don't handle initialisation from initializer lists
-// right in the absense of a constructor; MSVC 2015, notably, fails with
-// "error C2440: 'return': cannot convert from 'initializer list' to '<type>'"
-#if (defined(_MSC_VER) && _MSC_VER < 1910) \
- || (defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 4)
-# define BROKEN_INITIALIZER_LISTS
-#endif
-
namespace Quotient {
-// The below enables pretty-printing of enums in logs
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
-# define REGISTER_ENUM(EnumName) Q_ENUM(EnumName)
-#else
-// Thanks to Olivier for spelling it and for making Q_ENUM to replace it:
-// https://woboq.com/blog/q_enum.html
-# define REGISTER_ENUM(EnumName) \
- Q_ENUMS(EnumName) \
- friend QDebug operator<<(QDebug dbg, EnumName val) \
- { \
- static int enumIdx = staticMetaObject.indexOfEnumerator(#EnumName); \
- return dbg << Event::staticMetaObject.enumerator(enumIdx).valueToKey( \
- int(val)); \
- }
-#endif
-
-/** static_cast<> for unique_ptr's */
-template <typename T1, typename PtrT2>
-inline auto unique_ptr_cast(PtrT2&& p)
-{
- return std::unique_ptr<T1>(static_cast<T1*>(p.release()));
-}
-
struct NoneTag {};
constexpr NoneTag none {};
@@ -185,7 +127,8 @@ namespace _impl {
struct fn_traits;
}
-/** Determine traits of an arbitrary function/lambda/functor
+/// Determine traits of an arbitrary function/lambda/functor
+/*!
* Doesn't work with generic lambdas and function objects that have
* operator() overloaded.
* \sa
@@ -332,4 +275,4 @@ qreal stringToHueF(const QString& s);
QString serverPart(const QString& mxId);
} // namespace Quotient
/// \deprecated Use namespace Quotient instead
-namespace QMatrixClient = Quotient; \ No newline at end of file
+namespace QMatrixClient = Quotient;