Пример #1
0
void PQBaseItem::serializeObject(QTextStream &stream, const QObject *object, unsigned indentSize) const
{
    QString value;
    const QMetaObject *objectInfo;

    if (object == 0) {
        return; // empty string
    }
    objectInfo = object->metaObject();

    // Handle object name
    QString objectName = QString::fromLatin1(objectInfo->className());
    // Some QML objects instantiates directly C++ classes, the name must be stripedd of Q* prefix
    static QStringList unwantedPrefixes =
        QStringList() << QLatin1String("QGraphics")
                      << QLatin1String("QDeclarative");
    Q_FOREACH (const QString &prefix, unwantedPrefixes) {
        if (objectName.startsWith(prefix)) {
            objectName.remove(0, prefix.length());
        }
    }

    stream << PQSerializer::indentStep().repeated(indentSize) << objectName << QLatin1String(" {") << endl;
    for (int i = objectInfo->propertyOffset(); i < objectInfo->propertyCount(); ++i) {
        serializeProperty(stream,
                          QDeclarativeProperty(const_cast<QObject *>(object),
                                               QString::fromLatin1(objectInfo->property(i).name())),
                          indentSize + 1);
    }
    stream << PQSerializer::indentStep().repeated(indentSize) << QLatin1String("}"); // close object
}
Пример #2
0
int evt_UpdatePropertyValue(char* apikey, char* thngId, char* propertyName, Property* property)
{
	connect();

	char * urlPath = createUpdatePropertyURLPath(thngId, propertyName);
	char * header = createHeader_ContentType(apikey,"application/json");
	char * jsonString = serializeProperty(property);
	
	int responseCode = HTTP_Put(socket, EVRYTHNG_API_HOST, urlPath, header, jsonString, respHeader, ARRAY_SIZE(respHeader), respBody, ARRAY_SIZE(respBody),200);
	
	disconnect();	
	free(jsonString);
	free(urlPath);
	free(header);
	
	return responseCode;	
};
Пример #3
0
void PQBaseItem::serialize(QTextStream &stream, const unsigned &baseIndentSize) const
{
    unsigned indentSize = baseIndentSize;

    QStringList properties(property("_PQProperties").toStringList());

    // Open self declaration
    stream << PQSerializer::indentStep().repeated(indentSize) << qmlName() << QLatin1String(" {") << endl;
    ++indentSize;

    Q_FOREACH(const QString &currentPropertyName, properties+extraProperties) {
        QDeclarativeProperty currentProperty(const_cast<PQBaseItem *>(this), currentPropertyName);
        serializeProperty(stream, currentProperty, indentSize);
    }

    // Close self declaration
    --indentSize;
    stream << PQSerializer::indentStep().repeated(indentSize) << QLatin1Char('}') << endl;
}