~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to mobile/lib/calendar/groupwareuidelegate.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2011 Tobias Koenig <tokoe@kde.org>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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
 
17
    02110-1301, USA.
 
18
*/
 
19
 
 
20
#include "groupwareuidelegate.h"
 
21
 
 
22
#include "incidenceview.h"
 
23
 
 
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>
 
31
#include <klocale.h>
 
32
#include <ksystemtimezone.h>
 
33
 
 
34
GroupwareUiDelegate::GroupwareUiDelegate()
 
35
  : mCalendar( 0 )
 
36
{
 
37
}
 
38
 
 
39
void GroupwareUiDelegate::setCalendar( CalendarSupport::Calendar *calendar )
 
40
{
 
41
  mCalendar = calendar;
 
42
}
 
43
 
 
44
void GroupwareUiDelegate::createCalendar()
 
45
{
 
46
  Akonadi::Session *session = new Akonadi::Session( "GroupwareIntegration", this );
 
47
  Akonadi::ChangeRecorder *monitor = new Akonadi::ChangeRecorder( this );
 
48
 
 
49
  Akonadi::ItemFetchScope scope;
 
50
  scope.fetchFullPayload( true );
 
51
 
 
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 );
 
60
 
 
61
  CalendarSupport::CalendarModel *calendarModel =
 
62
    new CalendarSupport::CalendarModel( monitor, this );
 
63
  calendarModel->setObjectName( "Groupware calendar model" );
 
64
 
 
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() ) );
 
70
}
 
71
 
 
72
void GroupwareUiDelegate::requestIncidenceEditor( const Akonadi::Item &item )
 
73
{
 
74
  const KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( item );
 
75
  if ( !incidence ) {
 
76
    kWarning() << "Incidence is null, won't open the editor";
 
77
    return;
 
78
  }
 
79
 
 
80
  IncidenceView *editor = new IncidenceView;
 
81
  editor->setWindowTitle( i18n( "Kontact Touch Calendar" ) );
 
82
  editor->load( item, QDate::currentDate() );
 
83
 
 
84
  editor->setIsCounterProposal( true );
 
85
  editor->show();
 
86
}