Changeset View
Changeset View
Standalone View
Standalone View
server/src/search/searchmanager.cpp
Show First 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | void SearchManager::searchUpdateResultsAvailable( const QSet<qint64> &results ) | ||||
newMatches = newMatches - existingMatches; | newMatches = newMatches - existingMatches; | ||||
const bool existingTransaction = DataStore::self()->inTransaction(); | const bool existingTransaction = DataStore::self()->inTransaction(); | ||||
if ( !existingTransaction ) { | if ( !existingTransaction ) { | ||||
DataStore::self()->beginTransaction(); | DataStore::self()->beginTransaction(); | ||||
} | } | ||||
QVariantList newMatchesVariant; | QVariantList newMatchesVariant; | ||||
{ | |||||
QVariantList _nm; | |||||
Q_FOREACH ( qint64 id, newMatches ) { | Q_FOREACH( qint64 id, newMatches ) { | ||||
newMatchesVariant << id; | _nm << id; | ||||
Collection::addPimItem( collection.id(), id ); | |||||
} | } | ||||
qDebug() << "Added" << newMatches.count(); | if ( _nm.size() > 0 ) { | ||||
SelectQueryBuilder<PimItem> qb; | |||||
qb.addValueCondition( PimItem::idFullColumnName(), Query::In, _nm ); | |||||
if ( !qb.exec() ) { | |||||
return; | |||||
} | |||||
const QVector<PimItem> newItems = qb.result(); | |||||
QSet<qint64> newIDs; | |||||
Q_FOREACH ( const PimItem &item, newItems ) { | |||||
newMatchesVariant << item.id(); | |||||
newIDs << item.id(); | |||||
Collection::addPimItem( collection.id(), item.id() ); | |||||
} | |||||
qDebug() << "Added" << newItems.count(); | |||||
newMatches = newMatches - newIDs; | |||||
} | |||||
if (!newMatches.isEmpty()) { | |||||
akDebug() << "Could not add items to search collection, because their item do not exist anymore in PimItem table:" << newMatches; | |||||
} | |||||
} | |||||
if ( !existingTransaction && !DataStore::self()->commitTransaction() ) { | if ( !existingTransaction && !DataStore::self()->commitTransaction() ) { | ||||
akDebug() << "Failed to commit transaction"; | akDebug() << "Failed to commit transaction"; | ||||
return; | return; | ||||
} | } | ||||
if ( !newMatchesVariant.isEmpty() ) { | if ( !newMatchesVariant.isEmpty() ) { | ||||
SelectQueryBuilder<PimItem> qb; | SelectQueryBuilder<PimItem> qb; | ||||
Show All 10 Lines |