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

akonadi

  • 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
28using namespace Akonadi;
29using namespace KCalCore;
30
31FetchJobCalendarPrivate::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
40FetchJobCalendarPrivate::~FetchJobCalendarPrivate()
41{
42}
43
44void 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
70FetchJobCalendar::FetchJobCalendar(QObject *parent) : CalendarBase(new FetchJobCalendarPrivate(this), parent)
71{
72}
73
74FetchJobCalendar::~FetchJobCalendar()
75{
76}
77
78bool 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::CalendarBase
The base class for all akonadi aware calendars.
Definition calendarbase.h:51
Akonadi::FetchJobCalendar
A KCalCore::Calendar that uses a one time IncidenceFetchJob to populate itself.
Definition fetchjobcalendar.h:46
Akonadi::FetchJobCalendar::FetchJobCalendar
FetchJobCalendar(QObject *parent=0)
Creates a new FetchJobCalendar.
Definition fetchjobcalendar.cpp:70
Akonadi::FetchJobCalendar::~FetchJobCalendar
~FetchJobCalendar()
Destroys this FetchJobCalendar.
Definition fetchjobcalendar.cpp:74
Akonadi::FetchJobCalendar::isLoaded
bool isLoaded() const
Returns if the calendar already finished loading.
Definition fetchjobcalendar.cpp:78
Akonadi::IncidenceFetchJob
Retrieve all incidences in all calendars.
Definition incidencefetchjob_p.h:37
Akonadi
FreeBusyManager::Singleton.
Definition actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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