• 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
comparisonvisitor.cpp
1 /*
2  Copyright 2009 Ingo Klöcker <kloecker@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 "comparisonvisitor.h"
21 #include "event.h"
22 #include "freebusy.h"
23 #include "journal.h"
24 #include "todo.h"
25 
26 using namespace KCal;
27 
28 class ComparisonVisitor::Private
29 {
30  public:
31  Private() : mReference( 0 ) {}
32 
33  public:
34  const IncidenceBase *mReference;
35 };
36 
37 ComparisonVisitor::ComparisonVisitor() : d( new Private() )
38 {
39 }
40 
41 ComparisonVisitor::~ComparisonVisitor()
42 {
43  delete d;
44 }
45 
46 bool ComparisonVisitor::compare( IncidenceBase *incidence, const IncidenceBase *reference )
47 {
48  d->mReference = reference;
49 
50  const bool result = incidence ? incidence->accept( *this ) : reference == 0;
51 
52  d->mReference = 0;
53 
54  return result;
55 }
56 
57 bool ComparisonVisitor::visit( Event *event )
58 {
59  Q_ASSERT( event != 0 );
60 
61  const Event *refEvent = dynamic_cast<const Event*>( d->mReference );
62  if ( refEvent ) {
63  return *event == *refEvent;
64  } else {
65  // refEvent is no Event and thus cannot be equal to event
66  return false;
67  }
68 }
69 
70 bool ComparisonVisitor::visit( Todo *todo )
71 {
72  Q_ASSERT( todo != 0 );
73 
74  const Todo *refTodo = dynamic_cast<const Todo*>( d->mReference );
75  if ( refTodo ) {
76  return *todo == *refTodo;
77  } else {
78  // refTodo is no Todo and thus cannot be equal to todo
79  return false;
80  }
81 }
82 
83 bool ComparisonVisitor::visit( Journal *journal )
84 {
85  Q_ASSERT( journal != 0 );
86 
87  const Journal *refJournal = dynamic_cast<const Journal*>( d->mReference );
88  if ( refJournal ) {
89  return *journal == *refJournal;
90  } else {
91  // refJournal is no Journal and thus cannot be equal to journal
92  return false;
93  }
94 }
95 
96 bool ComparisonVisitor::visit( FreeBusy *freebusy )
97 {
98  Q_ASSERT( freebusy != 0 );
99 
100  const FreeBusy *refFreeBusy = dynamic_cast<const FreeBusy*>( d->mReference );
101  if ( refFreeBusy ) {
102  return *freebusy == *refFreeBusy;
103  } else {
104  // refFreeBusy is no FreeBusy and thus cannot be equal to freebusy
105  return false;
106  }
107 }
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::ComparisonVisitor::compare
bool compare(IncidenceBase *incidence, const IncidenceBase *reference)
Compares the incidence referenced by incidence to the incidence referenced by reference.
Definition: comparisonvisitor.cpp:46
KCal::ComparisonVisitor::ComparisonVisitor
ComparisonVisitor()
Creates a visitor instance.
Definition: comparisonvisitor.cpp:37
todo.h
This file is part of the API for handling calendar data and defines the Todo class.
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::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::ComparisonVisitor::visit
virtual bool visit(Event *event)
Compares the event referenced by event to the incidence passed to compare().
Definition: comparisonvisitor.cpp:57
event.h
This file is part of the API for handling calendar data and defines the Event class.
KCal::ComparisonVisitor::~ComparisonVisitor
virtual ~ComparisonVisitor()
Destroys the instance.
Definition: comparisonvisitor.cpp:41
KCal::FreeBusy
Provides information about the free/busy time of a calendar.
Definition: freebusy.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: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