summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/oevent.cpp
Unidiff
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 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
1#include <qshared.h> 29#include <qshared.h>
2#include <qarray.h> 30#include <qarray.h>
3 31
4#include <qpe/palmtopuidgen.h> 32#include <qpe/palmtopuidgen.h>
5#include <qpe/categories.h> 33#include <qpe/categories.h>
6#include <qpe/stringutil.h> 34#include <qpe/stringutil.h>
7 35
8#include "orecur.h" 36#include <opie2/orecur.h>
9#include "opimresolver.h" 37#include <opie2/opimresolver.h>
10#include "opimnotifymanager.h" 38#include <opie2/opimnotifymanager.h>
11 39
12#include "oevent.h" 40#include <opie2/oevent.h>
41
42namespace Opie {
13 43
14int OCalendarHelper::week( const QDate& date) { 44int OCalendarHelper::week( const QDate& date) {
15 // Calculates the week this date is in within that 45 // Calculates the week this date is in within that
16 // month. Equals the "row" is is in in the month view 46 // month. Equals the "row" is is in in the month view
17 int week = 1; 47 int week = 1;
18 QDate tmp( date.year(), date.month(), 1 ); 48 QDate tmp( date.year(), date.month(), 1 );
19 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 49 if ( date.dayOfWeek() < tmp.dayOfWeek() )
20 ++week; 50 ++week;
21 51
22 week += ( date.day() - 1 ) / 7; 52 week += ( date.day() - 1 ) / 7;
23 53
24 return week; 54 return week;
25} 55}
26int OCalendarHelper::ocurrence( const QDate& date) { 56int OCalendarHelper::ocurrence( const QDate& date) {
27 // calculates the number of occurrances of this day of the 57 // calculates the number of occurrances of this day of the
28 // week till the given date (e.g 3rd Wednesday of the month) 58 // week till the given date (e.g 3rd Wednesday of the month)
29 return ( date.day() - 1 ) / 7 + 1; 59 return ( date.day() - 1 ) / 7 + 1;
30} 60}
31int OCalendarHelper::dayOfWeek( char day ) { 61int OCalendarHelper::dayOfWeek( char day ) {
32 int dayOfWeek = 1; 62 int dayOfWeek = 1;
33 char i = ORecur::MON; 63 char i = ORecur::MON;
34 while ( !( i & day ) && i <= ORecur::SUN ) { 64 while ( !( i & day ) && i <= ORecur::SUN ) {
35 i <<= 1; 65 i <<= 1;
36 ++dayOfWeek; 66 ++dayOfWeek;
37 } 67 }
38 return dayOfWeek; 68 return dayOfWeek;
39} 69}
40int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { 70int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
41 return ( second.year() - first.year() ) * 12 + 71 return ( second.year() - first.year() ) * 12 +
42 second.month() - first.month(); 72 second.month() - first.month();
43} 73}
44 74
45struct OEvent::Data : public QShared { 75struct OEvent::Data : public QShared {
46 Data() : QShared() { 76 Data() : QShared() {
47 child = 0; 77 child = 0;
48 recur = 0; 78 recur = 0;
49 manager = 0; 79 manager = 0;
50 isAllDay = false; 80 isAllDay = false;
51 parent = 0; 81 parent = 0;
52 } 82 }
53 ~Data() { 83 ~Data() {
54 delete manager; 84 delete manager;
55 delete recur; 85 delete recur;
56 } 86 }
57 QString description; 87 QString description;
58 QString location; 88 QString location;
59 OPimNotifyManager* manager; 89 OPimNotifyManager* manager;
60 ORecur* recur; 90 ORecur* recur;
@@ -670,48 +700,50 @@ QDate OEffectiveEvent::endDate()const {
670 return data->event.endDateTime().date(); 700 return data->event.endDateTime().date();
671} 701}
672void OEffectiveEvent::deref() { 702void OEffectiveEvent::deref() {
673 if ( data->deref() ) { 703 if ( data->deref() ) {
674 delete data; 704 delete data;
675 data = 0; 705 data = 0;
676 } 706 }
677} 707}
678void OEffectiveEvent::changeOrModify() { 708void OEffectiveEvent::changeOrModify() {
679 if ( data->count != 1 ) { 709 if ( data->count != 1 ) {
680 data->deref(); 710 data->deref();
681 Data* d2 = new Data; 711 Data* d2 = new Data;
682 d2->event = data->event; 712 d2->event = data->event;
683 d2->date = data->date; 713 d2->date = data->date;
684 d2->start = data->start; 714 d2->start = data->start;
685 d2->end = data->end; 715 d2->end = data->end;
686 d2->startDate = data->startDate; 716 d2->startDate = data->startDate;
687 d2->endDate = data->endDate; 717 d2->endDate = data->endDate;
688 d2->dates = data->dates; 718 d2->dates = data->dates;
689 data = d2; 719 data = d2;
690 } 720 }
691} 721}
692bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{ 722bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{
693 if ( data->date < e.date() ) 723 if ( data->date < e.date() )
694 return TRUE; 724 return TRUE;
695 if ( data->date == e.date() ) 725 if ( data->date == e.date() )
696 return ( startTime() < e.startTime() ); 726 return ( startTime() < e.startTime() );
697 else 727 else
698 return FALSE; 728 return FALSE;
699} 729}
700bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{ 730bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{
701 return (data->date <= e.date() ); 731 return (data->date <= e.date() );
702} 732}
703bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const { 733bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const {
704 return ( date() == e.date() 734 return ( date() == e.date()
705 && startTime() == e.startTime() 735 && startTime() == e.startTime()
706 && endTime()== e.endTime() 736 && endTime()== e.endTime()
707 && event() == e.event() ); 737 && event() == e.event() );
708} 738}
709bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const { 739bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const {
710 return !(*this == e ); 740 return !(*this == e );
711} 741}
712bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const { 742bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const {
713 return !(*this <= e ); 743 return !(*this <= e );
714} 744}
715bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const { 745bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const {
716 return !(*this < e); 746 return !(*this < e);
717} 747}
748
749}