event.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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( Opaque )
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 Event *Event::clone()
00046 {
00047 kdDebug(5800) << "Event::clone()" << endl;
00048 return new Event(*this);
00049 }
00050
00051 bool Event::operator==( const Event& e2 ) const
00052 {
00053 return
00054 static_cast<const Incidence&>(*this) == static_cast<const Incidence&>(e2) &&
00055 dtEnd() == e2.dtEnd() &&
00056 hasEndDate() == e2.hasEndDate() &&
00057 transparency() == e2.transparency();
00058 }
00059
00060
00061
00062 void Event::setDtEnd(const QDateTime &dtEnd)
00063 {
00064 if (mReadOnly) return;
00065
00066 mDtEnd = dtEnd;
00067
00068 setHasEndDate(true);
00069 setHasDuration(false);
00070
00071 updated();
00072 }
00073
00074 QDateTime Event::dtEnd() const
00075 {
00076 if (hasEndDate()) return mDtEnd;
00077 if (hasDuration()) return dtStart().addSecs(duration());
00078
00079 kdDebug(5800) << "Warning! Event '" << summary()
00080 << "' does have neither end date nor duration." << endl;
00081 return dtStart();
00082 }
00083
00084 QString Event::dtEndTimeStr() const
00085 {
00086 return KGlobal::locale()->formatTime(mDtEnd.time());
00087 }
00088
00089 QString Event::dtEndDateStr(bool shortfmt) const
00090 {
00091 return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt);
00092 }
00093
00094 QString Event::dtEndStr() const
00095 {
00096 return KGlobal::locale()->formatDateTime(mDtEnd);
00097 }
00098
00099 void Event::setHasEndDate(bool b)
00100 {
00101 mHasEndDate = b;
00102 }
00103
00104 bool Event::hasEndDate() const
00105 {
00106 return mHasEndDate;
00107 }
00108
00109 bool Event::isMultiDay() const
00110 {
00111 bool multi = !(dtStart().date() == dtEnd().date());
00112 return multi;
00113 }
00114
00115 void Event::setTransparency(Event::Transparency transparency)
00116 {
00117 if (mReadOnly) return;
00118 mTransparency = transparency;
00119 updated();
00120 }
00121
00122 Event::Transparency Event::transparency() const
00123 {
00124 return mTransparency;
00125 }
00126
00127 void Event::setDuration(int seconds)
00128 {
00129 setHasEndDate(false);
00130 Incidence::setDuration(seconds);
00131 }
This file is part of the documentation for libkcal Library Version 3.2.2.