[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/nepomuk/core
From:       Vishesh Handa <handa.vish () gmail ! com>
Date:       2010-08-25 17:39:10
Message-ID: 20100825173910.ECB35AC857 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1167926 by vhanda:

Deprecate valuesToRDFNodes and valueToRDFNode in favor of Variant::toNodeList and 
Variant::toNode.


 M  +2 -23     tools.cpp  
 M  +6 -2      tools.h  
 M  +12 -18    variant.cpp  


--- trunk/KDE/kdelibs/nepomuk/core/tools.cpp #1167925:1167926
@@ -54,37 +54,16 @@
 
 Soprano::Node Nepomuk::valueToRDFNode( const Nepomuk::Variant& v )
 {
-    if ( v.isUrl() )
-        return Soprano::Node( v.toUrl() );
-    else
-        return Soprano::Node( Soprano::LiteralValue( v.variant() ) );
+    return v.toNode();
 }
 
 
 QList<Soprano::Node> Nepomuk::valuesToRDFNodes( const Nepomuk::Variant& v )
 {
-    QList<Soprano::Node> nl;
-
-    if ( v.isUrlList() ) {
-        QList<QUrl> urls = v.toUrlList();
-        for ( QList<QUrl>::const_iterator it = urls.constBegin(); it != \
                urls.constEnd(); ++it ) {
-            nl.append( Soprano::Node( *it ) );
+    return v.toNodeList();
         }
-    }
-    if( v.isList() ) {
-        QStringList vl = v.toStringList();
-        for( QStringList::const_iterator it = vl.constBegin(); it != vl.constEnd(); \
                ++it ) {
-            nl.append( Soprano::Node( Soprano::LiteralValue::fromString( *it, ( \
                QVariant::Type )v.simpleType() ) ) );
-        }
-    }
-    else {
-        nl.append( valueToRDFNode( v ) );
-    }
 
-    return nl;
-}
 
-
 Nepomuk::Variant Nepomuk::RDFLiteralToValue( const Soprano::Node& node )
 {
     return Variant::fromNode( node );
--- trunk/KDE/kdelibs/nepomuk/core/tools.h #1167925:1167926
@@ -35,14 +35,18 @@
     /**
      * Used internally by Resource.
      * Converts a Variant into a literal value to be used in the RDF store.
+     *
+     * \deprecated Use Nepomuk::Varaint::toNodeList()
      */
-    NEPOMUK_EXPORT QList<Soprano::Node> valuesToRDFNodes( const Variant& );
+    KDE_DEPRECATED NEPOMUK_EXPORT QList<Soprano::Node> valuesToRDFNodes( const \
Variant& );  
     /**
      * Used internally by Resource.
      * Converts a non-list Variant into a Soprano::Node.
+     *
+     * \deprecated Use Nepomuk::Varaint::toNode()
      */
-    NEPOMUK_EXPORT Soprano::Node valueToRDFNode( const Variant& );
+    KDE_DEPRECATED NEPOMUK_EXPORT Soprano::Node valueToRDFNode( const Variant& );
 
     /**
      * Used internally by Resource.
--- trunk/KDE/kdelibs/nepomuk/core/variant.cpp #1167925:1167926
@@ -1271,34 +1271,28 @@
         return Soprano::Node( Soprano::LiteralValue( variant() ) );
 }
 
+
 QList<Soprano::Node> Nepomuk::Variant::toNodeList() const
 {
-    QList<Soprano::Node> valueNodes;
+    QList<Soprano::Node> nl;
     
-    // one Resource
-    if( isResource() ) {
-        valueNodes.append( toUrl() );
+    if ( isResourceList() ) {
+        QList<QUrl> urls = toUrlList();
+        for ( QList<QUrl>::const_iterator it = urls.constBegin(); it != \
urls.constEnd(); ++it ) { +            nl.append( Soprano::Node( *it ) );
     }
-    
-    // many Resources
-    else if( isResourceList() ) {
-        const QList<QUrl>& l = toUrlList();
-        for( QList<QUrl>::const_iterator resIt = l.constBegin(); resIt != \
                l.constEnd(); ++resIt ) {
-            valueNodes.append( *resIt );
         }
-    }
-    
-    // many literals
     else if( isList() ) {
-        valueNodes = Nepomuk::valuesToRDFNodes( *this );
+        QStringList vl = toStringList();
+        for( QStringList::const_iterator it = vl.constBegin(); it != vl.constEnd(); \
++it ) { +            nl.append( Soprano::Node( Soprano::LiteralValue::fromString( \
*it, ( QVariant::Type )simpleType() ) ) );  }
-    
-    // one literal
+    }
     else {
-        valueNodes.append( Nepomuk::valueToRDFNode( *this ) );
+        nl.append( toNode() );
     }
 
-    return valueNodes;
+    return nl;
 }
 
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic