summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/oevent.cpp
authoralwin <alwin>2004-02-20 02:06:52 (UTC)
committer alwin <alwin>2004-02-20 02:06:52 (UTC)
commit55f4d502486e01927356908223622e435c975f7e (patch) (side-by-side diff)
tree824b5c1e8992564677c4f39473bc108a32a2cf2a /libopie2/opiepim/oevent.cpp
parent060b4fc7a3fd5c1b5f745167fe084f7486719b7e (diff)
downloadopie-55f4d502486e01927356908223622e435c975f7e.zip
opie-55f4d502486e01927356908223622e435c975f7e.tar.gz
opie-55f4d502486e01927356908223622e435c975f7e.tar.bz2
moved the opie pim stuff to libopie2 - pim. Tried to resort them, may be someone should take a look for a better file order. but now all applications can start using libopiepim2 instead of libopie1-pim-stuff.
Diffstat (limited to 'libopie2/opiepim/oevent.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/oevent.cpp40
1 files changed, 36 insertions, 4 deletions
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp
index 9b31957..de5e30b 100644
--- a/libopie2/opiepim/oevent.cpp
+++ b/libopie2/opiepim/oevent.cpp
@@ -1,60 +1,90 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#include <qshared.h>
#include <qarray.h>
#include <qpe/palmtopuidgen.h>
#include <qpe/categories.h>
#include <qpe/stringutil.h>
-#include "orecur.h"
-#include "opimresolver.h"
-#include "opimnotifymanager.h"
+#include <opie2/orecur.h>
+#include <opie2/opimresolver.h>
+#include <opie2/opimnotifymanager.h>
-#include "oevent.h"
+#include <opie2/oevent.h>
+
+namespace Opie {
int OCalendarHelper::week( const QDate& date) {
// Calculates the week this date is in within that
// month. Equals the "row" is is in in the month view
int week = 1;
QDate tmp( date.year(), date.month(), 1 );
if ( date.dayOfWeek() < tmp.dayOfWeek() )
++week;
week += ( date.day() - 1 ) / 7;
return week;
}
int OCalendarHelper::ocurrence( const QDate& date) {
// calculates the number of occurrances of this day of the
// week till the given date (e.g 3rd Wednesday of the month)
return ( date.day() - 1 ) / 7 + 1;
}
int OCalendarHelper::dayOfWeek( char day ) {
int dayOfWeek = 1;
char i = ORecur::MON;
while ( !( i & day ) && i <= ORecur::SUN ) {
i <<= 1;
++dayOfWeek;
}
return dayOfWeek;
}
int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
return ( second.year() - first.year() ) * 12 +
second.month() - first.month();
}
struct OEvent::Data : public QShared {
Data() : QShared() {
child = 0;
recur = 0;
manager = 0;
isAllDay = false;
parent = 0;
}
~Data() {
delete manager;
delete recur;
}
QString description;
QString location;
OPimNotifyManager* manager;
ORecur* recur;
@@ -670,48 +700,50 @@ QDate OEffectiveEvent::endDate()const {
return data->event.endDateTime().date();
}
void OEffectiveEvent::deref() {
if ( data->deref() ) {
delete data;
data = 0;
}
}
void OEffectiveEvent::changeOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
d2->event = data->event;
d2->date = data->date;
d2->start = data->start;
d2->end = data->end;
d2->startDate = data->startDate;
d2->endDate = data->endDate;
d2->dates = data->dates;
data = d2;
}
}
bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{
if ( data->date < e.date() )
return TRUE;
if ( data->date == e.date() )
return ( startTime() < e.startTime() );
else
return FALSE;
}
bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{
return (data->date <= e.date() );
}
bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const {
return ( date() == e.date()
&& startTime() == e.startTime()
&& endTime()== e.endTime()
&& event() == e.event() );
}
bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const {
return !(*this == e );
}
bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const {
return !(*this <= e );
}
bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const {
return !(*this < e);
}
+
+}