本文整理汇总了C++中QDeclarativeListReference::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeListReference::count方法的具体用法?C++ QDeclarativeListReference::count怎么用?C++ QDeclarativeListReference::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeListReference
的用法示例。
在下文中一共展示了QDeclarativeListReference::count方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertObjectInListProperty
bool insertObjectInListProperty(QDeclarativeListReference &fromList, int position, QObject *object)
{
QList<QObject *> tmpList;
int i;
if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
return false;
if (position == fromList.count()) {
fromList.append(object);
return true;
}
for (i=0; i<fromList.count(); ++i)
tmpList << fromList.at(i);
fromList.clear();
for (i=0; i<position; ++i)
fromList.append(tmpList.at(i));
fromList.append(object);
for (; i<tmpList.count(); ++i)
fromList.append(tmpList.at(i));
return true;
}
示例2: count
void tst_qdeclarativelistreference::count()
{
TestType *tt = new TestType;
tt->data.append(tt);
tt->data.append(0);
tt->data.append(tt);
{
QDeclarativeListReference ref;
QVERIFY(ref.count() == 0);
}
{
QDeclarativeListReference ref(tt, "blah");
QVERIFY(ref.count() == 0);
}
{
QDeclarativeListReference ref(tt, "data");
QVERIFY(ref.count() == 3);
tt->data.removeAt(1);
QVERIFY(ref.count() == 2);
delete tt;
QVERIFY(ref.count() == 0);
}
{
TestType tt;
tt.data.append(&tt);
tt.property.count = 0;
QDeclarativeListReference ref(&tt, "data");
QVERIFY(ref.count() == 0);
}
}
示例3: serializeProperty
void PQBaseItem::serializeProperty(QTextStream &stream, const QDeclarativeProperty &property, unsigned indentSize) const
{
QString str;
QTextStream outStream(&str);
if (property.propertyTypeCategory() == QDeclarativeProperty::Normal) { // Normal value property
const int propertyType = property.propertyType();
const QString propertyValue = property.read().toString();
if (propertyType >= QVariant::Bool && propertyType <= QVariant::Double) { // Numerical, unquoted values
outStream << propertyValue;
} else {
if (!propertyValue.isEmpty()) {
QString value = propertyValue;
value.replace(QLatin1Char('\\'), QLatin1String("\\\\")) // escape backslashes in rich text
.replace(QLatin1Char('"'), QLatin1String("\\\"")); // escape quotes
value = QLatin1Char('"') % value % QLatin1Char('"');
outStream << value;
}
}
} else if (property.propertyTypeCategory() == QDeclarativeProperty::Object) { // Complex Object type
const QVariant variantValue = property.read();
if (variantValue.isValid() && !variantValue.isNull()) {
serializeObject(outStream, variantValue.value<QObject *>(), indentSize);
}
} else if (property.propertyTypeCategory() == QDeclarativeProperty::List) { // List of objects
const QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(property.read());
outStream << QLatin1Char('[') << endl;
for (int itemIndex = 0, c = list.count(); itemIndex < c; ++itemIndex) {
QObject *item = list.at(itemIndex);
serializeObject(outStream, item, indentSize+1);
if (itemIndex + 1 != list.count()) {
outStream << QLatin1Char(','); // separator
}
outStream << endl;
}
outStream << PQSerializer::indentStep().repeated(indentSize) << QLatin1String("]"); // close list
}
if (!str.isEmpty()) {
stream << PQSerializer::indentStep().repeated(indentSize)
<< property.name() << QLatin1String(": ") << str
<< endl;
}
}
示例4: qmlmetaproperty
void tst_qdeclarativelistreference::qmlmetaproperty()
{
TestType tt;
tt.data.append(&tt);
tt.data.append(0);
tt.data.append(&tt);
QDeclarativeProperty prop(&tt, QLatin1String("data"));
QVariant v = prop.read();
QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
QVERIFY(ref.count() == 3);
QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
}
示例5: qmllistreference_invalid
void tst_qdeclarativelistreference::qmllistreference_invalid()
{
TestType tt;
// Invalid
{
QDeclarativeListReference r;
QVERIFY(r.isValid() == false);
QVERIFY(r.object() == 0);
QVERIFY(r.listElementType() == 0);
QVERIFY(r.canAt() == false);
QVERIFY(r.canClear() == false);
QVERIFY(r.canCount() == false);
QVERIFY(r.append(0) == false);
QVERIFY(r.at(10) == 0);
QVERIFY(r.clear() == false);
QVERIFY(r.count() == 0);
}
// Non-property
{
QDeclarativeListReference r(&tt, "blah");
QVERIFY(r.isValid() == false);
QVERIFY(r.object() == 0);
QVERIFY(r.listElementType() == 0);
QVERIFY(r.canAt() == false);
QVERIFY(r.canClear() == false);
QVERIFY(r.canCount() == false);
QVERIFY(r.append(0) == false);
QVERIFY(r.at(10) == 0);
QVERIFY(r.clear() == false);
QVERIFY(r.count() == 0);
}
// Non-list property
{
QDeclarativeListReference r(&tt, "intProperty");
QVERIFY(r.isValid() == false);
QVERIFY(r.object() == 0);
QVERIFY(r.listElementType() == 0);
QVERIFY(r.canAt() == false);
QVERIFY(r.canClear() == false);
QVERIFY(r.canCount() == false);
QVERIFY(r.append(0) == false);
QVERIFY(r.at(10) == 0);
QVERIFY(r.clear() == false);
QVERIFY(r.count() == 0);
}
}
示例6: deleteObjectsInList
void ObjectNodeInstance::deleteObjectsInList(const QDeclarativeProperty &property)
{
QObjectList objectList;
QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(property.read());
if (!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();
}
示例7: removeObjectFromListProperty
bool removeObjectFromListProperty(QDeclarativeListReference &fromList, QObject *object)
{
QList<QObject *> tmpList;
int i;
if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
return false;
for (i=0; i<fromList.count(); ++i)
if (object != fromList.at(i))
tmpList << fromList.at(i);
fromList.clear();
foreach (QObject *item, tmpList)
fromList.append(item);
return true;
}
示例8: engineTypes
void tst_qdeclarativelistreference::engineTypes()
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine, TEST_FILE("engineTypes.qml"));
QObject *o = component.create();
QVERIFY(o);
QDeclarativeProperty p1(o, QLatin1String("myList"));
QVERIFY(p1.propertyTypeCategory() == QDeclarativeProperty::Normal);
QDeclarativeProperty p2(o, QLatin1String("myList"), engine.rootContext());
QVERIFY(p2.propertyTypeCategory() == QDeclarativeProperty::List);
QVariant v = p2.read();
QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
QVERIFY(ref.count() == 2);
QVERIFY(ref.listElementType());
QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
delete o;
}