本文整理汇总了C++中QDeclarativeListReference类的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeListReference类的具体用法?C++ QDeclarativeListReference怎么用?C++ QDeclarativeListReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDeclarativeListReference类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QVERIFY
void tst_qdeclarativelistreference::canCount()
{
TestType *tt = new TestType;
{
QDeclarativeListReference ref;
QVERIFY(ref.canCount() == false);
}
{
QDeclarativeListReference ref(tt, "blah");
QVERIFY(ref.canCount() == false);
}
{
QDeclarativeListReference ref(tt, "data");
QVERIFY(ref.canCount() == true);
delete tt;
QVERIFY(ref.canCount() == false);
}
{
TestType tt;
tt.property.count = 0;
QDeclarativeListReference ref(&tt, "data");
QVERIFY(ref.canCount() == false);
}
}
示例2: prop
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);
}
示例3: 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();
}
示例4: outStream
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;
}
}
示例5: property
void ObjectNodeInstance::doResetProperty(const QString &propertyName)
{
m_modelAbstractPropertyHash.remove(propertyName);
QDeclarativeProperty property(object(), propertyName, context());
if (!property.isValid())
return;
QVariant oldValue = property.read();
if (oldValue.type() == QVariant::Url) {
QUrl url = oldValue.toUrl();
QString path = url.toLocalFile();
if (QFileInfo(path).exists() && nodeInstanceView())
nodeInstanceView()->removeFilePropertyFromFileSystemWatcher(object(), propertyName, path);
}
QDeclarativeAbstractBinding *binding = QDeclarativePropertyPrivate::binding(property);
if (binding) {
binding->setEnabled(false, 0);
binding->destroy();
}
if (property.isResettable()) {
property.reset();
} else if (property.propertyTypeCategory() == QDeclarativeProperty::List) {
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;
}
list.clear();
} else if (property.isWritable()) {
if (property.read() == resetValue(propertyName))
return;
property.write(resetValue(propertyName));
}
}
示例6: component
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;
}
示例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: hasFullImplementedListInterface
static bool hasFullImplementedListInterface(const QDeclarativeListReference &list)
{
#if QT_VERSION<0x050000
return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear();
#else
return list.isChangeable();
#endif
}
示例9: 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;
}
示例10: hasFullImplementedListInterface
static bool hasFullImplementedListInterface(const QDeclarativeListReference &list)
{
return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear();
}