#ifndef QMLOBJECTLISTHELPER_H #define QMLOBJECTLISTHELPER_H #include "QmlObjectListModel.h" #include template inline bool contains(const QmlObjectListModel &in, const PtrType toFind) { static_assert(std::is_pointer::value, "PtrType must be a pointer."); typedef typename std::remove_pointer::type Type; for (int i = 0; i < in.count(); ++i) { const auto obj = qobject_cast(in[i]); Q_ASSERT(obj != nullptr); Q_ASSERT(toFind != nullptr); if (*obj == *toFind) { return true; } } return false; } template inline bool equals(const QmlObjectListModel &list, const QmlObjectListModel &otherList) { static_assert(std::is_pointer::value, "PtrType must be a pointer."); typedef typename std::remove_pointer::type Type; if (list.count() == otherList.count()) { for (int i = 0; i < list.count(); ++i) { const auto obj = qobject_cast(list[i]); const auto otherObj = qobject_cast(otherList[i]); Q_ASSERT(obj != nullptr); Q_ASSERT(otherObj != nullptr); if (*obj != *otherObj) { return false; } } return true; } else { return false; } } #endif // QMLOBJECTLISTHELPER_H