summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/libopie.pro4
-rw-r--r--libopie/pim/odatebookaccess.cpp37
-rw-r--r--libopie/pim/odatebookaccess.h32
-rw-r--r--libopie/pim/odatebookaccessbackend.cpp156
-rw-r--r--libopie/pim/odatebookaccessbackend.h32
-rw-r--r--libopie/pim/oevent.cpp57
-rw-r--r--libopie/pim/oevent.h6
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.cpp156
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.h32
-rw-r--r--libopie2/opiepim/core/odatebookaccess.cpp37
-rw-r--r--libopie2/opiepim/core/odatebookaccess.h32
-rw-r--r--libopie2/opiepim/oevent.cpp57
-rw-r--r--libopie2/opiepim/oevent.h6
13 files changed, 580 insertions, 64 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index 2b843c1..70399ea 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -40,2 +40,4 @@ HEADERS = ofontmenu.h \
40 pim/otimezone.h \ 40 pim/otimezone.h \
41 pim/odatebookaccess.h \
42 pim/odatebookaccessbackend.h \
41 orecurrancewidget.h \ 43 orecurrancewidget.h \
@@ -77,2 +79,4 @@ SOURCES = ofontmenu.cc \
77 pim/otimezone.cpp \ 79 pim/otimezone.cpp \
80 pim/odatebookaccess.cpp \
81 pim/odatebookaccessbackend.cpp \
78 orecurrancewidget.cpp \ 82 orecurrancewidget.cpp \
diff --git a/libopie/pim/odatebookaccess.cpp b/libopie/pim/odatebookaccess.cpp
new file mode 100644
index 0000000..5f97e7c
--- a/dev/null
+++ b/libopie/pim/odatebookaccess.cpp
@@ -0,0 +1,37 @@
1#include "obackendfactory.h"
2#include "odatebookaccess.h"
3
4ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
5 : OPimAccessTemplate<OEvent>( back )
6{
7 if (!back )
8 back = OBackendFactory<ODateBookAccessBackend>::Default("datebook", QString::null );
9
10 m_backEnd = back;
11}
12ODateBookAccess::~ODateBookAccess() {
13}
14ODateBookAccess::List ODateBookAccess::rawEvents()const {
15 QArray<int> ints = m_backEnd->rawEvents();
16
17 List lis( ints, this );
18 return lis;
19}
20ODateBookAccess::List ODateBookAccess::rawRepeats()const {
21 QArray<int> ints = m_backEnd->rawRepeats();
22
23 List lis( ints, this );
24 return lis;
25}
26ODateBookAccess::List ODateBookAccess::nonRepeats()const {
27 QArray<int> ints = m_backEnd->nonRepeats();
28
29 List lis( ints, this );
30 return lis;
31}
32OEffectiveEvent::ValueList ODateBookAccess::effecticeEvents( const QDate& from, const QDate& to ) {
33 return m_backEnd->effecticeEvents( from, to );
34}
35OEffectiveEvent::ValueList ODateBookAccess::effecticeEvents( const QDateTime& start ) {
36 return m_backEnd->effecticeEvents( start );
37}
diff --git a/libopie/pim/odatebookaccess.h b/libopie/pim/odatebookaccess.h
new file mode 100644
index 0000000..3f2c728
--- a/dev/null
+++ b/libopie/pim/odatebookaccess.h
@@ -0,0 +1,32 @@
1#ifndef OPIE_DATE_BOOK_ACCESS_H
2#define OPIE_DATE_BOOK_ACCESS_H
3
4#include "odatebookaccessbackend.h"
5#include "opimaccesstemplate.h"
6
7#include "oevent.h"
8
9class ODateBookAccess : public OPimAccessTemplate<OEvent> {
10public:
11 ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random );
12 ~ODateBookAccess();
13
14 /** return all events */
15 List rawEvents()const;
16
17 /** return repeating events */
18 List rawRepeats()const;
19
20 /** return non repeating events */
21 List nonRepeats()const;
22
23 OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to );
24 OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start );
25
26private:
27 ODateBookAccessBackend* m_backEnd;
28 class Private;
29 Private* d;
30};
31
32#endif
diff --git a/libopie/pim/odatebookaccessbackend.cpp b/libopie/pim/odatebookaccessbackend.cpp
new file mode 100644
index 0000000..8fa1a68
--- a/dev/null
+++ b/libopie/pim/odatebookaccessbackend.cpp
@@ -0,0 +1,156 @@
1#include <qtl.h>
2
3#include "orecur.h"
4
5#include "odatebookaccessbackend.h"
6
7namespace {
8/* a small helper to get all NonRepeating events for a range of time */
9 void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events,
10 const QDate& from, const QDate& to ) {
11 QDateTime dtStart, dtEnd;
12
13 for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) {
14 dtStart = (*it).startDateTime();
15 dtEnd = (*it).endDateTime();
16
17 /*
18 * If in range
19 */
20 if (dtStart.date() >= from && dtEnd.date() <= to ) {
21 OEffectiveEvent eff;
22 eff.setEvent( (*it) );
23 eff.setDate( dtStart.date() );
24 eff.setStartTime( dtStart.time() );
25
26 /* if not on the same day */
27 if ( dtStart.date() != dtEnd.date() )
28 eff.setEndTime( QTime(23, 59, 0 ) );
29 else
30 eff.setEndTime( dtEnd.time() );
31
32 tmpList.append( eff );
33 }
34
35 /* we must also check for end date information... */
36 if ( dtEnd.date() != dtStart.date() && dtEnd.date() >= from ) {
37 QDateTime dt = dtStart.addDays( 1 );
38 dt.setTime( QTime(0, 0, 0 ) );
39 QDateTime dtStop;
40 if ( dtEnd > to )
41 dtStop = to;
42 else
43 dtStop = dtEnd;
44
45 while ( dt <= dtStop ) {
46 OEffectiveEvent eff;
47 eff.setEvent( (*it) );
48 eff.setDate( dt.date() );
49
50 if ( dt >= from ) {
51 eff.setStartTime( QTime(0, 0, 0 ) );
52 if ( dt.date() == dtEnd.date() )
53 eff.setEndTime( dtEnd.time() );
54 else
55 eff.setEndTime( QTime(23, 59, 0 ) );
56 tmpList.append( eff );
57 }
58 dt = dt.addDays( 1 );
59 }
60 }
61 }
62 }
63
64 void repeat( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& list,
65 const QDate& from, const QDate& to ) {
66 QDate repeat;
67 for ( OEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
68 int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() );
69 QDate itDate = from.addDays(-dur );
70 ORecur rec = (*it).recurrence();
71 if ( !rec.hasEndDate() || rec.endDate() > to ) {
72 rec.setEndDate( to );
73 rec.setHasEndDate( true );
74 }
75 while (rec.nextOcurrence(itDate, repeat ) ) {
76 if (repeat > to ) break;
77 OEffectiveEvent eff;
78 eff.setDate( repeat );
79 if ( (*it).isAllDay() ) {
80 eff.setStartTime( QTime(0, 0, 0 ) );
81 eff.setEndTime( QTime(23, 59, 59 ) );
82 }else {
83 /* we only occur by days, not hours/minutes/seconds. Hence
84 * the actual end and start times will be the same for
85 * every repeated event. For multi day events this is
86 * fixed up later if on wronge day span
87 */
88 eff.setStartTime( (*it).startDateTime().time() );
89 eff.setEndTime( (*it).endDateTime().time() );
90 }
91 if ( dur != 0 ) {
92 // multi-day repeating events
93 QDate sub_it = QMAX( repeat, from );
94 QDate startDate = repeat;
95 QDate endDate = startDate.addDays( dur );
96
97 while ( sub_it <= endDate && sub_it <= to ) {
98 OEffectiveEvent tmpEff = eff;
99 tmpEff.setEvent( (*it) );
100 if ( sub_it != startDate )
101 tmpEff.setStartTime( QTime(0, 0, 0 ) );
102 if ( sub_it != endDate )
103 tmpEff.setEndTime( QTime( 23, 59, 59 ) );
104
105 tmpEff.setDate( sub_it );
106 tmpEff.setEffectiveDates( startDate, endDate );
107 tmpList.append( tmpEff );
108
109 sub_it = sub_it.addDays( 1 );
110 }
111 itDate = endDate;
112 }else {
113 eff.setEvent( (*it) );
114 tmpList.append( eff );
115 itDate = repeat.addDays( 1 );
116 }
117 }
118 }
119 }
120}
121
122ODateBookAccessBackend::ODateBookAccessBackend()
123 : OPimAccessBackend<OEvent>()
124{
125
126}
127ODateBookAccessBackend::~ODateBookAccessBackend() {
128
129}
130OEffectiveEvent::ValueList ODateBookAccessBackend::effecticeEvents( const QDate& from,
131 const QDate& to ) {
132 OEffectiveEvent::ValueList tmpList;
133 OEvent::ValueList list = directNonRepeats();
134
135 events( tmpList, list, from, to );
136 repeat( tmpList, directRawRepeats(),from,to );
137
138 list = directRawRepeats();
139
140 qHeapSort( tmpList );
141 return tmpList;
142}
143OEffectiveEvent::ValueList ODateBookAccessBackend::effecticeEvents( const QDateTime& dt ) {
144 OEffectiveEvent::ValueList day = effecticeEvents( dt.date(), dt.date() );
145 OEffectiveEvent::ValueList::Iterator it;
146
147 OEffectiveEvent::ValueList tmpList;
148 QDateTime dtTmp;
149 for ( it = day.begin(); it != day.end(); ++it ) {
150 dtTmp = QDateTime( (*it).date(), (*it).startTime() );
151 if ( QABS(dt.secsTo(dtTmp) ) < 60 )
152 tmpList.append( (*it) );
153 }
154
155 return tmpList;
156}
diff --git a/libopie/pim/odatebookaccessbackend.h b/libopie/pim/odatebookaccessbackend.h
new file mode 100644
index 0000000..eb6e8fb
--- a/dev/null
+++ b/libopie/pim/odatebookaccessbackend.h
@@ -0,0 +1,32 @@
1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H
2#define OPIE_DATE_BOOK_ACCESS_BACKEND_H
3
4#include <qarray.h>
5
6#include "opimaccessbackend.h"
7#include "oevent.h"
8
9class ODateBookAccessBackend : public OPimAccessBackend<OEvent> {
10public:
11 typedef int UID;
12 ODateBookAccessBackend();
13 ~ODateBookAccessBackend();
14
15 virtual QArray<UID> rawEvents()const = 0;
16 virtual QArray<UID> rawRepeats()const = 0;
17 virtual QArray<UID> nonRepeats() const = 0;
18
19 /**
20 * these two methods are used if you do not implement
21 * effectiveEvents...
22 */
23 virtual OEvent::ValueList directNonRepeats() = 0;
24 virtual OEvent::ValueList directRawRepeats() = 0;
25
26 /* is implemented by default but you can reimplement it*/
27 virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to );
28 virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start );
29
30};
31
32#endif
diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp
index 71b9441..aaae3b2 100644
--- a/libopie/pim/oevent.cpp
+++ b/libopie/pim/oevent.cpp
@@ -11,33 +11,31 @@
11 11
12namespace OCalendarHelper { 12int OCalendarHelper::week( const QDate& date) {
13 static int week( const QDate& date) { 13 // Calculates the week this date is in within that
14 // Calculates the week this date is in within that 14 // month. Equals the "row" is is in in the month view
15 // month. Equals the "row" is is in in the month view 15 int week = 1;
16 int week = 1; 16 QDate tmp( date.year(), date.month(), 1 );
17 QDate tmp( date.year(), date.month(), 1 ); 17 if ( date.dayOfWeek() < tmp.dayOfWeek() )
18 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 18 ++week;
19 ++week;
20 19
21 week += ( date.day() - 1 ) / 7; 20 week += ( date.day() - 1 ) / 7;
22 21
23 return week; 22 return week;
24 } 23}
25 static int occurence( const QDate& date) { 24int OCalendarHelper::ocurrence( const QDate& date) {
26 // calculates the number of occurrances of this day of the 25 // calculates the number of occurrances of this day of the
27 // week till the given date (e.g 3rd Wednesday of the month) 26 // week till the given date (e.g 3rd Wednesday of the month)
28 return ( date.day() - 1 ) / 7 + 1; 27 return ( date.day() - 1 ) / 7 + 1;
29 } 28}
30 static int dayOfWeek( char day ) { 29int OCalendarHelper::dayOfWeek( char day ) {
31 int dayOfWeek = 1; 30 int dayOfWeek = 1;
32 char i = ORecur::MON; 31 char i = ORecur::MON;
33 while ( !( i & day ) && i <= ORecur::SUN ) { 32 while ( !( i & day ) && i <= ORecur::SUN ) {
34 i <<= 1; 33 i <<= 1;
35 ++dayOfWeek; 34 ++dayOfWeek;
36 }
37 return dayOfWeek;
38 }
39 static int monthDiff( const QDate& first, const QDate& second ) {
40 return ( second.year() - first.year() ) * 12 +
41 second.month() - first.month();
42 } 35 }
36 return dayOfWeek;
37}
38int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
39 return ( second.year() - first.year() ) * 12 +
40 second.month() - first.month();
43} 41}
@@ -132,3 +130,4 @@ void OEvent::setRecurrence( const ORecur& rec) {
132bool OEvent::hasRecurrence()const { 130bool OEvent::hasRecurrence()const {
133 return data->recur; 131 if (!data->recur ) return false;
132 return data->recur->doesRecur();
134} 133}
diff --git a/libopie/pim/oevent.h b/libopie/pim/oevent.h
index 4489be7..c718e2e 100644
--- a/libopie/pim/oevent.h
+++ b/libopie/pim/oevent.h
@@ -15,3 +15,3 @@
15 15
16namespace OCalendarHelper { 16struct OCalendarHelper {
17 /** calculate the week number of the date */ 17 /** calculate the week number of the date */
@@ -28,3 +28,3 @@ namespace OCalendarHelper {
28 28
29} 29};
30 30
@@ -141,3 +141,3 @@ class OEffectiveEvent {
141public: 141public:
142 QValueList<OEffectiveEvent> ValueList; 142 typedef QValueList<OEffectiveEvent> ValueList;
143 enum Position { MidWay, Start, End, StartEnd }; 143 enum Position { MidWay, Start, End, StartEnd };
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
new file mode 100644
index 0000000..8fa1a68
--- a/dev/null
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
@@ -0,0 +1,156 @@
1#include <qtl.h>
2
3#include "orecur.h"
4
5#include "odatebookaccessbackend.h"
6
7namespace {
8/* a small helper to get all NonRepeating events for a range of time */
9 void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events,
10 const QDate& from, const QDate& to ) {
11 QDateTime dtStart, dtEnd;
12
13 for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) {
14 dtStart = (*it).startDateTime();
15 dtEnd = (*it).endDateTime();
16
17 /*
18 * If in range
19 */
20 if (dtStart.date() >= from && dtEnd.date() <= to ) {
21 OEffectiveEvent eff;
22 eff.setEvent( (*it) );
23 eff.setDate( dtStart.date() );
24 eff.setStartTime( dtStart.time() );
25
26 /* if not on the same day */
27 if ( dtStart.date() != dtEnd.date() )
28 eff.setEndTime( QTime(23, 59, 0 ) );
29 else
30 eff.setEndTime( dtEnd.time() );
31
32 tmpList.append( eff );
33 }
34
35 /* we must also check for end date information... */
36 if ( dtEnd.date() != dtStart.date() && dtEnd.date() >= from ) {
37 QDateTime dt = dtStart.addDays( 1 );
38 dt.setTime( QTime(0, 0, 0 ) );
39 QDateTime dtStop;
40 if ( dtEnd > to )
41 dtStop = to;
42 else
43 dtStop = dtEnd;
44
45 while ( dt <= dtStop ) {
46 OEffectiveEvent eff;
47 eff.setEvent( (*it) );
48 eff.setDate( dt.date() );
49
50 if ( dt >= from ) {
51 eff.setStartTime( QTime(0, 0, 0 ) );
52 if ( dt.date() == dtEnd.date() )
53 eff.setEndTime( dtEnd.time() );
54 else
55 eff.setEndTime( QTime(23, 59, 0 ) );
56 tmpList.append( eff );
57 }
58 dt = dt.addDays( 1 );
59 }
60 }
61 }
62 }
63
64 void repeat( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& list,
65 const QDate& from, const QDate& to ) {
66 QDate repeat;
67 for ( OEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
68 int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() );
69 QDate itDate = from.addDays(-dur );
70 ORecur rec = (*it).recurrence();
71 if ( !rec.hasEndDate() || rec.endDate() > to ) {
72 rec.setEndDate( to );
73 rec.setHasEndDate( true );
74 }
75 while (rec.nextOcurrence(itDate, repeat ) ) {
76 if (repeat > to ) break;
77 OEffectiveEvent eff;
78 eff.setDate( repeat );
79 if ( (*it).isAllDay() ) {
80 eff.setStartTime( QTime(0, 0, 0 ) );
81 eff.setEndTime( QTime(23, 59, 59 ) );
82 }else {
83 /* we only occur by days, not hours/minutes/seconds. Hence
84 * the actual end and start times will be the same for
85 * every repeated event. For multi day events this is
86 * fixed up later if on wronge day span
87 */
88 eff.setStartTime( (*it).startDateTime().time() );
89 eff.setEndTime( (*it).endDateTime().time() );
90 }
91 if ( dur != 0 ) {
92 // multi-day repeating events
93 QDate sub_it = QMAX( repeat, from );
94 QDate startDate = repeat;
95 QDate endDate = startDate.addDays( dur );
96
97 while ( sub_it <= endDate && sub_it <= to ) {
98 OEffectiveEvent tmpEff = eff;
99 tmpEff.setEvent( (*it) );
100 if ( sub_it != startDate )
101 tmpEff.setStartTime( QTime(0, 0, 0 ) );
102 if ( sub_it != endDate )
103 tmpEff.setEndTime( QTime( 23, 59, 59 ) );
104
105 tmpEff.setDate( sub_it );
106 tmpEff.setEffectiveDates( startDate, endDate );
107 tmpList.append( tmpEff );
108
109 sub_it = sub_it.addDays( 1 );
110 }
111 itDate = endDate;
112 }else {
113 eff.setEvent( (*it) );
114 tmpList.append( eff );
115 itDate = repeat.addDays( 1 );
116 }
117 }
118 }
119 }
120}
121
122ODateBookAccessBackend::ODateBookAccessBackend()
123 : OPimAccessBackend<OEvent>()
124{
125
126}
127ODateBookAccessBackend::~ODateBookAccessBackend() {
128
129}
130OEffectiveEvent::ValueList ODateBookAccessBackend::effecticeEvents( const QDate& from,
131 const QDate& to ) {
132 OEffectiveEvent::ValueList tmpList;
133 OEvent::ValueList list = directNonRepeats();
134
135 events( tmpList, list, from, to );
136 repeat( tmpList, directRawRepeats(),from,to );
137
138 list = directRawRepeats();
139
140 qHeapSort( tmpList );
141 return tmpList;
142}
143OEffectiveEvent::ValueList ODateBookAccessBackend::effecticeEvents( const QDateTime& dt ) {
144 OEffectiveEvent::ValueList day = effecticeEvents( dt.date(), dt.date() );
145 OEffectiveEvent::ValueList::Iterator it;
146
147 OEffectiveEvent::ValueList tmpList;
148 QDateTime dtTmp;
149 for ( it = day.begin(); it != day.end(); ++it ) {
150 dtTmp = QDateTime( (*it).date(), (*it).startTime() );
151 if ( QABS(dt.secsTo(dtTmp) ) < 60 )
152 tmpList.append( (*it) );
153 }
154
155 return tmpList;
156}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h
new file mode 100644
index 0000000..eb6e8fb
--- a/dev/null
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.h
@@ -0,0 +1,32 @@
1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H
2#define OPIE_DATE_BOOK_ACCESS_BACKEND_H
3
4#include <qarray.h>
5
6#include "opimaccessbackend.h"
7#include "oevent.h"
8
9class ODateBookAccessBackend : public OPimAccessBackend<OEvent> {
10public:
11 typedef int UID;
12 ODateBookAccessBackend();
13 ~ODateBookAccessBackend();
14
15 virtual QArray<UID> rawEvents()const = 0;
16 virtual QArray<UID> rawRepeats()const = 0;
17 virtual QArray<UID> nonRepeats() const = 0;
18
19 /**
20 * these two methods are used if you do not implement
21 * effectiveEvents...
22 */
23 virtual OEvent::ValueList directNonRepeats() = 0;
24 virtual OEvent::ValueList directRawRepeats() = 0;
25
26 /* is implemented by default but you can reimplement it*/
27 virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to );
28 virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start );
29
30};
31
32#endif
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp
new file mode 100644
index 0000000..5f97e7c
--- a/dev/null
+++ b/libopie2/opiepim/core/odatebookaccess.cpp
@@ -0,0 +1,37 @@
1#include "obackendfactory.h"
2#include "odatebookaccess.h"
3
4ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
5 : OPimAccessTemplate<OEvent>( back )
6{
7 if (!back )
8 back = OBackendFactory<ODateBookAccessBackend>::Default("datebook", QString::null );
9
10 m_backEnd = back;
11}
12ODateBookAccess::~ODateBookAccess() {
13}
14ODateBookAccess::List ODateBookAccess::rawEvents()const {
15 QArray<int> ints = m_backEnd->rawEvents();
16
17 List lis( ints, this );
18 return lis;
19}
20ODateBookAccess::List ODateBookAccess::rawRepeats()const {
21 QArray<int> ints = m_backEnd->rawRepeats();
22
23 List lis( ints, this );
24 return lis;
25}
26ODateBookAccess::List ODateBookAccess::nonRepeats()const {
27 QArray<int> ints = m_backEnd->nonRepeats();
28
29 List lis( ints, this );
30 return lis;
31}
32OEffectiveEvent::ValueList ODateBookAccess::effecticeEvents( const QDate& from, const QDate& to ) {
33 return m_backEnd->effecticeEvents( from, to );
34}
35OEffectiveEvent::ValueList ODateBookAccess::effecticeEvents( const QDateTime& start ) {
36 return m_backEnd->effecticeEvents( start );
37}
diff --git a/libopie2/opiepim/core/odatebookaccess.h b/libopie2/opiepim/core/odatebookaccess.h
new file mode 100644
index 0000000..3f2c728
--- a/dev/null
+++ b/libopie2/opiepim/core/odatebookaccess.h
@@ -0,0 +1,32 @@
1#ifndef OPIE_DATE_BOOK_ACCESS_H
2#define OPIE_DATE_BOOK_ACCESS_H
3
4#include "odatebookaccessbackend.h"
5#include "opimaccesstemplate.h"
6
7#include "oevent.h"
8
9class ODateBookAccess : public OPimAccessTemplate<OEvent> {
10public:
11 ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random );
12 ~ODateBookAccess();
13
14 /** return all events */
15 List rawEvents()const;
16
17 /** return repeating events */
18 List rawRepeats()const;
19
20 /** return non repeating events */
21 List nonRepeats()const;
22
23 OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to );
24 OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start );
25
26private:
27 ODateBookAccessBackend* m_backEnd;
28 class Private;
29 Private* d;
30};
31
32#endif
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp
index 71b9441..aaae3b2 100644
--- a/libopie2/opiepim/oevent.cpp
+++ b/libopie2/opiepim/oevent.cpp
@@ -11,33 +11,31 @@
11 11
12namespace OCalendarHelper { 12int OCalendarHelper::week( const QDate& date) {
13 static int week( const QDate& date) { 13 // Calculates the week this date is in within that
14 // Calculates the week this date is in within that 14 // month. Equals the "row" is is in in the month view
15 // month. Equals the "row" is is in in the month view 15 int week = 1;
16 int week = 1; 16 QDate tmp( date.year(), date.month(), 1 );
17 QDate tmp( date.year(), date.month(), 1 ); 17 if ( date.dayOfWeek() < tmp.dayOfWeek() )
18 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 18 ++week;
19 ++week;
20 19
21 week += ( date.day() - 1 ) / 7; 20 week += ( date.day() - 1 ) / 7;
22 21
23 return week; 22 return week;
24 } 23}
25 static int occurence( const QDate& date) { 24int OCalendarHelper::ocurrence( const QDate& date) {
26 // calculates the number of occurrances of this day of the 25 // calculates the number of occurrances of this day of the
27 // week till the given date (e.g 3rd Wednesday of the month) 26 // week till the given date (e.g 3rd Wednesday of the month)
28 return ( date.day() - 1 ) / 7 + 1; 27 return ( date.day() - 1 ) / 7 + 1;
29 } 28}
30 static int dayOfWeek( char day ) { 29int OCalendarHelper::dayOfWeek( char day ) {
31 int dayOfWeek = 1; 30 int dayOfWeek = 1;
32 char i = ORecur::MON; 31 char i = ORecur::MON;
33 while ( !( i & day ) && i <= ORecur::SUN ) { 32 while ( !( i & day ) && i <= ORecur::SUN ) {
34 i <<= 1; 33 i <<= 1;
35 ++dayOfWeek; 34 ++dayOfWeek;
36 }
37 return dayOfWeek;
38 }
39 static int monthDiff( const QDate& first, const QDate& second ) {
40 return ( second.year() - first.year() ) * 12 +
41 second.month() - first.month();
42 } 35 }
36 return dayOfWeek;
37}
38int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
39 return ( second.year() - first.year() ) * 12 +
40 second.month() - first.month();
43} 41}
@@ -132,3 +130,4 @@ void OEvent::setRecurrence( const ORecur& rec) {
132bool OEvent::hasRecurrence()const { 130bool OEvent::hasRecurrence()const {
133 return data->recur; 131 if (!data->recur ) return false;
132 return data->recur->doesRecur();
134} 133}
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h
index 4489be7..c718e2e 100644
--- a/libopie2/opiepim/oevent.h
+++ b/libopie2/opiepim/oevent.h
@@ -15,3 +15,3 @@
15 15
16namespace OCalendarHelper { 16struct OCalendarHelper {
17 /** calculate the week number of the date */ 17 /** calculate the week number of the date */
@@ -28,3 +28,3 @@ namespace OCalendarHelper {
28 28
29} 29};
30 30
@@ -141,3 +141,3 @@ class OEffectiveEvent {
141public: 141public:
142 QValueList<OEffectiveEvent> ValueList; 142 typedef QValueList<OEffectiveEvent> ValueList;
143 enum Position { MidWay, Start, End, StartEnd }; 143 enum Position { MidWay, Start, End, StartEnd };