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

KCal Library

comparisonvisitor.cpp
00001 /*
00002   Copyright 2009 Ingo Klöcker <kloecker@kde.org>
00003 
00004   This library is free software; you can redistribute it and/or modify it
00005   under the terms of the GNU Library General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or (at your
00007   option) any later version.
00008 
00009   This library is distributed in the hope that it will be useful, but WITHOUT
00010   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012   License for more details.
00013 
00014   You should have received a copy of the GNU Library General Public License
00015   along with this library; see the file COPYING.LIB.  If not, write to the
00016   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017   02110-1301, USA.
00018 */
00019 
00020 #include "comparisonvisitor.h"
00021 #include "event.h"
00022 #include "freebusy.h"
00023 #include "journal.h"
00024 #include "todo.h"
00025 
00026 using namespace KCal;
00027 
00028 class ComparisonVisitor::Private
00029 {
00030   public:
00031     Private() : mReference( 0 ) {}
00032 
00033   public:
00034     const IncidenceBase *mReference;
00035 };
00036 
00037 ComparisonVisitor::ComparisonVisitor() : d( new Private() )
00038 {
00039 }
00040 
00041 ComparisonVisitor::~ComparisonVisitor()
00042 {
00043   delete d;
00044 }
00045 
00046 bool ComparisonVisitor::compare( IncidenceBase *incidence, const IncidenceBase *reference )
00047 {
00048   d->mReference = reference;
00049 
00050   const bool result = incidence ? incidence->accept( *this ) : reference == 0;
00051 
00052   d->mReference = 0;
00053 
00054   return result;
00055 }
00056 
00057 bool ComparisonVisitor::visit( Event *event )
00058 {
00059   Q_ASSERT( event != 0 );
00060 
00061   const Event *refEvent = dynamic_cast<const Event*>( d->mReference );
00062   if ( refEvent ) {
00063     return *event == *refEvent;
00064   } else {
00065     // refEvent is no Event and thus cannot be equal to event
00066     return false;
00067   }
00068 }
00069 
00070 bool ComparisonVisitor::visit( Todo *todo )
00071 {
00072   Q_ASSERT( todo != 0 );
00073 
00074   const Todo *refTodo = dynamic_cast<const Todo*>( d->mReference );
00075   if ( refTodo ) {
00076     return *todo == *refTodo;
00077   } else {
00078     // refTodo is no Todo and thus cannot be equal to todo
00079     return false;
00080   }
00081 }
00082 
00083 bool ComparisonVisitor::visit( Journal *journal )
00084 {
00085   Q_ASSERT( journal != 0 );
00086 
00087   const Journal *refJournal = dynamic_cast<const Journal*>( d->mReference );
00088   if ( refJournal ) {
00089     return *journal == *refJournal;
00090   } else {
00091     // refJournal is no Journal and thus cannot be equal to journal
00092     return false;
00093   }
00094 }
00095 
00096 bool ComparisonVisitor::visit( FreeBusy *freebusy )
00097 {
00098   Q_ASSERT( freebusy != 0 );
00099 
00100   const FreeBusy *refFreeBusy = dynamic_cast<const FreeBusy*>( d->mReference );
00101   if ( refFreeBusy ) {
00102     return *freebusy == *refFreeBusy;
00103   } else {
00104     // refFreeBusy is no FreeBusy and thus cannot be equal to freebusy
00105     return false;
00106   }
00107 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Tue May 8 2012 00:03:20 by doxygen 1.8.0 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.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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