libopie PIM API Documentation

oevent.cpp

Go to the documentation of this file.
00001 #include <qshared.h>
00002 #include <qarray.h>
00003 
00004 #include <qpe/palmtopuidgen.h>
00005 #include <qpe/categories.h>
00006 #include <qpe/stringutil.h>
00007 
00008 #include "orecur.h"
00009 #include "opimresolver.h"
00010 #include "opimnotifymanager.h"
00011 
00012 #include "oevent.h"
00013 
00014 int OCalendarHelper::week( const QDate& date) {
00015     // Calculates the week this date is in within that
00016     // month. Equals the "row" is is in in the month view
00017     int week = 1;
00018     QDate tmp( date.year(), date.month(), 1 );
00019     if ( date.dayOfWeek() < tmp.dayOfWeek() )
00020         ++week;
00021 
00022     week += ( date.day() - 1 ) / 7;
00023 
00024     return week;
00025 }
00026 int OCalendarHelper::ocurrence( const QDate& date) {
00027     // calculates the number of occurrances of this day of the
00028     // week till the given date (e.g 3rd Wednesday of the month)
00029     return ( date.day() - 1 ) / 7 + 1;
00030 }
00031 int OCalendarHelper::dayOfWeek( char day ) {
00032     int dayOfWeek = 1;
00033     char i = ORecur::MON;
00034     while ( !( i & day ) && i <= ORecur::SUN ) {
00035         i <<= 1;
00036         ++dayOfWeek;
00037     }
00038     return dayOfWeek;
00039 }
00040 int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
00041     return ( second.year() - first.year() ) * 12 +
00042         second.month() - first.month();
00043 }
00044 
00045 struct OEvent::Data : public QShared {
00046     Data() : QShared() {
00047         child = 0;
00048         recur = 0;
00049         manager = 0;
00050         isAllDay = false;
00051         parent = 0;
00052     }
00053     ~Data() {
00054         delete manager;
00055         delete recur;
00056     }
00057     QString description;
00058     QString location;
00059     OPimNotifyManager* manager;
00060     ORecur* recur;
00061     QString note;
00062     QDateTime created;
00063     QDateTime start;
00064     QDateTime end;
00065     bool isAllDay : 1;
00066     QString timezone;
00067     QArray<int>* child;
00068     int parent;
00069 };
00070 
00071 OEvent::OEvent( int uid )
00072     : OPimRecord( uid ) {
00073     data = new Data;
00074 }
00075 OEvent::OEvent( const OEvent& ev)
00076     : OPimRecord( ev ), data( ev.data )
00077 {
00078     data->ref();
00079 }
00080 
00081 OEvent::OEvent( const QMap<int, QString> map )
00082     : OPimRecord( 0 )
00083 {
00084     data = new Data;
00085 
00086     fromMap( map );
00087 }
00088 
00089 OEvent::~OEvent() {
00090     if ( data->deref() ) {
00091         delete data;
00092         data = 0;
00093     }
00094 }
00095 OEvent& OEvent::operator=( const OEvent& ev) {
00096     if ( this == &ev ) return  *this;
00097 
00098     OPimRecord::operator=( ev );
00099     ev.data->ref();
00100     deref();
00101     data = ev.data;
00102 
00103 
00104     return *this;
00105 }
00106 QString OEvent::description()const {
00107     return data->description;
00108 }
00109 void OEvent::setDescription( const QString& description ) {
00110     changeOrModify();
00111     data->description = description;
00112 }
00113 void OEvent::setLocation( const QString& loc ) {
00114     changeOrModify();
00115     data->location = loc;
00116 }
00117 QString OEvent::location()const {
00118     return data->location;
00119 }
00120 OPimNotifyManager &OEvent::notifiers()const {
00121     // I hope we can skip the changeOrModify here
00122     // the notifier should take care of it
00123     // and OPimNotify is shared too
00124     if (!data->manager )
00125         data->manager = new OPimNotifyManager;
00126 
00127     return *data->manager;
00128 }
00129 bool OEvent::hasNotifiers()const {
00130     if (!data->manager )
00131         return false;
00132     if (data->manager->reminders().isEmpty() &&
00133         data->manager->alarms().isEmpty() )
00134         return false;
00135 
00136     return true;
00137 }
00138 ORecur OEvent::recurrence()const {
00139     if (!data->recur)
00140         data->recur = new ORecur;
00141 
00142     return *data->recur;
00143 }
00144 void OEvent::setRecurrence( const ORecur& rec) {
00145     changeOrModify();
00146     if (data->recur )
00147         (*data->recur) = rec;
00148     else
00149         data->recur = new ORecur( rec );
00150 }
00151 bool OEvent::hasRecurrence()const {
00152     if (!data->recur ) return false;
00153     return data->recur->doesRecur();
00154 }
00155 QString OEvent::note()const {
00156     return data->note;
00157 }
00158 void OEvent::setNote( const QString& note ) {
00159     changeOrModify();
00160     data->note = note;
00161 }
00162 QDateTime OEvent::createdDateTime()const {
00163     return data->created;
00164 }
00165 void OEvent::setCreatedDateTime( const QDateTime& time ) {
00166     changeOrModify();
00167     data->created = time;
00168 }
00169 QDateTime OEvent::startDateTime()const {
00170     if ( data->isAllDay )
00171         return QDateTime( data->start.date(), QTime(0, 0, 0 ) );
00172     return data->start;
00173 }
00174 QDateTime OEvent::startDateTimeInZone()const {
00175     /* if no timezone, or all day event or if the current and this timeZone match... */
00176     if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime();
00177 
00178     OTimeZone zone(data->timezone  );
00179     return zone.toDateTime( data->start, OTimeZone::current() );
00180 }
00181 void OEvent::setStartDateTime( const QDateTime& dt ) {
00182     changeOrModify();
00183     data->start = dt;
00184 }
00185 QDateTime OEvent::endDateTime()const {
00186     /*
00187      * if all Day event the end time needs
00188      * to be on the same day as the start
00189      */
00190     if ( data->isAllDay )
00191         return QDateTime( data->start.date(), QTime(23, 59, 59 ) );
00192     return data->end;
00193 }
00194 QDateTime OEvent::endDateTimeInZone()const {
00195     /* if no timezone, or all day event or if the current and this timeZone match... */
00196     if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime();
00197 
00198     OTimeZone zone(data->timezone  );
00199     return zone.toDateTime( data->end, OTimeZone::current() );
00200 }
00201 void OEvent::setEndDateTime( const QDateTime& dt ) {
00202     changeOrModify();
00203     data->end =    dt;
00204 }
00205 bool OEvent::isMultipleDay()const {
00206     return data->end.date().day() - data->start.date().day();
00207 }
00208 bool OEvent::isAllDay()const {
00209     return data->isAllDay;
00210 }
00211 void OEvent::setAllDay( bool allDay ) {
00212     changeOrModify();
00213     data->isAllDay = allDay;
00214     if (allDay ) data->timezone = "UTC";
00215 }
00216 void OEvent::setTimeZone( const QString& tz ) {
00217     changeOrModify();
00218     data->timezone = tz;
00219 }
00220 QString OEvent::timeZone()const {
00221     if (data->isAllDay ) return QString::fromLatin1("UTC");
00222     return data->timezone;
00223 }
00224 bool OEvent::match( const QRegExp& re )const {
00225     if ( re.match( data->description ) != -1 ){
00226         setLastHitField( Qtopia::DatebookDescription );
00227         return true;
00228     }
00229     if ( re.match( data->note ) != -1 ){
00230         setLastHitField( Qtopia::Note );
00231         return true;
00232     }
00233     if ( re.match( data->location ) != -1 ){
00234         setLastHitField( Qtopia::Location );
00235         return true;
00236     }
00237     if ( re.match( data->start.toString() ) != -1 ){
00238         setLastHitField( Qtopia::StartDateTime );
00239         return true;
00240     }
00241     if ( re.match( data->end.toString() ) != -1 ){
00242         setLastHitField( Qtopia::EndDateTime );
00243         return true;
00244     }
00245     return false;
00246 }
00247 QString OEvent::toRichText()const {
00248     QString text, value;
00249 
00250     // description
00251     text += "<b><h3><img src=\"datebook/DateBook\">";
00252     if ( !description().isEmpty() ) {
00253         text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"),  "" );
00254     }
00255     text += "</h3></b><br><hr><br>";
00256 
00257     // location
00258     if ( !(value = location()).isEmpty() ) {
00259         text += "<b>" + QObject::tr( "Location:" ) + "</b> ";
00260         text += Qtopia::escapeString(value) + "<br>";
00261     }
00262 
00263     // all day event
00264     if ( isAllDay() ) {
00265         text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>";
00266     }
00267     // multiple day event
00268     else if ( isMultipleDay () ) {
00269         text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>";
00270     }
00271     // start & end times
00272     else {
00273         // start time
00274         if ( startDateTime().isValid() ) {
00275             text += "<b>" + QObject::tr( "Start:") + "</b> ";
00276             text += Qtopia::escapeString(startDateTime().toString() ).
00277                     replace(QRegExp( "[\n]"),  "<br>" ) + "<br>";
00278         }
00279 
00280         // end time
00281         if ( endDateTime().isValid() ) {
00282             text += "<b>" + QObject::tr( "End:") + "</b> ";
00283             text += Qtopia::escapeString(endDateTime().toString() ).
00284                     replace(QRegExp( "[\n]"),  "<br>" ) + "<br>";
00285         }
00286     }
00287 
00288     // categories
00289     if ( categoryNames("Calendar").count() ){
00290         text += "<b>" + QObject::tr( "Category:") + "</b> ";
00291         text += categoryNames("Calendar").join(", ");
00292         text += "<br>";
00293     }
00294 
00295     //notes
00296     if ( !note().isEmpty() ) {
00297         text += "<b>" + QObject::tr( "Note:") + "</b><br>";
00298         text += note();
00299 //         text += Qtopia::escapeString(note() ).
00300 //                 replace(QRegExp( "[\n]"),  "<br>" ) + "<br>";
00301     }
00302     return text;
00303 }
00304 QString OEvent::toShortText()const {
00305     QString text;
00306     text += QString::number( startDateTime().date().day() );
00307     text += ".";
00308     text += QString::number( startDateTime().date().month() );
00309     text += ".";
00310     text += QString::number( startDateTime().date().year() );
00311     text += " ";
00312     text += QString::number( startDateTime().time().hour() );
00313     text += ":";
00314     text += QString::number( startDateTime().time().minute() );
00315     text += " - ";
00316     text += description();
00317     return text;
00318 }
00319 QString OEvent::type()const {
00320     return QString::fromLatin1("OEvent");
00321 }
00322 QString OEvent::recordField( int /*id */ )const {
00323     return QString::null;
00324 }
00325 int OEvent::rtti() {
00326     return OPimResolver::DateBook;
00327 }
00328 bool OEvent::loadFromStream( QDataStream& ) {
00329     return true;
00330 }
00331 bool OEvent::saveToStream( QDataStream& )const {
00332     return true;
00333 }
00334 void OEvent::changeOrModify() {
00335     if ( data->count != 1 ) {
00336         data->deref();
00337         Data* d2 = new Data;
00338         d2->description = data->description;
00339         d2->location = data->location;
00340 
00341         if (data->manager )
00342             d2->manager = new OPimNotifyManager( *data->manager );
00343 
00344         if ( data->recur )
00345             d2->recur = new ORecur( *data->recur );
00346 
00347         d2->note = data->note;
00348         d2->created = data->created;
00349         d2->start = data->start;
00350         d2->end = data->end;
00351         d2->isAllDay = data->isAllDay;
00352         d2->timezone = data->timezone;
00353         d2->parent = data->parent;
00354 
00355         if ( data->child ) {
00356             d2->child = new QArray<int>( *data->child );
00357             d2->child->detach();
00358         }
00359 
00360         data = d2;
00361     }
00362 }
00363 void OEvent::deref() {
00364     if ( data->deref() ) {
00365         delete data;
00366         data = 0;
00367     }
00368 }
00369 // Exporting Event data to map. Using the same
00370 // encoding as ODateBookAccessBackend_xml does..
00371 // Thus, we could remove the stuff there and use this
00372 // for it and for all other places..
00373 // Encoding should happen at one place, only ! (eilers)
00374 QMap<int, QString> OEvent::toMap()const {
00375     QMap<int, QString> retMap;
00376 
00377     retMap.insert( OEvent::FUid, QString::number( uid() ) );
00378     retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ));
00379     retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) );
00380     retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) );
00381     retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" );
00382     OPimAlarm alarm = notifiers().alarms()[0];
00383     retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo(  startDateTime() ) / 60 ) );
00384     retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" );
00385 
00386     OTimeZone zone(  timeZone().isEmpty() ? OTimeZone::current() : timeZone() );
00387     retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime(  startDateTime(), OTimeZone::utc() ) ) ) );
00388     retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime(  endDateTime(), OTimeZone::utc() ) ) ) );
00389     retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) );
00390     retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() );
00391     if( parent() )
00392         retMap.insert( OEvent::FRecParent, QString::number( parent() ) );
00393     if( children().count() ){
00394             QArray<int> childr = children();
00395         QString buf;
00396             for ( uint i = 0; i < childr.count(); i++ ) {
00397             if ( i != 0 ) buf += " ";
00398             buf += QString::number( childr[i] );
00399             }       
00400         retMap.insert( OEvent::FRecChildren, buf );
00401     }
00402     
00403     // Add recurrence stuff
00404     if( hasRecurrence() ){
00405         ORecur recur = recurrence();
00406         QMap<int, QString> recFields = recur.toMap();
00407         retMap.insert( OEvent::FRType, recFields[ORecur::RType] );
00408         retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] );
00409         retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] );
00410         retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] );
00411         retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] );
00412         retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] );
00413         retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] );
00414         retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] );
00415     } else {
00416         ORecur recur = recurrence();
00417         QMap<int, QString> recFields = recur.toMap();
00418         retMap.insert( OEvent::FRType, recFields[ORecur::RType] );
00419     }
00420    
00421     return retMap;
00422 }
00423 
00424 void OEvent::fromMap( const QMap<int, QString>& map )
00425 {
00426 
00427     // We just want to set the UID if it is really stored.
00428     if ( !map[OEvent::FUid].isEmpty() )
00429         setUid( map[OEvent::FUid].toInt() );
00430 
00431     setCategories( idsFromString( map[OEvent::FCategories] ) );
00432     setDescription( map[OEvent::FDescription] );
00433     setLocation( map[OEvent::FLocation] );
00434 
00435     if ( map[OEvent::FType] == "AllDay" )
00436         setAllDay( true );
00437     else
00438         setAllDay( false );
00439     
00440     int alarmTime = -1;
00441     if( !map[OEvent::FAlarm].isEmpty() )
00442         alarmTime = map[OEvent::FAlarm].toInt();
00443 
00444     int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent );
00445     if ( ( alarmTime != -1 )  ){
00446         QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 );
00447         OPimAlarm al( sound ,  dt  );
00448         notifiers().add( al );
00449     }
00450     if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){
00451         setTimeZone( map[OEvent::FTimeZone] );
00452     }
00453     
00454     time_t start = (time_t) map[OEvent::FStart].toLong();
00455     time_t end   = (time_t) map[OEvent::FEnd].toLong();
00456 
00457     /* AllDay is always in UTC */
00458     if ( isAllDay() ) {
00459         OTimeZone utc = OTimeZone::utc();
00460         setStartDateTime( utc.fromUTCDateTime( start ) );
00461         setEndDateTime  ( utc.fromUTCDateTime( end   ) );
00462         setTimeZone( "UTC"); // make sure it is really utc
00463     }else {
00464         /* to current date time */
00465         // qWarning(" Start is %d", start );
00466         OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() );
00467         QDateTime date = zone.toDateTime( start );
00468         qWarning(" Start is %s", date.toString().latin1() );
00469         setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) );
00470 
00471         date = zone.toDateTime( end );
00472         setEndDateTime  ( zone.toDateTime( date, OTimeZone::current() ) );
00473     }
00474     
00475     if ( !map[OEvent::FRecParent].isEmpty() )
00476         setParent( map[OEvent::FRecParent].toInt() );
00477 
00478     if ( !map[OEvent::FRecChildren].isEmpty() ){
00479         QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] );
00480         for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
00481             addChild( (*it).toInt() );
00482         }
00483     }
00484     
00485     // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap..
00486     if( !map[OEvent::FRType].isEmpty() ){
00487         QMap<int, QString> recFields;
00488         recFields.insert( ORecur::RType, map[OEvent::FRType] );
00489         recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] );
00490         recFields.insert( ORecur::RPosition, map[OEvent::FRPosition] );
00491         recFields.insert( ORecur::RFreq, map[OEvent::FRFreq] );
00492         recFields.insert( ORecur::RHasEndDate, map[OEvent::FRHasEndDate] );
00493         recFields.insert( ORecur::EndDate, map[OEvent::FREndDate] );
00494         recFields.insert( ORecur::Created, map[OEvent::FRCreated] );
00495         recFields.insert( ORecur::Exceptions, map[OEvent::FRExceptions] );
00496         ORecur recur( recFields );
00497         setRecurrence( recur );
00498     }
00499     
00500 }
00501 
00502 
00503 int OEvent::parent()const {
00504     return data->parent;
00505 }
00506 void OEvent::setParent( int uid ) {
00507     changeOrModify();
00508     data->parent = uid;
00509 }
00510 QArray<int> OEvent::children() const{
00511     if (!data->child) return QArray<int>();
00512     else
00513         return data->child->copy();
00514 }
00515 void OEvent::setChildren( const QArray<int>& arr ) {
00516     changeOrModify();
00517     if (data->child) delete data->child;
00518 
00519     data->child = new QArray<int>( arr );
00520     data->child->detach();
00521 }
00522 void OEvent::addChild( int uid ) {
00523     changeOrModify();
00524     if (!data->child ) {
00525         data->child = new QArray<int>(1);
00526         (*data->child)[0] = uid;
00527     }else{
00528         int count = data->child->count();
00529         data->child->resize( count + 1 );
00530         (*data->child)[count] = uid;
00531     }
00532 }
00533 void OEvent::removeChild( int uid ) {
00534     if (!data->child || !data->child->contains( uid ) ) return;
00535     changeOrModify();
00536     QArray<int> newAr( data->child->count() - 1 );
00537     int j = 0;
00538     uint count = data->child->count();
00539     for ( uint i = 0; i < count; i++ ) {
00540         if ( (*data->child)[i] != uid ) {
00541             newAr[j] = (*data->child)[i];
00542             j++;
00543         }
00544     }
00545     (*data->child) = newAr;
00546 }
00547 struct OEffectiveEvent::Data : public QShared {
00548     Data() : QShared() {
00549     }
00550     OEvent event;
00551     QDate date;
00552     QTime start, end;
00553     QDate startDate, endDate;
00554     bool dates : 1;
00555 };
00556 
00557 OEffectiveEvent::OEffectiveEvent() {
00558     data = new Data;
00559     data->date = QDate::currentDate();
00560     data->start = data->end = QTime::currentTime();
00561     data->dates = false;
00562 }
00563 OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate,
00564                                   Position pos ) {
00565     data = new Data;
00566     data->event = ev;
00567     data->date = startDate;
00568     if ( pos & Start )
00569         data->start = ev.startDateTime().time();
00570     else
00571         data->start = QTime( 0, 0, 0 );
00572 
00573     if ( pos & End )
00574         data->end = ev.endDateTime().time();
00575     else
00576         data->end = QTime( 23, 59, 59 );
00577 
00578     data->dates = false;
00579 }
00580 OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) {
00581     data = ev.data;
00582     data->ref();
00583 }
00584 OEffectiveEvent::~OEffectiveEvent() {
00585     if ( data->deref() ) {
00586         delete data;
00587         data = 0;
00588     }
00589 }
00590 OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) {
00591     if ( *this == ev ) return  *this;
00592 
00593     ev.data->ref();
00594     deref();
00595     data = ev.data;
00596 
00597     return *this;
00598 }
00599 
00600 void OEffectiveEvent::setStartTime( const QTime& ti) {
00601     changeOrModify();
00602     data->start = ti;
00603 }
00604 void OEffectiveEvent::setEndTime( const QTime& en) {
00605     changeOrModify();
00606     data->end = en;
00607 }
00608 void OEffectiveEvent::setEvent( const OEvent& ev) {
00609     changeOrModify();
00610     data->event = ev;
00611 }
00612 void OEffectiveEvent::setDate( const QDate& da) {
00613     changeOrModify();
00614     data->date = da;
00615 }
00616 void OEffectiveEvent::setEffectiveDates( const QDate& from,
00617                                          const QDate& to ) {
00618     if (!from.isValid() ) {
00619         data->dates = false;
00620         return;
00621     }
00622 
00623     data->startDate = from;
00624     data->endDate = to;
00625 }
00626 QString OEffectiveEvent::description()const {
00627     return data->event.description();
00628 }
00629 QString OEffectiveEvent::location()const {
00630     return data->event.location();
00631 }
00632 QString OEffectiveEvent::note()const {
00633     return data->event.note();
00634 }
00635 OEvent OEffectiveEvent::event()const {
00636     return data->event;
00637 }
00638 QTime OEffectiveEvent::startTime()const {
00639     return data->start;
00640 }
00641 QTime OEffectiveEvent::endTime()const {
00642     return data->end;
00643 }
00644 QDate OEffectiveEvent::date()const {
00645     return data->date;
00646 }
00647 int OEffectiveEvent::length()const {
00648     return (data->end.hour() * 60 - data->start.hour() * 60)
00649         + QABS(data->start.minute() - data->end.minute() );
00650 }
00651 int OEffectiveEvent::size()const {
00652     return ( data->end.hour() - data->start.hour() ) * 3600
00653         + (data->end.minute() - data->start.minute() * 60
00654         + data->end.second() - data->start.second() );
00655 }
00656 QDate OEffectiveEvent::startDate()const {
00657     if ( data->dates )
00658         return data->startDate;
00659     else if ( data->event.hasRecurrence() )  // single day, since multi-day should have a d pointer
00660         return data->date;
00661     else
00662         return data->event.startDateTime().date();
00663 }
00664 QDate OEffectiveEvent::endDate()const {
00665     if ( data->dates )
00666         return data->endDate;
00667     else if ( data->event.hasRecurrence() )
00668         return data->date;
00669     else
00670         return data->event.endDateTime().date();
00671 }
00672 void OEffectiveEvent::deref() {
00673     if ( data->deref() ) {
00674         delete data;
00675         data = 0;
00676     }
00677 }
00678 void OEffectiveEvent::changeOrModify() {
00679     if ( data->count != 1 ) {
00680         data->deref();
00681         Data* d2 = new Data;
00682         d2->event = data->event;
00683         d2->date = data->date;
00684         d2->start = data->start;
00685         d2->end = data->end;
00686         d2->startDate = data->startDate;
00687         d2->endDate = data->endDate;
00688         d2->dates = data->dates;
00689         data = d2;
00690     }
00691 }
00692 bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{
00693     if ( data->date < e.date() )
00694     return TRUE;
00695     if ( data->date == e.date() )
00696     return ( startTime() < e.startTime() );
00697     else
00698     return FALSE;
00699 }
00700 bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{
00701     return (data->date <= e.date() );
00702 }
00703 bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const {
00704     return ( date() == e.date()
00705          && startTime() == e.startTime()
00706          && endTime()== e.endTime()
00707          && event() == e.event() );
00708 }
00709 bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const {
00710     return !(*this == e );
00711 }
00712 bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const {
00713     return !(*this <= e );
00714 }
00715 bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const {
00716     return !(*this < e);
00717 }
KDE Logo
This file is part of the documentation for OPIE Version 1.1.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:25:20 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001