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

List:       kde-commits
Subject:    KDE/kdelibs/nepomuk/core
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2008-05-06 8:52:23
Message-ID: 1210063943.561445.29143.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 804499 by trueg:

Only connect to the main model when necessary. Before that we do not have any data to \
invalidate anyway.

 M  +30 -17    resourcemanager.cpp  


--- trunk/KDE/kdelibs/nepomuk/core/resourcemanager.cpp #804498:804499
@@ -59,10 +59,6 @@
     : QObject(),
       d( new Private( this ) )
 {
-    connect( mainModel(), SIGNAL(statementsAdded()),
-             this, SLOT(slotStoreChanged()) );
-    connect( mainModel(), SIGNAL(statementsRemoved()),
-             this, SLOT(slotStoreChanged()) );
 }
 
 
@@ -91,6 +87,10 @@
 {
     delete d->mainModel;
     d->mainModel = new MainModel( this );
+    connect( d->mainModel, SIGNAL(statementsAdded()),
+             this, SLOT(slotStoreChanged()) );
+    connect( d->mainModel, SIGNAL(statementsRemoved()),
+             this, SLOT(slotStoreChanged()) );
     return d->mainModel->isValid() ? 0 : -1;
 }
 
@@ -125,14 +125,13 @@
 
     if( !type.isEmpty() ) {
         // check local data
-        // no need ATM since we do not cache changes
-//         QList<ResourceData*> localData = ResourceData::allResourceDataOfType( \
                type );
-//         for( QList<ResourceData*>::iterator rdIt = localData.begin();
-//              rdIt != localData.end(); ++rdIt ) {
-//             l.append( Resource( *rdIt ) );
-//         }
+        QList<ResourceData*> localData = ResourceData::allResourceDataOfType( type \
); +        for( QList<ResourceData*>::iterator rdIt = localData.begin();
+             rdIt != localData.end(); ++rdIt ) {
+            l.append( Resource( *rdIt ) );
+        }
 
-//         kDebug(300004) << " added local resources: " << l.count();
+        kDebug(300004) << " added local resources: " << l.count();
 
         Soprano::Model* model = mainModel();
         Soprano::StatementIterator it = model->listStatements( Soprano::Statement( \
Soprano::Node(), Soprano::Vocabulary::RDF::type(), type ) ); @@ -166,12 +165,11 @@
     }
     else {
         // check local data
-        // no need ATM since we do not cache changes
-//         QList<ResourceData*> localData = \
                ResourceData::allResourceDataWithProperty( uri, v );
-//         for( QList<ResourceData*>::iterator rdIt = localData.begin();
-//              rdIt != localData.end(); ++rdIt ) {
-//             l.append( Resource( *rdIt ) );
-//         }
+        QList<ResourceData*> localData = ResourceData::allResourceDataWithProperty( \
uri, v ); +        for( QList<ResourceData*>::iterator rdIt = localData.begin();
+             rdIt != localData.end(); ++rdIt ) {
+            l.append( Resource( *rdIt ) );
+        }
 
         // check remote data
         Soprano::Node n;
@@ -238,8 +236,23 @@
 
 void Nepomuk::ResourceManager::setOverrideMainModel( Soprano::Model* model )
 {
+    if ( d->overrideModel ) {
+        d->overrideModel->disconnect( this );
+    }
+
     d->overrideModel = model;
 
+    if ( model ) {
+        connect( model, SIGNAL(statementsAdded()),
+                 this, SLOT(slotStoreChanged()) );
+        connect( model, SIGNAL(statementsRemoved()),
+                 this, SLOT(slotStoreChanged()) );
+    }
+
+    if ( d->mainModel ) {
+        d->mainModel->blockSignals( model != 0 );
+    }
+
     // clear cache to make sure we do not mix data
     Q_FOREACH( ResourceData* data, ResourceData::allResourceData()) {
         data->invalidateCache();


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

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