Skip to content
Snippets Groups Projects
Commit d3108983 authored by Pierre Lamot's avatar Pierre Lamot Committed by François Cartegnie
Browse files

qt: add fetchMore ListCache

this allows to request more data from the cache using the standart growth policy
rather than requiring the caller to `refer` and item after what is currently
loaded. This function ensure that the cache tries to load at least the current
count + chunk size
parent 07f410b5
No related branches found
No related tags found
No related merge requests found
......@@ -235,6 +235,11 @@ public:
*/
void refer(size_t index);
/**
* Request to fetch more data
*/
void fetchMore();
/*
* reload
*/
......
......@@ -374,6 +374,26 @@ void ListCache<T>::refer(size_t index)
}
}
template<typename T>
void ListCache<T>::fetchMore()
{
const CacheData* cache = m_cachedData.get();
if (!cache)
cache = m_oldData.get();
if (!cache)
return; //nothing loaded yet
if (cache->loadedCount >= cache->queryCount)
return;
if (m_maxReferedIndex >= cache->loadedCount + m_chunkSize)
return;
m_maxReferedIndex = std::min(cache->loadedCount + m_chunkSize, cache->queryCount);
if (!m_appendTask)
asyncFetchMore();
}
template<typename T>
void ListCache<T>::invalidate()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment