• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 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
26using namespace KCal;
27
28class ComparisonVisitor::Private
29{
30 public:
31 Private() : mReference( 0 ) {}
32
33 public:
34 const IncidenceBase *mReference;
35};
36
37ComparisonVisitor::ComparisonVisitor() : d( new Private() )
38{
39}
40
41ComparisonVisitor::~ComparisonVisitor()
42{
43 delete d;
44}
45
46bool 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
57bool 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
70bool 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
83bool 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
96bool 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::ComparisonVisitor::ComparisonVisitor
ComparisonVisitor()
Creates a visitor instance.
Definition: comparisonvisitor.cpp:37
KCal::ComparisonVisitor::~ComparisonVisitor
virtual ~ComparisonVisitor()
Destroys the instance.
Definition: comparisonvisitor.cpp:41
KCal::ComparisonVisitor::visit
virtual bool visit(Event *event)
Compares the event referenced by event to the incidence passed to compare().
Definition: comparisonvisitor.cpp:57
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::Event
This class provides an Event in the sense of RFC2445.
Definition: event.h:42
KCal::FreeBusy
Provides information about the free/busy time of a calendar.
Definition: freebusy.h:51
KCal::IncidenceBase
An abstract class that provides a common base for all calendar incidence classes.
Definition: incidencebase.h:103
KCal::IncidenceBase::accept
virtual bool accept(Visitor &v)
Accept IncidenceVisitor.
Definition: incidencebase.h:228
KCal::Journal
Provides a Journal in the sense of RFC2445.
Definition: journal.h:44
KCal::Todo
Provides a To-do in the sense of RFC2445.
Definition: todo.h:45
event.h
This file is part of the API for handling calendar data and defines the Event class.
freebusy.h
This file is part of the API for handling calendar data and defines the FreeBusy class.
journal.h
This file is part of the API for handling calendar data and defines the Journal class.
todo.h
This file is part of the API for handling calendar data and defines the Todo class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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-4.14.10 API Reference

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