-rw-r--r-- | libkcal/event.cpp | 20 | ||||
-rw-r--r-- | libkcal/event.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 5285559..ad66639 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp @@ -150,48 +150,68 @@ bool Event::hasEndDate() const bool Event::isMultiDay() const { bool multi = !(dtStart().date() == dtEnd().date()); return multi; } void Event::setTransparency(Event::Transparency transparency) { if (mReadOnly) return; mTransparency = transparency; updated(); } Event::Transparency Event::transparency() const { return mTransparency; } void Event::setDuration(int seconds) { setHasEndDate(false); Incidence::setDuration(seconds); } +bool Event::matchTime(QDateTime*startDT, QDateTime* endDT) +{ + if ( ! doesRecur() ) { + if ( doesFloat() ) { + if ( mDtEnd.addDays( 1 ) < *startDT) + return false; + if ( endDT && mDtStart > * endDT) + return false; + } else { + if ( mDtEnd < *startDT ) + return false; + if ( endDT && mDtStart > * endDT) + return false; + } + } else { + if ( endDT && mDtStart > * endDT) + return false; + } + return true; +} bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* startDT ) { if ( testEvent == this ) return false; if ( ! doesRecur() && !testEvent->doesRecur() ) { QDateTime te; if ( testEvent->doesFloat() ) te = testEvent->mDtEnd.addDays( 1 ); else te = testEvent->mDtEnd; QDateTime e; if ( doesFloat() ) e = mDtEnd.addDays( 1 ); else e = mDtEnd; if ( mDtStart < te && testEvent->mDtStart < e ) { if ( mDtStart < testEvent->mDtStart ) *overlapDT = testEvent->mDtStart; else *overlapDT = mDtStart; if ( startDT ) return (*overlapDT >= *startDT ); return true; } diff --git a/libkcal/event.h b/libkcal/event.h index e6055a5..2da9770 100644 --- a/libkcal/event.h +++ b/libkcal/event.h @@ -17,48 +17,49 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef EVENT_H #define EVENT_H // // Event component, representing a VEVENT object // #include "incidence.h" namespace KCal { /** This class provides an Event in the sense of RFC2445. */ class Event : public Incidence { public: enum Transparency { Opaque, Transparent }; typedef ListBase<Event> List; Event(); Event(const Event &); ~Event(); + bool matchTime(QDateTime*startDT, QDateTime* endDT); QCString type() const { return "Event"; } IncTypeID typeID() const { return eventID; } Incidence *clone(); QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; /** for setting an event's ending date/time with a QDateTime. */ void setDtEnd(const QDateTime &dtEnd); /** Return the event's ending date/time as a QDateTime. */ virtual QDateTime dtEnd() const; /** returns an event's end time as a string formatted according to the users locale settings */ QString dtEndTimeStr() const; /** returns an event's end date as a string formatted according to the users locale settings */ QString dtEndDateStr(bool shortfmt=true) const; /** returns an event's end date and time as a string formatted according to the users locale settings */ QString dtEndStr(bool shortfmt=true) const; void setHasEndDate(bool); /** Return whether the event has an end date/time. */ bool hasEndDate() const; |