File indexing completed on 2025-03-09 04:56:52
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Kevin Ottens <ervin@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 0007 #include "akonadifakejobs.h" 0008 0009 #include <KCalendarCore/Todo> 0010 0011 #include <QTimer> 0012 0013 using namespace Testlib; 0014 0015 void AkonadiFakeCollectionFetchJob::setCollections(const Akonadi::Collection::List &collections) 0016 { 0017 m_collections = collections; 0018 } 0019 0020 Akonadi::Collection::List AkonadiFakeCollectionFetchJob::collections() const 0021 { 0022 auto result = isDone() ? m_collections : Akonadi::Collection::List(); 0023 0024 if (m_resource.isEmpty()) { 0025 auto it = std::remove_if(result.begin(), result.end(), 0026 [] (const Akonadi::Collection &col) { 0027 const auto mime = col.contentMimeTypes(); 0028 return !mime.contains(KCalendarCore::Todo::todoMimeType()); 0029 }); 0030 result.erase(it, std::end(result)); 0031 } 0032 0033 return result; 0034 } 0035 0036 QString AkonadiFakeCollectionFetchJob::resource() const 0037 { 0038 return m_resource; 0039 } 0040 0041 void AkonadiFakeCollectionFetchJob::setResource(const QString &resource) 0042 { 0043 m_resource = resource; 0044 } 0045 0046 void AkonadiFakeItemFetchJob::setItems(const Akonadi::Item::List &items) 0047 { 0048 m_items = items; 0049 } 0050 0051 Akonadi::Item::List AkonadiFakeItemFetchJob::items() const 0052 { 0053 if (expectedError() != KJob::NoError) 0054 return m_items; 0055 0056 return isDone() ? m_items : Akonadi::Item::List(); 0057 } 0058 0059 Akonadi::Collection AkonadiFakeItemFetchJob::collection() const 0060 { 0061 return m_collection; 0062 } 0063 0064 void AkonadiFakeItemFetchJob::setCollection(const Akonadi::Collection &collection) 0065 { 0066 m_collection = collection; 0067 } 0068 0069 0070 #include "moc_akonadifakejobs.cpp"