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

List:       kde-commits
Subject:    KDE/kdelibs/nepomuk/query
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-08-25 17:34:07
Message-ID: 20100825173407.66500AC857 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1167922 by trueg:

Converted the new comparison operator for ComparisonTerm creation into
a static Term method. This is sadly necessary since the new operator
clashes with the Entity::operator==() which makes the new operator
source incompatible.

 M  +16 -15    term.cpp  
 M  +14 -13    term.h  


--- trunk/KDE/kdelibs/nepomuk/query/term.cpp #1167921:1167922
@@ -292,6 +292,22 @@
 }
 
 
+// static
+Nepomuk::Query::Term Nepomuk::Query::Term::fromProperty( const \
Nepomuk::Types::Property& property, const Nepomuk::Variant& variant ) +{
+    if( variant.isList() ) {
+        AndTerm andTerm;
+        Q_FOREACH( const Variant& v, variant.toVariantList() ) {
+            andTerm.addSubTerm( fromProperty(property, v) );
+        }
+        return andTerm;
+    }
+    else {
+        return ComparisonTerm( property, Term::fromVariant(variant), \
ComparisonTerm::Equal ); +    }
+}
+
+
 bool Nepomuk::Query::Term::operator==( const Term& other ) const
 {
     return d_ptr->equals( other.d_ptr );
@@ -388,21 +404,6 @@
 }
 
 
-Nepomuk::Query::Term Nepomuk::operator==( const Nepomuk::Types::Property& property, \
                const Nepomuk::Variant& variant )
-{
-    if( variant.isList() ) {
-        Query::AndTerm andTerm;
-        Q_FOREACH( const Variant& v, variant.toVariantList() ) {
-            andTerm.addSubTerm( property == v );
-        }
-        return andTerm;
-    }
-    else {
-        return Query::ComparisonTerm( property, Query::Term::fromVariant(variant), \
                Query::ComparisonTerm::Equal );
-    }
-}
-
-
 Nepomuk::Query::Term Nepomuk::Query::operator!=( const Nepomuk::Types::Property& \
property, const Nepomuk::Query::Term& term )  {
     return !( property == term );
--- trunk/KDE/kdelibs/nepomuk/query/term.h #1167921:1167922
@@ -385,6 +385,20 @@
             static Term fromVariant( const Variant& variant );
 
             /**
+             * Create a term using a Types::Property and a Variant. Sadly this \
cannot be modelled +             * as an operator since it would clash with \
Entity::operator==(). +             *
+             * \param property The property to be used in the ComparisonTerm.
+             * \param variant The value to be compared to. Either ResourceTerm or \
LiteralTerm is used. List +             * variants (Variant::isList()) are handled \
via an AndTerm meaning all values need to match. +             *
+             * \since 4.6
+             *
+             * \relates ComparisonTerm
+             */
+            static Term fromProperty( const Types::Property& property, const \
Variant& variant ); +
+            /**
              * Comparison operator.
              *
              * \return \p true if this term is equal to \p term.
@@ -552,19 +566,6 @@
         NEPOMUKQUERY_EXPORT uint qHash( const Nepomuk::Query::Term& );
     }
 
-    /**
-     * Comparision operator for simple creation of ComparisonTerm objects using the
-     * ComparisonTerm::Equal comparator.
-     *
-     * \param property The property to be used in the ComparisonTerm.
-     * \param variant The value to be compared to. Either ResourceTerm or \
                LiteralTerm is used. List
-     * variants (Variant::isList()) are handled via an AndTerm meaning all values \
                need to match.
-     *
-     * \since 4.6
-     *
-     * \relates ComparisonTerm
-     */
-    NEPOMUKQUERY_EXPORT Query::Term operator==( const Types::Property& property, \
const Variant& variant );  }
 
 /** \cond hide_nepomuk_term_clone_from_doxygen */


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

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