mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Updates for Qt 5.8.
This commit is contained in:
@@ -29,10 +29,6 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#if QT_VERSION >= 0x50701
|
||||
#define BLACK_USE_LATIN1_JSON_KEYS
|
||||
#endif
|
||||
|
||||
class QDateTime;
|
||||
class QPixmap;
|
||||
class QStringList;
|
||||
@@ -53,17 +49,8 @@ namespace BlackMisc
|
||||
//! Implicit constructor.
|
||||
Q_DECL_CONSTEXPR CExplicitLatin1String(QLatin1String s) : m_latin1(s) {}
|
||||
|
||||
#ifdef BLACK_USE_LATIN1_JSON_KEYS
|
||||
//! Type usable as key in QJsonObject.
|
||||
Q_DECL_CONSTEXPR auto toJsonKey() const { return *this; }
|
||||
//! Implicit conversion.
|
||||
Q_DECL_CONSTEXPR operator QLatin1String() const { return m_latin1; }
|
||||
#else
|
||||
//! Type usable as key in QJsonObject.
|
||||
QString toJsonKey() const { return m_latin1; }
|
||||
//! Implicit conversion.
|
||||
operator QString() const { return m_latin1; }
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@@ -357,7 +344,7 @@ namespace BlackMisc
|
||||
auto meta = introspect<Derived>().without(MetaFlags<DisabledForJson>());
|
||||
meta.forEachMember([ &, this ](auto member)
|
||||
{
|
||||
json << std::make_pair(CExplicitLatin1String(member.latin1Name()).toJsonKey(), std::cref(member.in(*this->derived())));
|
||||
json << std::make_pair(CExplicitLatin1String(member.latin1Name()), std::cref(member.in(*this->derived())));
|
||||
});
|
||||
return Json::appendJsonObject(json, baseToJson(static_cast<const TBaseOfT<Derived> *>(derived())));
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace BlackMisc
|
||||
meta.forEachMember([ &, this ](auto member)
|
||||
{
|
||||
auto &&maybeMemo = helper.maybeMemoize(member.in(*this));
|
||||
json << std::make_pair(CExplicitLatin1String(member.latin1Name()).toJsonKey(), std::cref(maybeMemo));
|
||||
json << std::make_pair(CExplicitLatin1String(member.latin1Name()), std::cref(maybeMemo));
|
||||
});
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -372,7 +372,6 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Set a callback to be called when the value is changed by another source.
|
||||
//! \todo Qt 5.7.0: in assert use m_page->parent()->metaObject()->inherits(&U::staticMetaObject)
|
||||
template <typename F>
|
||||
void setNotifySlot(F slot)
|
||||
{
|
||||
@@ -382,7 +381,7 @@ namespace BlackMisc
|
||||
return;
|
||||
}
|
||||
using U = typename Private::TClassOfPointerToMember<F>::type;
|
||||
Q_ASSERT_X(m_page->parent()->inherits(U::staticMetaObject.className()), Q_FUNC_INFO, "Slot is member function of wrong class");
|
||||
Q_ASSERT_X(m_page->parent()->metaObject()->inherits(&U::staticMetaObject), Q_FUNC_INFO, "Slot is member function of wrong class");
|
||||
m_page->setNotifySlot(*m_element, { [slot](QObject *obj) { Private::invokeSlot(slot, static_cast<U *>(obj)); }, makeId(slot) });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user