-rw-r--r-- | libopie/pim/oevent.cpp | 57 |
1 files changed, 28 insertions, 29 deletions
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 | |||
@@ -1,54 +1,52 @@ | |||
1 | #include <qshared.h> | 1 | #include <qshared.h> |
2 | 2 | ||
3 | #include <qpe/palmtopuidgen.h> | 3 | #include <qpe/palmtopuidgen.h> |
4 | #include <qpe/categories.h> | 4 | #include <qpe/categories.h> |
5 | 5 | ||
6 | #include "orecur.h" | 6 | #include "orecur.h" |
7 | #include "opimresolver.h" | 7 | #include "opimresolver.h" |
8 | #include "opimnotifymanager.h" | 8 | #include "opimnotifymanager.h" |
9 | 9 | ||
10 | #include "oevent.h" | 10 | #include "oevent.h" |
11 | 11 | ||
12 | namespace OCalendarHelper { | 12 | int 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) { | 24 | int 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 ) { | 29 | int 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 | } | ||
38 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { | ||
39 | return ( second.year() - first.year() ) * 12 + | ||
40 | second.month() - first.month(); | ||
43 | } | 41 | } |
44 | 42 | ||
45 | struct OEvent::Data : public QShared { | 43 | struct OEvent::Data : public QShared { |
46 | Data() : QShared() { | 44 | Data() : QShared() { |
47 | recur = 0; | 45 | recur = 0; |
48 | manager = 0; | 46 | manager = 0; |
49 | isAllDay = false; | 47 | isAllDay = false; |
50 | } | 48 | } |
51 | ~Data() { | 49 | ~Data() { |
52 | delete manager; | 50 | delete manager; |
53 | delete recur; | 51 | delete recur; |
54 | } | 52 | } |
@@ -121,25 +119,26 @@ ORecur OEvent::recurrence()const { | |||
121 | data->recur = new ORecur; | 119 | data->recur = new ORecur; |
122 | 120 | ||
123 | return *data->recur; | 121 | return *data->recur; |
124 | } | 122 | } |
125 | void OEvent::setRecurrence( const ORecur& rec) { | 123 | void OEvent::setRecurrence( const ORecur& rec) { |
126 | changeOrModify(); | 124 | changeOrModify(); |
127 | if (data->recur ) | 125 | if (data->recur ) |
128 | (*data->recur) = rec; | 126 | (*data->recur) = rec; |
129 | else | 127 | else |
130 | data->recur = new ORecur( rec ); | 128 | data->recur = new ORecur( rec ); |
131 | } | 129 | } |
132 | bool OEvent::hasRecurrence()const { | 130 | bool OEvent::hasRecurrence()const { |
133 | return data->recur; | 131 | if (!data->recur ) return false; |
132 | return data->recur->doesRecur(); | ||
134 | } | 133 | } |
135 | QString OEvent::note()const { | 134 | QString OEvent::note()const { |
136 | return data->note; | 135 | return data->note; |
137 | } | 136 | } |
138 | void OEvent::setNote( const QString& note ) { | 137 | void OEvent::setNote( const QString& note ) { |
139 | changeOrModify(); | 138 | changeOrModify(); |
140 | data->note = note; | 139 | data->note = note; |
141 | } | 140 | } |
142 | QDateTime OEvent::createdDateTime()const { | 141 | QDateTime OEvent::createdDateTime()const { |
143 | return data->created; | 142 | return data->created; |
144 | } | 143 | } |
145 | void OEvent::setCreatedDateTime( const QDateTime& time ) { | 144 | void OEvent::setCreatedDateTime( const QDateTime& time ) { |