Updates for Qt 5.8.

This commit is contained in:
Mathew Sutcliffe
2017-02-10 02:22:02 +00:00
parent b6f6e0f676
commit fe3c97e37f
3 changed files with 3 additions and 17 deletions

View File

@@ -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())));
}

View File

@@ -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;
}

View File

@@ -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) });
}