Commit ea2343ab authored by Konrad Czapla's avatar Konrad Czapla
Browse files

Add setLimit to get only limited number of items

parent bc84f13e
......@@ -104,6 +104,7 @@ public:
ProtocolHelperValuePool *mValuePool = nullptr;
ItemFetchJob::DeliveryOptions mDeliveryOptions = ItemFetchJob::Default;
int mCount = 0;
Protocol::FetchLimit mItemsLimit;
};
ItemFetchJob::ItemFetchJob(const Collection &collection, QObject *parent)
......@@ -178,7 +179,8 @@ void ItemFetchJob::doStart()
d->sendCommand(Protocol::FetchItemsCommandPtr::create(d->mRequestedItems.isEmpty() ? Scope() : ProtocolHelper::entitySetToScope(d->mRequestedItems),
ProtocolHelper::commandContextToProtocol(d->mCollection, d->mCurrentTag, d->mRequestedItems),
ProtocolHelper::itemFetchScopeToProtocol(d->mFetchScope),
ProtocolHelper::tagFetchScopeToProtocol(d->mFetchScope.tagFetchScope())));
ProtocolHelper::tagFetchScopeToProtocol(d->mFetchScope.tagFetchScope()),
d->mItemsLimit));
} catch (const Akonadi::Exception &e) {
setError(Job::Unknown);
setErrorText(QString::fromUtf8(e.what()));
......@@ -279,4 +281,12 @@ int ItemFetchJob::count() const
return d->mCount;
}
void ItemFetchJob::setLimit(int limit, int start, Qt::SortOrder order)
{
Q_D(ItemFetchJob);
d->mItemsLimit.setLimit(limit);
d->mItemsLimit.setLimitOffset(start);
d->mItemsLimit.setSortOrder(order);
}
#include "moc_itemfetchjob.cpp"
......@@ -225,6 +225,17 @@ public:
*/
int count() const;
/**
* Sets the limit of fetched items.
*
* @param limit the maximum number of items to retrieve.
* @param start specifies the offset of the first item to retrieve.
* @param order specifies whether items will be fetched
* starting with the highest or lowest ID of the item.
*/
void setLimit(int limit, int start, Qt::SortOrder order = Qt::DescendingOrder);
Q_SIGNALS:
/**
* This signal is emitted whenever new items have been fetched completely.
......
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