File indexing completed on 2024-11-24 04:44:34

0001 /*  This file is part of the KDE project
0002     SPDX-FileCopyrightText: 2009 Kevin Krammer <kevin.krammer@gmx.at>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "itemfetchjob.h"
0008 
0009 #include "session_p.h"
0010 
0011 #include <Akonadi/ItemFetchScope>
0012 
0013 using namespace Akonadi;
0014 
0015 class FileStore::ItemFetchJobPrivate
0016 {
0017 public:
0018     ItemFetchScope mFetchScope;
0019 
0020     Item::List mRequestedItems;
0021     Item::List mResultItems;
0022 
0023     Collection mCollection;
0024     Item mItem;
0025 };
0026 
0027 FileStore::ItemFetchJob::ItemFetchJob(const Collection &collection, FileStore::AbstractJobSession *session)
0028     : FileStore::Job(session)
0029     , d(new ItemFetchJobPrivate())
0030 {
0031     d->mCollection = collection;
0032 
0033     session->addJob(this);
0034 }
0035 
0036 FileStore::ItemFetchJob::ItemFetchJob(const Item &item, FileStore::AbstractJobSession *session)
0037     : FileStore::Job(session)
0038     , d(new ItemFetchJobPrivate())
0039 {
0040     d->mItem = item;
0041 
0042     session->addJob(this);
0043 }
0044 
0045 FileStore::ItemFetchJob::ItemFetchJob(const Item::List &items, FileStore::AbstractJobSession *session)
0046     : FileStore::Job(session)
0047     , d(new ItemFetchJobPrivate())
0048 {
0049     d->mRequestedItems = items;
0050 
0051     session->addJob(this);
0052 }
0053 
0054 FileStore::ItemFetchJob::~ItemFetchJob() = default;
0055 
0056 Collection FileStore::ItemFetchJob::collection() const
0057 {
0058     return d->mCollection;
0059 }
0060 
0061 Item FileStore::ItemFetchJob::item() const
0062 {
0063     return d->mItem;
0064 }
0065 
0066 void FileStore::ItemFetchJob::setFetchScope(const ItemFetchScope &fetchScope)
0067 {
0068     d->mFetchScope = fetchScope;
0069 }
0070 
0071 ItemFetchScope &FileStore::ItemFetchJob::fetchScope()
0072 {
0073     return d->mFetchScope;
0074 }
0075 
0076 Item::List FileStore::ItemFetchJob::requestedItems() const
0077 {
0078     return d->mRequestedItems;
0079 }
0080 
0081 Item::List FileStore::ItemFetchJob::items() const
0082 {
0083     return d->mResultItems;
0084 }
0085 
0086 bool FileStore::ItemFetchJob::accept(FileStore::Job::Visitor *visitor)
0087 {
0088     return visitor->visit(this);
0089 }
0090 
0091 void FileStore::ItemFetchJob::handleItemsReceived(const Item::List &items)
0092 {
0093     d->mResultItems << items;
0094 
0095     Q_EMIT itemsReceived(items);
0096 }
0097 
0098 #include "moc_itemfetchjob.cpp"