23 #include <Akonadi/CollectionFetchJob>
24 #include <Akonadi/CollectionFetchScope>
25 #include <Akonadi/ItemFetchJob>
26 #include <Akonadi/ItemFetchScope>
28 #include <KCalCore/Event>
29 #include <KCalCore/Journal>
30 #include <KCalCore/Todo>
33 using namespace Akonadi;
36 : Job(parent), m_jobCount( 0 )
38 m_mimeTypeChecker.addWantedMimeType( QLatin1String(
"text/calendar") );
48 CollectionFetchJob *job =
49 new CollectionFetchJob( Collection::root(), CollectionFetchJob::Recursive,
this );
51 job->fetchScope().setContentMimeTypes( QStringList() << QLatin1String(
"text/calendar" )
52 << KCalCore::Event::eventMimeType()
53 << KCalCore::Todo::todoMimeType()
54 << KCalCore::Journal::journalMimeType() );
55 connect( job, SIGNAL(result(KJob*)), SLOT(collectionFetchResult(KJob*)) );
58 void CalendarSupport::IncidenceFetchJob::collectionFetchResult( KJob *job )
61 kDebug() << job->error();
65 CollectionFetchJob *fetch = qobject_cast<CollectionFetchJob*>( job );
67 const Akonadi::Collection::List listCollection = fetch->collections();
68 if ( listCollection.isEmpty() ) {
71 foreach (
const Collection &col, fetch->collections() ) {
72 if ( !m_mimeTypeChecker.isWantedCollection( col ) ) {
75 ItemFetchJob *itemFetch =
new ItemFetchJob( col,
this );
76 itemFetch->fetchScope().fetchFullPayload(
true );
77 connect( itemFetch, SIGNAL(result(KJob*)), SLOT(itemFetchResult(KJob*)) );
83 void CalendarSupport::IncidenceFetchJob::itemFetchResult( KJob *job )
90 ItemFetchJob *fetch = qobject_cast<ItemFetchJob*>( job );
91 foreach (
const Item &item, fetch->items() ) {
92 if ( !m_mimeTypeChecker.isWantedItem( item ) ) {
95 m_items.push_back( item );
98 if ( m_jobCount <= 0 ) {
103 #include "incidencefetchjob.moc"
Akonadi::Item::List items() const
IncidenceFetchJob(QObject *parent=0)