Changeset View
Changeset View
Standalone View
Standalone View
src/core/engine.cpp
Show First 20 Lines • Show All 299 Lines • ▼ Show 20 Line(s) | 297 | foreach (const QSharedPointer<KNSCore::Provider> &p, m_providers) { | |||
---|---|---|---|---|---|
300 | } | 300 | } | ||
301 | } | 301 | } | ||
302 | emit signalProvidersLoaded(); | 302 | emit signalProvidersLoaded(); | ||
303 | } | 303 | } | ||
304 | 304 | | |||
305 | void Engine::slotEntriesLoaded(const KNSCore::Provider::SearchRequest &request, KNSCore::EntryInternal::List entries) | 305 | void Engine::slotEntriesLoaded(const KNSCore::Provider::SearchRequest &request, KNSCore::EntryInternal::List entries) | ||
306 | { | 306 | { | ||
307 | m_currentPage = qMax<int>(request.page, m_currentPage); | 307 | m_currentPage = qMax<int>(request.page, m_currentPage); | ||
308 | qCDebug(KNEWSTUFFCORE) << "loaded page " << request.page << "current page" << m_currentPage; | 308 | qCDebug(KNEWSTUFFCORE) << "loaded page " << request.page << "current page" << m_currentPage << "count:" << entries.count(); | ||
309 | 309 | | |||
310 | if (request.filter == Provider::Updates) { | 310 | if (request.filter == Provider::Updates) { | ||
311 | emit signalUpdateableEntriesLoaded(entries); | 311 | emit signalUpdateableEntriesLoaded(entries); | ||
312 | } else { | 312 | } else { | ||
313 | m_cache->insertRequest(request, entries); | 313 | m_cache->insertRequest(request, entries); | ||
314 | emit signalEntriesLoaded(entries); | 314 | emit signalEntriesLoaded(entries); | ||
315 | } | 315 | } | ||
316 | 316 | | |||
Show All 11 Lines | 322 | { | |||
328 | 328 | | |||
329 | foreach (const QSharedPointer<KNSCore::Provider> &p, m_providers) { | 329 | foreach (const QSharedPointer<KNSCore::Provider> &p, m_providers) { | ||
330 | if (p->isInitialized()) { | 330 | if (p->isInitialized()) { | ||
331 | if (m_currentRequest.filter == Provider::Installed) { | 331 | if (m_currentRequest.filter == Provider::Installed) { | ||
332 | // when asking for installed entries, never use the cache | 332 | // when asking for installed entries, never use the cache | ||
333 | p->loadEntries(m_currentRequest); | 333 | p->loadEntries(m_currentRequest); | ||
334 | } else { | 334 | } else { | ||
335 | // take entries from cache until there are no more | 335 | // take entries from cache until there are no more | ||
336 | EntryInternal::List cache = m_cache->requestFromCache(m_currentRequest); | 336 | EntryInternal::List cache; | ||
337 | while (!cache.isEmpty()) { | 337 | EntryInternal::List lastCache = m_cache->requestFromCache(m_currentRequest); | ||
338 | while (!lastCache.isEmpty()) { | ||||
338 | qCDebug(KNEWSTUFFCORE) << "From cache"; | 339 | qCDebug(KNEWSTUFFCORE) << "From cache"; | ||
339 | emit signalEntriesLoaded(cache); | 340 | cache << lastCache; | ||
340 | 341 | | |||
341 | m_currentPage = m_currentRequest.page; | 342 | m_currentPage = m_currentRequest.page; | ||
342 | ++m_currentRequest.page; | 343 | ++m_currentRequest.page; | ||
343 | cache = m_cache->requestFromCache(m_currentRequest); | 344 | lastCache = m_cache->requestFromCache(m_currentRequest); | ||
344 | } | 345 | } | ||
345 | 346 | | |||
346 | // Since the cache has no more pages, reset the request's page | 347 | // Since the cache has no more pages, reset the request's page | ||
347 | if (m_currentPage >= 0) { | 348 | if (m_currentPage >= 0) { | ||
348 | m_currentRequest.page = m_currentPage; | 349 | m_currentRequest.page = m_currentPage; | ||
349 | } | 350 | } | ||
350 | 351 | | |||
351 | // if the cache was empty, request data from provider | 352 | if (!cache.isEmpty()) { | ||
352 | if (m_currentPage == -1) { | 353 | emit signalEntriesLoaded(cache); | ||
354 | } else { | ||||
353 | qCDebug(KNEWSTUFFCORE) << "From provider"; | 355 | qCDebug(KNEWSTUFFCORE) << "From provider"; | ||
354 | p->loadEntries(m_currentRequest); | 356 | p->loadEntries(m_currentRequest); | ||
355 | 357 | | |||
356 | ++m_numDataJobs; | 358 | ++m_numDataJobs; | ||
357 | updateStatus(); | 359 | updateStatus(); | ||
358 | } | 360 | } | ||
359 | } | 361 | } | ||
360 | } | 362 | } | ||
▲ Show 20 Lines • Show All 319 Lines • Show Last 20 Lines |