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

KCal Library

  • 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 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:29:13 by doxygen 1.8.3.1 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
  • Related Pages

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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