libkcal Library API Documentation

event.cpp

00001 /*
00002     This file is part of libkcal.
00003     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include <kglobal.h>
00022 #include <klocale.h>
00023 #include <kdebug.h>
00024 
00025 #include "event.h"
00026 
00027 using namespace KCal;
00028 
00029 Event::Event() :
00030   mHasEndDate(false), mTransparency(0) 
00031 {
00032 }
00033 
00034 Event::Event(const Event &e) : Incidence(e)
00035 {
00036   mDtEnd = e.mDtEnd;
00037   mHasEndDate = e.mHasEndDate;
00038   mTransparency = e.mTransparency;
00039 }
00040 
00041 Event::~Event()
00042 {
00043 }
00044 
00045 Incidence *Event::clone()
00046 {
00047   kdDebug(5800) << "Event::clone()" << endl;
00048   return new Event(*this);
00049 }
00050 
00051 void Event::setDtEnd(const QDateTime &dtEnd)
00052 {  
00053   if (mReadOnly) return;
00054 
00055   mDtEnd = dtEnd;
00056 
00057   setHasEndDate(true);
00058   setHasDuration(false);
00059   
00060   updated();
00061 }
00062 
00063 QDateTime Event::dtEnd() const
00064 {
00065   if (hasEndDate()) return mDtEnd;
00066   if (hasDuration()) return dtStart().addSecs(duration());
00067 
00068   kdDebug(5800) << "Warning! Event '" << summary()
00069             << "' does have neither end date nor duration." << endl;
00070   return dtStart();
00071 }
00072 
00073 QString Event::dtEndTimeStr() const
00074 {
00075   return KGlobal::locale()->formatTime(mDtEnd.time());
00076 }
00077 
00078 QString Event::dtEndDateStr(bool shortfmt) const
00079 {
00080   return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt);
00081 }
00082 
00083 QString Event::dtEndStr() const
00084 {
00085   return KGlobal::locale()->formatDateTime(mDtEnd);
00086 }
00087 
00088 void Event::setHasEndDate(bool b)
00089 {
00090   mHasEndDate = b;
00091 }
00092 
00093 bool Event::hasEndDate() const
00094 {
00095   return mHasEndDate;
00096 }
00097 
00098 bool Event::isMultiDay() const
00099 {
00100   bool multi = !(dtStart().date() == dtEnd().date());
00101   return multi;
00102 }
00103 
00104 
00105 void Event::setTransparency(int transparency)
00106 {
00107   if (mReadOnly) return;
00108   mTransparency = transparency;
00109   updated();
00110 }
00111 
00112 int Event::transparency() const
00113 {
00114   return mTransparency;
00115 }
00116 
00117 void Event::setDuration(int seconds)
00118 {
00119   setHasEndDate(false);
00120   Incidence::setDuration(seconds);
00121 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:03 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001