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;
}
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;
}
Exemple #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();
}
Exemple #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;
}
Exemple #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);
}
Exemple #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;
}
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;
}
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;
}