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

KCal Library

  • sources
  • kde-4.12
  • kdepimlibs
  • kcal
assignmentvisitor.cpp
1 /*
2  Copyright (c) 2009 Kevin Krammer <kevin.krammer@gmx.at>
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 "assignmentvisitor.h"
21 
22 #include "event.h"
23 #include "freebusy.h"
24 #include "journal.h"
25 #include "todo.h"
26 
27 #include <kdebug.h>
28 
29 using namespace KCal;
30 
31 class AssignmentVisitor::Private
32 {
33  public:
34  Private() : mSource( 0 ) {}
35 
36  public:
37  const IncidenceBase *mSource;
38 };
39 
40 AssignmentVisitor::AssignmentVisitor() : d( new Private() )
41 {
42 }
43 
44 AssignmentVisitor::~AssignmentVisitor()
45 {
46  delete d;
47 }
48 
49 bool AssignmentVisitor::assign( IncidenceBase *target, const IncidenceBase *source )
50 {
51  Q_ASSERT( target != 0 );
52  Q_ASSERT( source != 0 );
53 
54  d->mSource = source;
55 
56  bool result = target->accept( *this );
57 
58  d->mSource = 0;
59 
60  return result;
61 }
62 
63 bool AssignmentVisitor::visit( Event *event )
64 {
65  Q_ASSERT( event != 0 );
66 
67  const Event *source = dynamic_cast<const Event*>( d->mSource );
68  if ( source == 0 ) {
69  kError() << "Type mismatch: source is" << d->mSource->type()
70  << "target is" << event->type();
71  return false;
72  }
73 
74  *event = *source;
75  return true;
76 }
77 
78 bool AssignmentVisitor::visit( Todo *todo )
79 {
80  Q_ASSERT( todo != 0 );
81 
82  const Todo *source = dynamic_cast<const Todo*>( d->mSource );
83  if ( source == 0 ) {
84  kError() << "Type mismatch: source is" << d->mSource->type()
85  << "target is" << todo->type();
86  return false;
87  }
88 
89  *todo = *source;
90  return true;
91 }
92 
93 bool AssignmentVisitor::visit( Journal *journal )
94 {
95  Q_ASSERT( journal != 0 );
96 
97  const Journal *source = dynamic_cast<const Journal*>( d->mSource );
98  if ( source == 0 ) {
99  kError() << "Type mismatch: source is" << d->mSource->type()
100  << "target is" << journal->type();
101  return false;
102  }
103 
104  *journal = *source;
105  return true;
106 }
107 
108 bool AssignmentVisitor::visit( FreeBusy *freebusy )
109 {
110  Q_ASSERT( freebusy != 0 );
111 
112  const FreeBusy *source = dynamic_cast<const FreeBusy*>( d->mSource );
113  if ( source == 0 ) {
114  kError() << "Type mismatch: source is" << d->mSource->type()
115  << "target is" << freebusy->type();
116  return false;
117  }
118 
119  *freebusy = *source;
120  return true;
121 }
122 
123 // kate: space-indent on; indent-width 2; replace-tabs on;
KCal::Todo
Provides a To-do in the sense of RFC2445.
Definition: todo.h:44
KCal::IncidenceBase
An abstract class that provides a common base for all calendar incidence classes. ...
Definition: incidencebase.h:102
KCal::Event
This class provides an Event in the sense of RFC2445.
Definition: event.h:41
KCal::Event::type
QByteArray type() const
Definition: event.cpp:108
KCal::AssignmentVisitor::assign
bool assign(IncidenceBase *target, const IncidenceBase *source)
Assigns the incidence referenced by source to the incidence referenced by target, first ensuring that...
Definition: assignmentvisitor.cpp:49
todo.h
This file is part of the API for handling calendar data and defines the Todo class.
KCal::AssignmentVisitor::AssignmentVisitor
AssignmentVisitor()
Creates a visitor instance.
Definition: assignmentvisitor.cpp:40
KCal::Journal::type
QByteArray type() const
Definition: journal.cpp:45
freebusy.h
This file is part of the API for handling calendar data and defines the FreeBusy class.
KCal::Journal
Provides a Journal in the sense of RFC2445.
Definition: journal.h:43
KCal::FreeBusy::type
QByteArray type() const
Definition: freebusy.cpp:217
KCal::IncidenceBase::accept
virtual bool accept(Visitor &v)
Accept IncidenceVisitor.
Definition: incidencebase.h:228
journal.h
This file is part of the API for handling calendar data and defines the Journal class.
KCal::AssignmentVisitor::~AssignmentVisitor
virtual ~AssignmentVisitor()
Destroys the instance.
Definition: assignmentvisitor.cpp:44
event.h
This file is part of the API for handling calendar data and defines the Event class.
KCal::AssignmentVisitor::visit
virtual bool visit(Event *event)
Tries to assign to the given event, using the source passed to assign().
Definition: assignmentvisitor.cpp:63
KCal::FreeBusy
Provides information about the free/busy time of a calendar.
Definition: freebusy.h:50
KCal::Todo::type
QByteArray type() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCal Library

Skip menu "KCal Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • 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