void ObjectNodeInstance::deleteObjectsInList(const QQmlProperty &property) { QObjectList objectList; QQmlListReference list = qvariant_cast<QQmlListReference>(property.read()); if (!QmlPrivateGate::hasFullImplementedListInterface(list)) { qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!"; return; } for (int i = 0; i < list.count(); i++) { objectList += list.at(i); } list.clear(); }
static void removeObjectFromList(const QQmlProperty &property, QObject *objectToBeRemoved, QQmlEngine * engine) { QQmlListReference listReference(property.object(), property.name().toUtf8(), engine); if (!QmlPrivateGate::hasFullImplementedListInterface(listReference)) { qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!"; return; } int count = listReference.count(); QObjectList objectList; for (int i = 0; i < count; i ++) { QObject *listItem = listReference.at(i); if (listItem && listItem != objectToBeRemoved) objectList.append(listItem); } listReference.clear(); foreach (QObject *object, objectList) listReference.append(object); }