Beispiel #1
0
void QtMetaUtilities::setValue(const QMetaObject &metaObject, QObject *object, const QString &propertyName, const QVariant &value)
{
    QString className = QLatin1String(metaObject.className());
    if (className == "QObject")
        return ;
    int idx = metaObject.indexOfProperty(propertyName.toUtf8().data());
    if (idx != -1)
        metaObject.property(idx).write(object, value);
}
void QmlPropertyChangesNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
{
    QMetaObject metaObject = QQuickPropertyChanges::staticMetaObject;

    if (metaObject.indexOfProperty(name.toLatin1()) > 0) { // 'restoreEntryValues', 'explicit'
        ObjectNodeInstance::setPropertyBinding(name, expression);
    } else {
        changesObject()->changeExpression(name.toLatin1(), expression);
    }
}
Beispiel #3
0
void CDiagramItem::fromXml(const QDomElement &n)
{
	QDomElement				e;
	QString					type, name, prop;
	QObject					*obj = NULL;
	QMetaProperty			pro;
	QMetaObject				*meta = NULL;
	CDiagramSerializable	*serialItem = NULL;

	setLibraryCategory(n.attribute( QString("libCategory") ) );
	setLibraryName(n.attribute( QString("libName") ) );
	setCategory(n.attribute( QString("category") ) );
	setName(n.attribute( QString("name") ) );
	setId(n.attribute( QString("id") ).toInt() );

	obj = dynamic_cast<QObject*>(this);
	e = n.firstChildElement( QString("property") );
	while (!e.isNull())
	{
		QByteArray	b;

		name = e.attribute( QString("name") );
		type = e.attribute( QString("type") );

		b = QByteArray::fromBase64( e.text().toAscii() );
		QDataStream s(&b, QIODevice::ReadOnly);
		QVariant	value(s);
		if (value.convert( QVariant::nameToType( qPrintable(type) ) ) )
		{
			meta = const_cast<QMetaObject*>( obj->metaObject() );
			pro = meta->property( meta->indexOfProperty(qPrintable(name)) );
			if (pro.isWritable())
				obj->setProperty(qPrintable(name), value);
		}
		e = e.nextSiblingElement( QString("property") );
	}
	
	e = n.firstChildElement( QString("children") );
	if (!e.isNull())
	{
		e = e.firstChildElement( QString("child") );
		while (!e.isNull())
		{
			prop = e.attribute( QString("dynamicProperty") );
			serialItem = RS_PROPERTY(prop.toAscii().constData());
			if (serialItem)
				serialItem->fromXml(e);
			e = e.nextSiblingElement(QString("child"));
		}
	}
	
	e = n.firstChildElement( QString("ext" ) );
	extFromXml(e);
}
Beispiel #4
0
QVariant QtMetaUtilities::getValue(const QMetaObject &metaObject, const QObject *object, const QString &propertyName)
{
    QVariant retour;
    QString className = QLatin1String(metaObject.className());
    if (className == "QObject")
        return retour;
    int idx = metaObject.indexOfProperty(propertyName.toUtf8().data());
    if (idx != -1)
        return metaObject.property(idx).read(object);

    return retour;
}
void QmlPropertyChangesNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{
    QMetaObject metaObject = QQuickPropertyChanges::staticMetaObject;

    if (metaObject.indexOfProperty(name.toLatin1()) > 0) { // 'restoreEntryValues', 'explicit'
        ObjectNodeInstance::setPropertyVariant(name, value);
    } else {
        changesObject()->changeValue(name.toLatin1(), value);
        QObject *targetObject = changesObject()->object();
        if (targetObject && nodeInstanceServer()->activeStateInstance().isWrappingThisObject(changesObject()->state())) {
            ServerNodeInstance targetInstance = nodeInstanceServer()->instanceForObject(targetObject);
            targetInstance.setPropertyVariant(name, value);
        }
    }
}
Beispiel #6
0
void CDiagramItem::updateChildrenProperty(const QString &name, const QVariant &value)
{
	QObject					*obj = NULL;
	QMetaObject				*meta = NULL;
	QList<QGraphicsItem*>	items;

	items = childItems();
	for (int i = 0; i < items.length(); ++i)
	{
		obj = dynamic_cast<QObject*>(items.at(i));
		if (obj)
		{
			meta = const_cast<QMetaObject*>( obj->metaObject() );
			if (meta && meta->indexOfProperty(name.toAscii().constData()) != -1 )
			{
				obj->setProperty(name.toAscii().constData(), value);
			}
		}
	}
}