• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

calendarsupport

  • sources
  • kde-4.12
  • kdepim
  • calendarsupport
  • next
incidencefetchjob.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3  Author: Volker Krause <vkrause@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "incidencefetchjob.h"
22 
23 #include <Akonadi/CollectionFetchJob>
24 #include <Akonadi/CollectionFetchScope>
25 #include <Akonadi/ItemFetchJob>
26 #include <Akonadi/ItemFetchScope>
27 
28 #include <KCalCore/Event>
29 #include <KCalCore/Journal>
30 #include <KCalCore/Todo>
31 #include <QDebug>
32 
33 using namespace Akonadi;
34 
35 CalendarSupport::IncidenceFetchJob::IncidenceFetchJob( QObject *parent )
36  : Job(parent), m_jobCount( 0 )
37 {
38  m_mimeTypeChecker.addWantedMimeType( QLatin1String("text/calendar") );
39 }
40 
41 Item::List CalendarSupport::IncidenceFetchJob::items() const
42 {
43  return m_items;
44 }
45 
46 void CalendarSupport::IncidenceFetchJob::doStart()
47 {
48  CollectionFetchJob *job =
49  new CollectionFetchJob( Collection::root(), CollectionFetchJob::Recursive, this );
50 
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*)) );
56 }
57 
58 void CalendarSupport::IncidenceFetchJob::collectionFetchResult( KJob *job )
59 {
60  if ( job->error() ) { // handled in base class
61  kDebug() << job->error();
62  emitResult();
63  return;
64  }
65  CollectionFetchJob *fetch = qobject_cast<CollectionFetchJob*>( job );
66  Q_ASSERT( fetch );
67  const Akonadi::Collection::List listCollection = fetch->collections();
68  if ( listCollection.isEmpty() ) {
69  emitResult();
70  } else {
71  foreach ( const Collection &col, fetch->collections() ) {
72  if ( !m_mimeTypeChecker.isWantedCollection( col ) ) {
73  continue;
74  }
75  ItemFetchJob *itemFetch = new ItemFetchJob( col, this );
76  itemFetch->fetchScope().fetchFullPayload( true );
77  connect( itemFetch, SIGNAL(result(KJob*)), SLOT(itemFetchResult(KJob*)) );
78  ++m_jobCount;
79  }
80  }
81 }
82 
83 void CalendarSupport::IncidenceFetchJob::itemFetchResult( KJob *job )
84 {
85  if ( job->error() ) { // handled in base class
86  return;
87  }
88 
89  --m_jobCount;
90  ItemFetchJob *fetch = qobject_cast<ItemFetchJob*>( job );
91  foreach ( const Item &item, fetch->items() ) {
92  if ( !m_mimeTypeChecker.isWantedItem( item ) ) {
93  continue;
94  }
95  m_items.push_back( item );
96  }
97 
98  if ( m_jobCount <= 0 ) {
99  emitResult();
100  }
101 }
102 
103 #include "incidencefetchjob.moc"
CalendarSupport::IncidenceFetchJob::doStart
void doStart()
Definition: incidencefetchjob.cpp:46
CalendarSupport::IncidenceFetchJob::items
Akonadi::Item::List items() const
Definition: incidencefetchjob.cpp:41
QObject
incidencefetchjob.h
CalendarSupport::IncidenceFetchJob::IncidenceFetchJob
IncidenceFetchJob(QObject *parent=0)
Definition: incidencefetchjob.cpp:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

calendarsupport

Skip menu "calendarsupport"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal