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