2
Copyright (c) 2011 Tobias Koenig <tokoe@kde.org>
4
This library is free software; you can redistribute it and/or modify it
5
under the terms of the GNU Library General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or (at your
7
option) any later version.
9
This library is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12
License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to the
16
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20
#include "groupwareuidelegate.h"
22
#include "incidenceview.h"
24
#include <akonadi/changerecorder.h>
25
#include <akonadi/itemfetchscope.h>
26
#include <akonadi/session.h>
27
#include <calendarsupport/calendar.h>
28
#include <calendarsupport/calendarmodel.h>
29
#include <calendarsupport/kcalprefs.h>
30
#include <calendarsupport/utils.h>
32
#include <ksystemtimezone.h>
34
GroupwareUiDelegate::GroupwareUiDelegate()
39
void GroupwareUiDelegate::setCalendar( CalendarSupport::Calendar *calendar )
44
void GroupwareUiDelegate::createCalendar()
46
Akonadi::Session *session = new Akonadi::Session( "GroupwareIntegration", this );
47
Akonadi::ChangeRecorder *monitor = new Akonadi::ChangeRecorder( this );
49
Akonadi::ItemFetchScope scope;
50
scope.fetchFullPayload( true );
52
monitor->setSession( session );
53
monitor->setCollectionMonitored( Akonadi::Collection::root() );
54
monitor->fetchCollection( true );
55
monitor->setItemFetchScope( scope );
56
monitor->setMimeTypeMonitored( "text/calendar" );
57
monitor->setMimeTypeMonitored( KCalCore::Event::eventMimeType(), true );
58
monitor->setMimeTypeMonitored( KCalCore::Todo::todoMimeType(), true );
59
monitor->setMimeTypeMonitored( KCalCore::Journal::journalMimeType(), true );
61
CalendarSupport::CalendarModel *calendarModel =
62
new CalendarSupport::CalendarModel( monitor, this );
63
calendarModel->setObjectName( "Groupware calendar model" );
65
mCalendar = new CalendarSupport::Calendar( calendarModel, calendarModel,
66
KSystemTimeZones::local() );
67
mCalendar->setObjectName( "Groupware calendar" );
68
mCalendar->setOwner( KCalCore::Person( CalendarSupport::KCalPrefs::instance()->fullName(),
69
CalendarSupport::KCalPrefs::instance()->email() ) );
72
void GroupwareUiDelegate::requestIncidenceEditor( const Akonadi::Item &item )
74
const KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( item );
76
kWarning() << "Incidence is null, won't open the editor";
80
IncidenceView *editor = new IncidenceView;
81
editor->setWindowTitle( i18n( "Kontact Touch Calendar" ) );
82
editor->load( item, QDate::currentDate() );
84
editor->setIsCounterProposal( true );