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,36 +1,66 @@
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;
@@ -694,24 +724,26 @@ bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{
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}