Commit 15b0a4b6 authored by Tobias Koenig's avatar Tobias Koenig
Browse files

Pass the parent collection to strigi

svn path=/trunk/KDE/kdepim/runtime/; revision=1192142
parent fdacbed2
...@@ -103,14 +103,27 @@ void StrigiFeeder::updateAll() ...@@ -103,14 +103,27 @@ void StrigiFeeder::updateAll()
connect( collectionFetch, SIGNAL( collectionsReceived( Akonadi::Collection::List ) ), SLOT( collectionsReceived( Akonadi::Collection::List ) ) ); connect( collectionFetch, SIGNAL( collectionsReceived( Akonadi::Collection::List ) ), SLOT( collectionsReceived( Akonadi::Collection::List ) ) );
} }
static KUrl extendedItemUrl( const Item &item )
{
KUrl url = item.url();
url.addQueryItem( "collection", QString::number( item.parentCollection().id() ) );
return url;
}
void StrigiFeeder::indexItem( const Item &item )
{
const QByteArray data = item.payloadData();
mStrigi.indexFile( extendedItemUrl( item ).url(), QDateTime::currentDateTime().toTime_t(), data );
}
void StrigiFeeder::itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection ) void StrigiFeeder::itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection )
{ {
if ( entityIsHidden( collection ) ) if ( entityIsHidden( collection ) )
return; return;
if ( item.hasPayload() ) { if ( item.hasPayload() ) {
const QByteArray data = item.payloadData(); indexItem( item );
mStrigi.indexFile( item.url().url(), QDateTime::currentDateTime().toTime_t(), data );
} else { } else {
const ItemFetchScope scope = fetchScopeForCollection( collection ); const ItemFetchScope scope = fetchScopeForCollection( collection );
if ( scope.fullPayload() || !scope.payloadParts().isEmpty() ) { if ( scope.fullPayload() || !scope.payloadParts().isEmpty() ) {
...@@ -128,8 +141,7 @@ void StrigiFeeder::itemChanged( const Akonadi::Item &item, const QSet<QByteArray ...@@ -128,8 +141,7 @@ void StrigiFeeder::itemChanged( const Akonadi::Item &item, const QSet<QByteArray
return; return;
if ( item.hasPayload() ) { if ( item.hasPayload() ) {
const QByteArray data = item.payloadData(); indexItem( item );
mStrigi.indexFile( item.url().url(), QDateTime::currentDateTime().toTime_t(), data );
} else { } else {
const Collection collection = item.parentCollection(); const Collection collection = item.parentCollection();
const ItemFetchScope scope = fetchScopeForCollection( collection ); const ItemFetchScope scope = fetchScopeForCollection( collection );
...@@ -234,8 +246,7 @@ void StrigiFeeder::itemsReceived( const Akonadi::Item::List &items ) ...@@ -234,8 +246,7 @@ void StrigiFeeder::itemsReceived( const Akonadi::Item::List &items )
{ {
foreach ( const Item &item, items ) { foreach ( const Item &item, items ) {
// we only get here if the item is not anywhere in strigi yet, so no need to delete it // we only get here if the item is not anywhere in strigi yet, so no need to delete it
const QByteArray data = item.payloadData(); indexItem( item );
mStrigi.indexFile( item.url().url(), QDateTime::currentDateTime().toTime_t(), data );
} }
mProcessedAmount += items.count(); mProcessedAmount += items.count();
emit percent( (mProcessedAmount * 100) / (mTotalAmount * 100) ); emit percent( (mProcessedAmount * 100) / (mTotalAmount * 100) );
...@@ -247,8 +258,7 @@ void StrigiFeeder::notificationItemsReceived( const Akonadi::Item::List &items ) ...@@ -247,8 +258,7 @@ void StrigiFeeder::notificationItemsReceived( const Akonadi::Item::List &items )
if ( !item.hasPayload() ) if ( !item.hasPayload() )
continue; continue;
const QByteArray data = item.payloadData(); indexItem( item );
mStrigi.indexFile( item.url().url(), QDateTime::currentDateTime().toTime_t(), data );
} }
} }
......
...@@ -80,6 +80,8 @@ class StrigiFeeder : public AgentBase, public AgentBase::Observer ...@@ -80,6 +80,8 @@ class StrigiFeeder : public AgentBase, public AgentBase::Observer
bool needsReIndexing() const; bool needsReIndexing() const;
Akonadi::ItemFetchScope fetchScopeForCollection( const Akonadi::Collection &collection ); Akonadi::ItemFetchScope fetchScopeForCollection( const Akonadi::Collection &collection );
void indexItem( const Item &item );
StrigiClient mStrigi; StrigiClient mStrigi;
Akonadi::Collection::List mCollectionQueue; Akonadi::Collection::List mCollectionQueue;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment