示例#1
0
文件: safecode.cpp 项目: vasi/kdelibs
QString SafeCode::propertyGetterDefinition( const Property* property, const ResourceClass* rc ) const
{
    QString s = propertyGetterDeclaration( property, rc, "Nepomuk" ) + '\n';

    if( property->hasSimpleType() ) {
        s += QString( "{\n"
                      "    return ( property( QUrl::fromEncoded(\"%1\") ).%2;\n"
                      "}\n" )
             .arg( property->uri().toString() )
             .arg( property->literalTypeConversionMethod() );
    }
    else if( property->isList() ) {
        s += QString("{\n"
                     "%1"
                     "    return convertResourceList<%3>( property( QUrl::fromEncoded(\"%2\") ).toResourceList() );\n"
                     "}\n" )
             .arg( s_typeComment )
             .arg( property->uri().toString() )
             .arg( property->typeString( true ) );
    }
    else {
        s += QString("{\n"
                     "%1"
                     "    return %2( property( QUrl::fromEncoded(\"%3\") ).toResource().resourceUri() );\n"
                     "}\n" )
             .arg( s_typeComment )
             .arg( property->typeString( true ) )
             .arg( property->uri().toString() );
    }

    return s;
}
示例#2
0
QString SafeCode::propertyGetterDefinition( const Property* property, const ResourceClass* rc ) const
{
    QString s = propertyGetterDeclaration( property, rc, "Nepomuk2" ) + '\n';

    if( property->hasSimpleType() ) {
        s += QString( "{\n"
                      "    return ( property( QUrl::fromEncoded(\"%1\") ).%2;\n"
                      "}\n" )
             .arg( property->uri().toString() )
             .arg( property->literalTypeConversionMethod() );
    }
    else if( property->isList() ) {
        s += QString("{\n"
                     "%1"
                     "    QList<%3> rl;\n"
                     "    QList<Resource> l = property( QUrl::fromEncoded(\"%2\") ).toResourceList() ;\n"
                     "    for( QList<Resource>::const_iterator it = l.constBegin();\n"
                     "        it != l.constEnd(); ++it )\n"
                     "    rl.append( %3( *it ) );\n"
                     "    return rl;\n"
                     "}\n" )
             .arg( s_typeComment )
             .arg( property->uri().toString() )
             .arg( property->typeString( true ) );
    }
    else {
        s += QString("{\n"
                     "%1"
                     "    return %2( property( QUrl::fromEncoded(\"%3\") ).toResource().uri() );\n"
                     "}\n" )
             .arg( s_typeComment )
             .arg( property->typeString( true ) )
             .arg( property->uri().toString() );
    }

    return s;
}