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

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
  • calendar
fetchjobcalendar.cpp
1 /*
2  Copyright (C) 2011 Sérgio Martins <sergio.martins@kdab.com>
3  Copyright (C) 2012 Sérgio Martins <iamsergio@gmail.com>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  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 the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #include "fetchjobcalendar.h"
22 #include "fetchjobcalendar_p.h"
23 #include "incidencefetchjob_p.h"
24 
25 #include <akonadi/item.h>
26 #include <akonadi/collection.h>
27 
28 using namespace Akonadi;
29 using namespace KCalCore;
30 
31 FetchJobCalendarPrivate::FetchJobCalendarPrivate(FetchJobCalendar *qq) : CalendarBasePrivate(qq)
32  , m_isLoaded(false)
33  , q(qq)
34 {
35  IncidenceFetchJob *job = new IncidenceFetchJob();
36  connect(job, SIGNAL(result(KJob*)),
37  SLOT(slotSearchJobFinished(KJob*)));
38 }
39 
40 FetchJobCalendarPrivate::~FetchJobCalendarPrivate()
41 {
42 }
43 
44 void FetchJobCalendarPrivate::slotSearchJobFinished(KJob *job)
45 {
46  IncidenceFetchJob *searchJob = static_cast<Akonadi::IncidenceFetchJob*>(job);
47  bool success = true;
48  QString errorMessage;
49  if (searchJob->error()) {
50  success = false;
51  errorMessage = searchJob->errorText();
52  kWarning() << "Unable to fetch incidences:" << searchJob->errorText();
53  } else {
54  foreach(const Akonadi::Item &item, searchJob->items()) {
55  if (!item.isValid() || !item.hasPayload<KCalCore::Incidence::Ptr>()) {
56  success = false;
57  errorMessage = QString("Invalid item or payload: %1").arg(item.id());
58  kWarning() << "Unable to fetch incidences:" << errorMessage;
59  continue;
60  }
61  internalInsert(item);
62  }
63  }
64  m_isLoaded = true;
65  // emit loadFinished() in a delayed manner, due to freezes because of execs.
66  QMetaObject::invokeMethod(q, "loadFinished", Qt::QueuedConnection,
67  Q_ARG(bool, success), Q_ARG(QString, errorMessage));
68 }
69 
70 FetchJobCalendar::FetchJobCalendar(QObject *parent) : CalendarBase(new FetchJobCalendarPrivate(this), parent)
71 {
72 }
73 
74 FetchJobCalendar::~FetchJobCalendar()
75 {
76 }
77 
78 bool FetchJobCalendar::isLoaded() const
79 {
80  FetchJobCalendarPrivate *d = static_cast<FetchJobCalendarPrivate*>(d_ptr.data());
81  return d->m_isLoaded;
82 }
83 
84 #include "moc_fetchjobcalendar.cpp"
85 #include "moc_fetchjobcalendar_p.cpp"
Akonadi::IncidenceFetchJob
Retrieve all incidences in all calendars.
Definition: incidencefetchjob_p.h:36
Akonadi::FetchJobCalendar::~FetchJobCalendar
~FetchJobCalendar()
Destroys this FetchJobCalendar.
Definition: fetchjobcalendar.cpp:74
Akonadi::FetchJobCalendar::FetchJobCalendar
FetchJobCalendar(QObject *parent=0)
Creates a new FetchJobCalendar.
Definition: fetchjobcalendar.cpp:70
Akonadi::FetchJobCalendar::isLoaded
bool isLoaded() const
Returns if the calendar already finished loading.
Definition: fetchjobcalendar.cpp:78
Akonadi::FetchJobCalendar
A KCalCore::Calendar that uses a one time IncidenceFetchJob to populate itself.
Definition: fetchjobcalendar.h:45
Akonadi::CalendarBase
The base class for all akonadi aware calendars.
Definition: calendarbase.h:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

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