Hi.
I was going through the Nepomuk framework in my normal fashion, and I
happened to notice a couple of things.
1. The *Nepomuk::ResourceData::hasProperty( const QUrl& uri )* function
currently uses the MAINMODEL to answer. It think it should use the cache, as
it would be faster. The function *hasProperty( const QUrl& p, const Variant&
v ) *also uses the cache. A patch has been provided.
2. The *Nepomuk::ResourceData::removeProperty( const QUrl& uri )* function
doesn't update the cache. The setProperty function does. It should be
symmetrical. I think.
3. In *Nepomuk::ResourceFilterModel::updateProperty( const QUrl& resource,
const QUrl& property, const Node& value )* shouldn't the line if(
it.hasNext() ) be a while( it.hasNext() ) ? I haven't tested it out, but I
think this is what should happen -
Let's say I have a resource with a uri and certain properties.
uri a rdf:Resource .
uri a rxx:A .
uri a rxx:B .
and I call the function *updateProperty*( uri, rdf:type, rxx:C ). The
current implementation would get all the above 3 statements (I'm not sure in
what order) . Suppose it got *"uri a rdf:Resource*" first. It would then
proceed to remove the statement and add the *"uri a rxx:C" *statement. This
doesn't seem right.
IMO, it should either delete all matching statements and add the one
specified in the arguments or it should take an oldValue and newValue and
accordingly change. KDevelop says it isn't used anywhere, so this isn't
really that important. :-/
Thanks
- Vishesh Handa
Index: resourcedata.cpp
===================================================================
--- resourcedata.cpp (revision 1123594)
+++ resourcedata.cpp (working copy)
@@ -226,12 +226,14 @@ bool Nepomuk::ResourceData::hasProperty(
if( m_proxyData )
return m_proxyData->hasProperty( uri );
- if ( determineUri() ) {
- return MAINMODEL->containsAnyStatement( Soprano::Statement( m_uri, uri, Soprano::Node() ) );
- }
- else {
+ if( !load() )
return false;
- }
+
+ QHash<QUrl, Variant>::const_iterator it = m_cache.constFind( uri );
+ if( it == m_cache.constEnd() )
+ return false;
+
+ return true;
}
Index: resourcedata.cpp
===================================================================
--- resourcedata.cpp (revision 1123594)
+++ resourcedata.cpp (working copy)
@@ -549,6 +549,7 @@ void Nepomuk::ResourceData::removeProper
QMutexLocker lock(&m_modificationMutex);
if ( determineUri() ) {
+ m_cache.remove( uri );
MAINMODEL->removeProperty( m_uri, uri );
}
}
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk