Ejemplo n.º 1
0
void MapToVariantConverter::addProperties(QVariantMap &variantMap,
                                          const Properties &properties) const
{
    if (properties.isEmpty())
        return;

    QVariantMap propertiesMap;
    QVariantMap propertyTypesMap;

    Properties::const_iterator it = properties.constBegin();
    Properties::const_iterator it_end = properties.constEnd();
    for (; it != it_end; ++it) {
        int type = it.value().userType();
        QVariant value = toExportValue(it.value());

        if (type == filePathTypeId())
            value = mMapDir.relativeFilePath(value.toString());

        propertiesMap[it.key()] = value;
        propertyTypesMap[it.key()] = typeToName(type);
    }

    variantMap[QLatin1String("properties")] = propertiesMap;
    variantMap[QLatin1String("propertytypes")] = propertyTypesMap;
}
Ejemplo n.º 2
0
QVariant MapToVariantConverter::propertyTypesToVariant(const Properties &properties) const
{
    QVariantMap variantMap;

    Properties::const_iterator it = properties.constBegin();
    Properties::const_iterator it_end = properties.constEnd();
    for (; it != it_end; ++it)
        variantMap[it.key()] = typeToName(it.value().userType());

    return variantMap;
}
Ejemplo n.º 3
0
Property
Properties::get( const std::string& key ) const
{
    std::string nkey = normalize( key );
    for( Properties::const_iterator i = begin(); i != end(); i++ )
    {
        if ( i->getName() == nkey )
        {
            return *i;
        }
    }
    return Property::invalid();
}
Ejemplo n.º 4
0
std::string
Properties::getValue( const std::string& key, std::string def ) const
{
    std::string nkey = normalize( key );
    for( Properties::const_iterator i = begin(); i != end(); i++ )
    {
        if ( i->getName() == nkey )
        {
            return i->getValue();
        }
    }
    return def;
}
Ejemplo n.º 5
0
osg::Vec4
Properties::getVec4Value( const std::string& key ) const
{
    std::string nkey = normalize( key );
    for( Properties::const_iterator i = begin(); i != end(); i++ )
    {
        if ( i->getName() == nkey )
        {
            return i->getVec4Value();
        }
    }
    return osg::Vec4(0,0,0,1);
}
Ejemplo n.º 6
0
bool
Properties::exists( const std::string& key ) const
{
    std::string nkey = normalize( key );
    for( Properties::const_iterator i = begin(); i != end(); i++ )
    {
        if ( i->getName() == nkey )
        {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 7
0
QVariant MapToVariantConverter::toVariant(const Properties &properties) const
{
    QVariantMap variantMap;

    Properties::const_iterator it = properties.constBegin();
    Properties::const_iterator it_end = properties.constEnd();
    for (; it != it_end; ++it) {
        QVariant value = toExportValue(it.value());

        if (it.value().userType() == filePathTypeId())
            value = mMapDir.relativeFilePath(value.toString());

        variantMap[it.key()] = value;
    }

    return variantMap;
}
Ejemplo n.º 8
0
void MapToVariantConverter::addProperties(QVariantMap &variantMap,
                                          const Properties &properties) const
{
    if (properties.isEmpty())
        return;

    QVariantList propertiesVariantList;

    Properties::const_iterator it = properties.constBegin();
    Properties::const_iterator it_end = properties.constEnd();
    for (; it != it_end; ++it) {
        int type = it.value().userType();
        const QVariant value = toExportValue(it.value(), mMapDir);

        QVariantMap propertyVariantMap;
        propertyVariantMap[QLatin1String("name")] = it.key();
        propertyVariantMap[QLatin1String("value")] = value;
        propertyVariantMap[QLatin1String("type")] = typeToName(type);
        propertiesVariantList << propertyVariantMap;
    }

    variantMap[QLatin1String("properties")] = propertiesVariantList;
}