author | zecke <zecke> | 2003-02-21 20:08:44 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-21 20:08:44 (UTC) |
commit | e09381c4b3d482c6b553a61c5fb0502a089dcc5f (patch) (unidiff) | |
tree | c336a21f6b00e09989de5309ca8bb933c9494b09 /libopie2/opiepim | |
parent | 3b37e71ad7dd41555763d15a16c691b503780de8 (diff) | |
download | opie-e09381c4b3d482c6b553a61c5fb0502a089dcc5f.zip opie-e09381c4b3d482c6b553a61c5fb0502a089dcc5f.tar.gz opie-e09381c4b3d482c6b553a61c5fb0502a089dcc5f.tar.bz2 |
-Fix hasRecurrence()
-Add the Access(Backend) of DateBook
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend.cpp | 156 | ||||
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend.h | 32 | ||||
-rw-r--r-- | libopie2/opiepim/core/odatebookaccess.cpp | 37 | ||||
-rw-r--r-- | libopie2/opiepim/core/odatebookaccess.h | 32 | ||||
-rw-r--r-- | libopie2/opiepim/oevent.cpp | 57 | ||||
-rw-r--r-- | libopie2/opiepim/oevent.h | 6 |
6 files changed, 288 insertions, 32 deletions
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 | |||
7 | namespace { | ||
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 | |||
122 | ODateBookAccessBackend::ODateBookAccessBackend() | ||
123 | : OPimAccessBackend<OEvent>() | ||
124 | { | ||
125 | |||
126 | } | ||
127 | ODateBookAccessBackend::~ODateBookAccessBackend() { | ||
128 | |||
129 | } | ||
130 | OEffectiveEvent::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 | } | ||
143 | OEffectiveEvent::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 | |||
9 | class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { | ||
10 | public: | ||
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 | |||
4 | ODateBookAccess::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 | } | ||
12 | ODateBookAccess::~ODateBookAccess() { | ||
13 | } | ||
14 | ODateBookAccess::List ODateBookAccess::rawEvents()const { | ||
15 | QArray<int> ints = m_backEnd->rawEvents(); | ||
16 | |||
17 | List lis( ints, this ); | ||
18 | return lis; | ||
19 | } | ||
20 | ODateBookAccess::List ODateBookAccess::rawRepeats()const { | ||
21 | QArray<int> ints = m_backEnd->rawRepeats(); | ||
22 | |||
23 | List lis( ints, this ); | ||
24 | return lis; | ||
25 | } | ||
26 | ODateBookAccess::List ODateBookAccess::nonRepeats()const { | ||
27 | QArray<int> ints = m_backEnd->nonRepeats(); | ||
28 | |||
29 | List lis( ints, this ); | ||
30 | return lis; | ||
31 | } | ||
32 | OEffectiveEvent::ValueList ODateBookAccess::effecticeEvents( const QDate& from, const QDate& to ) { | ||
33 | return m_backEnd->effecticeEvents( from, to ); | ||
34 | } | ||
35 | OEffectiveEvent::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 | |||
9 | class ODateBookAccess : public OPimAccessTemplate<OEvent> { | ||
10 | public: | ||
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 | |||
26 | private: | ||
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 | |||
@@ -1,427 +1,426 @@ | |||
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 | } |
55 | QString description; | 53 | QString description; |
56 | QString location; | 54 | QString location; |
57 | OPimNotifyManager* manager; | 55 | OPimNotifyManager* manager; |
58 | ORecur* recur; | 56 | ORecur* recur; |
59 | QString note; | 57 | QString note; |
60 | QDateTime created; | 58 | QDateTime created; |
61 | QDateTime start; | 59 | QDateTime start; |
62 | QDateTime end; | 60 | QDateTime end; |
63 | bool isAllDay : 1; | 61 | bool isAllDay : 1; |
64 | QString timezone; | 62 | QString timezone; |
65 | }; | 63 | }; |
66 | 64 | ||
67 | OEvent::OEvent( int uid ) | 65 | OEvent::OEvent( int uid ) |
68 | : OPimRecord( uid ) { | 66 | : OPimRecord( uid ) { |
69 | data = new Data; | 67 | data = new Data; |
70 | } | 68 | } |
71 | OEvent::OEvent( const OEvent& ev) | 69 | OEvent::OEvent( const OEvent& ev) |
72 | : OPimRecord( ev ), data( ev.data ) | 70 | : OPimRecord( ev ), data( ev.data ) |
73 | { | 71 | { |
74 | data->ref(); | 72 | data->ref(); |
75 | } | 73 | } |
76 | OEvent::~OEvent() { | 74 | OEvent::~OEvent() { |
77 | if ( data->deref() ) { | 75 | if ( data->deref() ) { |
78 | delete data; | 76 | delete data; |
79 | data = 0; | 77 | data = 0; |
80 | } | 78 | } |
81 | } | 79 | } |
82 | OEvent& OEvent::operator=( const OEvent& ev) { | 80 | OEvent& OEvent::operator=( const OEvent& ev) { |
83 | if ( *this == ev ) return *this; | 81 | if ( *this == ev ) return *this; |
84 | 82 | ||
85 | OPimRecord::operator=( ev ); | 83 | OPimRecord::operator=( ev ); |
86 | ev.data->ref(); | 84 | ev.data->ref(); |
87 | deref(); | 85 | deref(); |
88 | data = ev.data; | 86 | data = ev.data; |
89 | 87 | ||
90 | 88 | ||
91 | return *this; | 89 | return *this; |
92 | } | 90 | } |
93 | QString OEvent::description()const { | 91 | QString OEvent::description()const { |
94 | return data->description; | 92 | return data->description; |
95 | } | 93 | } |
96 | void OEvent::setDescription( const QString& description ) { | 94 | void OEvent::setDescription( const QString& description ) { |
97 | changeOrModify(); | 95 | changeOrModify(); |
98 | data->description = description; | 96 | data->description = description; |
99 | } | 97 | } |
100 | void OEvent::setLocation( const QString& loc ) { | 98 | void OEvent::setLocation( const QString& loc ) { |
101 | changeOrModify(); | 99 | changeOrModify(); |
102 | data->location = loc; | 100 | data->location = loc; |
103 | } | 101 | } |
104 | QString OEvent::location()const { | 102 | QString OEvent::location()const { |
105 | return data->location; | 103 | return data->location; |
106 | } | 104 | } |
107 | OPimNotifyManager &OEvent::notifiers() { | 105 | OPimNotifyManager &OEvent::notifiers() { |
108 | // I hope we can skip the changeOrModify here | 106 | // I hope we can skip the changeOrModify here |
109 | // the notifier should take care of it | 107 | // the notifier should take care of it |
110 | // and OPimNotify is shared too | 108 | // and OPimNotify is shared too |
111 | if (!data->manager ) | 109 | if (!data->manager ) |
112 | data->manager = new OPimNotifyManager; | 110 | data->manager = new OPimNotifyManager; |
113 | 111 | ||
114 | return *data->manager; | 112 | return *data->manager; |
115 | } | 113 | } |
116 | bool OEvent::hasNotifiers()const { | 114 | bool OEvent::hasNotifiers()const { |
117 | return ( data->manager); | 115 | return ( data->manager); |
118 | } | 116 | } |
119 | ORecur OEvent::recurrence()const { | 117 | ORecur OEvent::recurrence()const { |
120 | if (!data->recur) | 118 | if (!data->recur) |
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 ) { |
146 | changeOrModify(); | 145 | changeOrModify(); |
147 | data->created = time; | 146 | data->created = time; |
148 | } | 147 | } |
149 | QDateTime OEvent::startDateTime()const { | 148 | QDateTime OEvent::startDateTime()const { |
150 | if ( data->isAllDay ) | 149 | if ( data->isAllDay ) |
151 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); | 150 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); |
152 | return data->start; | 151 | return data->start; |
153 | } | 152 | } |
154 | QDateTime OEvent::startDateTimeInZone()const { | 153 | QDateTime OEvent::startDateTimeInZone()const { |
155 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 154 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
156 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); | 155 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); |
157 | 156 | ||
158 | OTimeZone zone(data->timezone ); | 157 | OTimeZone zone(data->timezone ); |
159 | return zone.toDateTime( data->start, OTimeZone::current() ); | 158 | return zone.toDateTime( data->start, OTimeZone::current() ); |
160 | } | 159 | } |
161 | void OEvent::setStartDateTime( const QDateTime& dt ) { | 160 | void OEvent::setStartDateTime( const QDateTime& dt ) { |
162 | changeOrModify(); | 161 | changeOrModify(); |
163 | data->start = dt; | 162 | data->start = dt; |
164 | } | 163 | } |
165 | QDateTime OEvent::endDateTime()const { | 164 | QDateTime OEvent::endDateTime()const { |
166 | /* | 165 | /* |
167 | * if all Day event the end time needs | 166 | * if all Day event the end time needs |
168 | * to be on the same day as the start | 167 | * to be on the same day as the start |
169 | */ | 168 | */ |
170 | if ( data->isAllDay ) | 169 | if ( data->isAllDay ) |
171 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); | 170 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); |
172 | return data->end; | 171 | return data->end; |
173 | } | 172 | } |
174 | QDateTime OEvent::endDateTimeInZone()const { | 173 | QDateTime OEvent::endDateTimeInZone()const { |
175 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 174 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
176 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); | 175 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); |
177 | 176 | ||
178 | OTimeZone zone(data->timezone ); | 177 | OTimeZone zone(data->timezone ); |
179 | return zone.toDateTime( data->end, OTimeZone::current() ); | 178 | return zone.toDateTime( data->end, OTimeZone::current() ); |
180 | } | 179 | } |
181 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 180 | void OEvent::setEndDateTime( const QDateTime& dt ) { |
182 | changeOrModify(); | 181 | changeOrModify(); |
183 | data->end = dt; | 182 | data->end = dt; |
184 | } | 183 | } |
185 | bool OEvent::isMultipleDay()const { | 184 | bool OEvent::isMultipleDay()const { |
186 | return data->end.date().day() - data->start.date().day(); | 185 | return data->end.date().day() - data->start.date().day(); |
187 | } | 186 | } |
188 | bool OEvent::isAllDay()const { | 187 | bool OEvent::isAllDay()const { |
189 | return data->isAllDay; | 188 | return data->isAllDay; |
190 | } | 189 | } |
191 | void OEvent::setTimeZone( const QString& tz ) { | 190 | void OEvent::setTimeZone( const QString& tz ) { |
192 | changeOrModify(); | 191 | changeOrModify(); |
193 | data->timezone = tz; | 192 | data->timezone = tz; |
194 | } | 193 | } |
195 | QString OEvent::timeZone()const { | 194 | QString OEvent::timeZone()const { |
196 | return data->timezone; | 195 | return data->timezone; |
197 | } | 196 | } |
198 | bool OEvent::match( const QRegExp& )const { | 197 | bool OEvent::match( const QRegExp& )const { |
199 | // FIXME | 198 | // FIXME |
200 | return false; | 199 | return false; |
201 | } | 200 | } |
202 | QString OEvent::toRichText()const { | 201 | QString OEvent::toRichText()const { |
203 | // FIXME | 202 | // FIXME |
204 | return "OEvent test"; | 203 | return "OEvent test"; |
205 | } | 204 | } |
206 | QString OEvent::toShortText()const { | 205 | QString OEvent::toShortText()const { |
207 | return "OEvent shotText"; | 206 | return "OEvent shotText"; |
208 | } | 207 | } |
209 | QString OEvent::type()const { | 208 | QString OEvent::type()const { |
210 | return QString::fromLatin1("OEvent"); | 209 | return QString::fromLatin1("OEvent"); |
211 | } | 210 | } |
212 | QString OEvent::recordField( int /*id */ )const { | 211 | QString OEvent::recordField( int /*id */ )const { |
213 | return QString::null; | 212 | return QString::null; |
214 | } | 213 | } |
215 | int OEvent::rtti() { | 214 | int OEvent::rtti() { |
216 | return OPimResolver::DateBook; | 215 | return OPimResolver::DateBook; |
217 | } | 216 | } |
218 | bool OEvent::loadFromStream( QDataStream& ) { | 217 | bool OEvent::loadFromStream( QDataStream& ) { |
219 | return true; | 218 | return true; |
220 | } | 219 | } |
221 | bool OEvent::saveToStream( QDataStream& )const { | 220 | bool OEvent::saveToStream( QDataStream& )const { |
222 | return true; | 221 | return true; |
223 | } | 222 | } |
224 | void OEvent::changeOrModify() { | 223 | void OEvent::changeOrModify() { |
225 | if ( data->count != 1 ) { | 224 | if ( data->count != 1 ) { |
226 | data->deref(); | 225 | data->deref(); |
227 | Data* d2 = new Data; | 226 | Data* d2 = new Data; |
228 | d2->description = data->description; | 227 | d2->description = data->description; |
229 | d2->location = data->location; | 228 | d2->location = data->location; |
230 | d2->manager = data->manager; | 229 | d2->manager = data->manager; |
231 | d2->recur = data->recur; | 230 | d2->recur = data->recur; |
232 | d2->note = data->note; | 231 | d2->note = data->note; |
233 | d2->created = data->created; | 232 | d2->created = data->created; |
234 | d2->start = data->start; | 233 | d2->start = data->start; |
235 | d2->end = data->end; | 234 | d2->end = data->end; |
236 | d2->isAllDay = data->isAllDay; | 235 | d2->isAllDay = data->isAllDay; |
237 | d2->timezone = data->timezone; | 236 | d2->timezone = data->timezone; |
238 | 237 | ||
239 | data = d2; | 238 | data = d2; |
240 | } | 239 | } |
241 | } | 240 | } |
242 | void OEvent::deref() { | 241 | void OEvent::deref() { |
243 | if ( data->deref() ) { | 242 | if ( data->deref() ) { |
244 | delete data; | 243 | delete data; |
245 | data = 0; | 244 | data = 0; |
246 | } | 245 | } |
247 | } | 246 | } |
248 | // FIXME | 247 | // FIXME |
249 | QMap<int, QString> OEvent::toMap()const { | 248 | QMap<int, QString> OEvent::toMap()const { |
250 | return QMap<int, QString>(); | 249 | return QMap<int, QString>(); |
251 | } | 250 | } |
252 | QMap<QString, QString> OEvent::toExtraMap()const { | 251 | QMap<QString, QString> OEvent::toExtraMap()const { |
253 | return QMap<QString, QString>(); | 252 | return QMap<QString, QString>(); |
254 | } | 253 | } |
255 | 254 | ||
256 | 255 | ||
257 | struct OEffectiveEvent::Data : public QShared { | 256 | struct OEffectiveEvent::Data : public QShared { |
258 | Data() : QShared() { | 257 | Data() : QShared() { |
259 | } | 258 | } |
260 | OEvent event; | 259 | OEvent event; |
261 | QDate date; | 260 | QDate date; |
262 | QTime start, end; | 261 | QTime start, end; |
263 | QDate startDate, endDate; | 262 | QDate startDate, endDate; |
264 | bool dates : 1; | 263 | bool dates : 1; |
265 | }; | 264 | }; |
266 | 265 | ||
267 | OEffectiveEvent::OEffectiveEvent() { | 266 | OEffectiveEvent::OEffectiveEvent() { |
268 | data = new Data; | 267 | data = new Data; |
269 | data->date = QDate::currentDate(); | 268 | data->date = QDate::currentDate(); |
270 | data->start = data->end = QTime::currentTime(); | 269 | data->start = data->end = QTime::currentTime(); |
271 | data->dates = false; | 270 | data->dates = false; |
272 | } | 271 | } |
273 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, | 272 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, |
274 | Position pos ) { | 273 | Position pos ) { |
275 | data = new Data; | 274 | data = new Data; |
276 | data->event = ev; | 275 | data->event = ev; |
277 | data->date = startDate; | 276 | data->date = startDate; |
278 | if ( pos & Start ) | 277 | if ( pos & Start ) |
279 | data->start = ev.startDateTime().time(); | 278 | data->start = ev.startDateTime().time(); |
280 | else | 279 | else |
281 | data->start = QTime( 0, 0, 0 ); | 280 | data->start = QTime( 0, 0, 0 ); |
282 | 281 | ||
283 | if ( pos & End ) | 282 | if ( pos & End ) |
284 | data->end = ev.endDateTime().time(); | 283 | data->end = ev.endDateTime().time(); |
285 | else | 284 | else |
286 | data->end = QTime( 23, 59, 59 ); | 285 | data->end = QTime( 23, 59, 59 ); |
287 | 286 | ||
288 | data->dates = false; | 287 | data->dates = false; |
289 | } | 288 | } |
290 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { | 289 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { |
291 | data = ev.data; | 290 | data = ev.data; |
292 | data->ref(); | 291 | data->ref(); |
293 | } | 292 | } |
294 | OEffectiveEvent::~OEffectiveEvent() { | 293 | OEffectiveEvent::~OEffectiveEvent() { |
295 | if ( data->deref() ) { | 294 | if ( data->deref() ) { |
296 | delete data; | 295 | delete data; |
297 | data = 0; | 296 | data = 0; |
298 | } | 297 | } |
299 | } | 298 | } |
300 | OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { | 299 | OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { |
301 | if ( *this == ev ) return *this; | 300 | if ( *this == ev ) return *this; |
302 | 301 | ||
303 | ev.data->ref(); | 302 | ev.data->ref(); |
304 | deref(); | 303 | deref(); |
305 | data = ev.data; | 304 | data = ev.data; |
306 | 305 | ||
307 | return *this; | 306 | return *this; |
308 | } | 307 | } |
309 | 308 | ||
310 | void OEffectiveEvent::setStartTime( const QTime& ti) { | 309 | void OEffectiveEvent::setStartTime( const QTime& ti) { |
311 | changeOrModify(); | 310 | changeOrModify(); |
312 | data->start = ti; | 311 | data->start = ti; |
313 | } | 312 | } |
314 | void OEffectiveEvent::setEndTime( const QTime& en) { | 313 | void OEffectiveEvent::setEndTime( const QTime& en) { |
315 | changeOrModify(); | 314 | changeOrModify(); |
316 | data->end = en; | 315 | data->end = en; |
317 | } | 316 | } |
318 | void OEffectiveEvent::setEvent( const OEvent& ev) { | 317 | void OEffectiveEvent::setEvent( const OEvent& ev) { |
319 | changeOrModify(); | 318 | changeOrModify(); |
320 | data->event = ev; | 319 | data->event = ev; |
321 | } | 320 | } |
322 | void OEffectiveEvent::setDate( const QDate& da) { | 321 | void OEffectiveEvent::setDate( const QDate& da) { |
323 | changeOrModify(); | 322 | changeOrModify(); |
324 | data->date = da; | 323 | data->date = da; |
325 | } | 324 | } |
326 | void OEffectiveEvent::setEffectiveDates( const QDate& from, | 325 | void OEffectiveEvent::setEffectiveDates( const QDate& from, |
327 | const QDate& to ) { | 326 | const QDate& to ) { |
328 | if (!from.isValid() ) { | 327 | if (!from.isValid() ) { |
329 | data->dates = false; | 328 | data->dates = false; |
330 | return; | 329 | return; |
331 | } | 330 | } |
332 | 331 | ||
333 | data->startDate = from; | 332 | data->startDate = from; |
334 | data->endDate = to; | 333 | data->endDate = to; |
335 | } | 334 | } |
336 | QString OEffectiveEvent::description()const { | 335 | QString OEffectiveEvent::description()const { |
337 | return data->event.description(); | 336 | return data->event.description(); |
338 | } | 337 | } |
339 | QString OEffectiveEvent::location()const { | 338 | QString OEffectiveEvent::location()const { |
340 | return data->event.location(); | 339 | return data->event.location(); |
341 | } | 340 | } |
342 | QString OEffectiveEvent::note()const { | 341 | QString OEffectiveEvent::note()const { |
343 | return data->event.note(); | 342 | return data->event.note(); |
344 | } | 343 | } |
345 | OEvent OEffectiveEvent::event()const { | 344 | OEvent OEffectiveEvent::event()const { |
346 | return data->event; | 345 | return data->event; |
347 | } | 346 | } |
348 | QTime OEffectiveEvent::startTime()const { | 347 | QTime OEffectiveEvent::startTime()const { |
349 | return data->start; | 348 | return data->start; |
350 | } | 349 | } |
351 | QTime OEffectiveEvent::endTime()const { | 350 | QTime OEffectiveEvent::endTime()const { |
352 | return data->end; | 351 | return data->end; |
353 | } | 352 | } |
354 | QDate OEffectiveEvent::date()const { | 353 | QDate OEffectiveEvent::date()const { |
355 | return data->date; | 354 | return data->date; |
356 | } | 355 | } |
357 | int OEffectiveEvent::length()const { | 356 | int OEffectiveEvent::length()const { |
358 | return (data->end.hour() * 60 - data->start.hour() * 60) | 357 | return (data->end.hour() * 60 - data->start.hour() * 60) |
359 | + QABS(data->start.minute() - data->end.minute() ); | 358 | + QABS(data->start.minute() - data->end.minute() ); |
360 | } | 359 | } |
361 | int OEffectiveEvent::size()const { | 360 | int OEffectiveEvent::size()const { |
362 | return ( data->end.hour() - data->start.hour() ) * 3600 | 361 | return ( data->end.hour() - data->start.hour() ) * 3600 |
363 | + (data->end.minute() - data->start.minute() * 60 | 362 | + (data->end.minute() - data->start.minute() * 60 |
364 | + data->end.second() - data->start.second() ); | 363 | + data->end.second() - data->start.second() ); |
365 | } | 364 | } |
366 | QDate OEffectiveEvent::startDate()const { | 365 | QDate OEffectiveEvent::startDate()const { |
367 | if ( data->dates ) | 366 | if ( data->dates ) |
368 | return data->startDate; | 367 | return data->startDate; |
369 | else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer | 368 | else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer |
370 | return data->date; | 369 | return data->date; |
371 | else | 370 | else |
372 | return data->event.startDateTime().date(); | 371 | return data->event.startDateTime().date(); |
373 | } | 372 | } |
374 | QDate OEffectiveEvent::endDate()const { | 373 | QDate OEffectiveEvent::endDate()const { |
375 | if ( data->dates ) | 374 | if ( data->dates ) |
376 | return data->endDate; | 375 | return data->endDate; |
377 | else if ( data->event.hasRecurrence() ) | 376 | else if ( data->event.hasRecurrence() ) |
378 | return data->date; | 377 | return data->date; |
379 | else | 378 | else |
380 | return data->event.endDateTime().date(); | 379 | return data->event.endDateTime().date(); |
381 | } | 380 | } |
382 | void OEffectiveEvent::deref() { | 381 | void OEffectiveEvent::deref() { |
383 | if ( data->deref() ) { | 382 | if ( data->deref() ) { |
384 | delete data; | 383 | delete data; |
385 | data = 0; | 384 | data = 0; |
386 | } | 385 | } |
387 | } | 386 | } |
388 | void OEffectiveEvent::changeOrModify() { | 387 | void OEffectiveEvent::changeOrModify() { |
389 | if ( data->count != 1 ) { | 388 | if ( data->count != 1 ) { |
390 | data->deref(); | 389 | data->deref(); |
391 | Data* d2 = new Data; | 390 | Data* d2 = new Data; |
392 | d2->event = data->event; | 391 | d2->event = data->event; |
393 | d2->date = data->date; | 392 | d2->date = data->date; |
394 | d2->start = data->start; | 393 | d2->start = data->start; |
395 | d2->end = data->end; | 394 | d2->end = data->end; |
396 | d2->startDate = data->startDate; | 395 | d2->startDate = data->startDate; |
397 | d2->endDate = data->endDate; | 396 | d2->endDate = data->endDate; |
398 | d2->dates = data->dates; | 397 | d2->dates = data->dates; |
399 | data = d2; | 398 | data = d2; |
400 | } | 399 | } |
401 | } | 400 | } |
402 | bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{ | 401 | bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{ |
403 | if ( data->date < e.date() ) | 402 | if ( data->date < e.date() ) |
404 | return TRUE; | 403 | return TRUE; |
405 | if ( data->date == e.date() ) | 404 | if ( data->date == e.date() ) |
406 | return ( startTime() < e.startTime() ); | 405 | return ( startTime() < e.startTime() ); |
407 | else | 406 | else |
408 | return FALSE; | 407 | return FALSE; |
409 | } | 408 | } |
410 | bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{ | 409 | bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{ |
411 | return (data->date <= e.date() ); | 410 | return (data->date <= e.date() ); |
412 | } | 411 | } |
413 | bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const { | 412 | bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const { |
414 | return ( date() == e.date() | 413 | return ( date() == e.date() |
415 | && startTime() == e.startTime() | 414 | && startTime() == e.startTime() |
416 | && endTime()== e.endTime() | 415 | && endTime()== e.endTime() |
417 | && event() == e.event() ); | 416 | && event() == e.event() ); |
418 | } | 417 | } |
419 | bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const { | 418 | bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const { |
420 | return !(*this == e ); | 419 | return !(*this == e ); |
421 | } | 420 | } |
422 | bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const { | 421 | bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const { |
423 | return !(*this <= e ); | 422 | return !(*this <= e ); |
424 | } | 423 | } |
425 | bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const { | 424 | bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const { |
426 | return !(*this < e); | 425 | return !(*this < e); |
427 | } | 426 | } |
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 | |||
@@ -1,198 +1,198 @@ | |||
1 | // CONTAINS GPLed code of TT | 1 | // CONTAINS GPLed code of TT |
2 | 2 | ||
3 | #ifndef OPIE_PIM_EVENT_H | 3 | #ifndef OPIE_PIM_EVENT_H |
4 | #define OPIE_PIM_EVENT_H | 4 | #define OPIE_PIM_EVENT_H |
5 | 5 | ||
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | #include <qvaluelist.h> | 8 | #include <qvaluelist.h> |
9 | 9 | ||
10 | #include <qpe/recordfields.h> | 10 | #include <qpe/recordfields.h> |
11 | #include <qpe/palmtopuidgen.h> | 11 | #include <qpe/palmtopuidgen.h> |
12 | 12 | ||
13 | #include "otimezone.h" | 13 | #include "otimezone.h" |
14 | #include "opimrecord.h" | 14 | #include "opimrecord.h" |
15 | 15 | ||
16 | namespace OCalendarHelper { | 16 | struct OCalendarHelper { |
17 | /** calculate the week number of the date */ | 17 | /** calculate the week number of the date */ |
18 | static int week( const QDate& ); | 18 | static int week( const QDate& ); |
19 | /** calculate the occurence of week days since the start of the month */ | 19 | /** calculate the occurence of week days since the start of the month */ |
20 | static int ocurrence( const QDate& ); | 20 | static int ocurrence( const QDate& ); |
21 | 21 | ||
22 | // returns the dayOfWeek for the *first* day it finds (ignores | 22 | // returns the dayOfWeek for the *first* day it finds (ignores |
23 | // any further days!). Returns 1 (Monday) if there isn't any day found | 23 | // any further days!). Returns 1 (Monday) if there isn't any day found |
24 | static int dayOfWeek( char day ); | 24 | static int dayOfWeek( char day ); |
25 | 25 | ||
26 | /** returns the diff of month */ | 26 | /** returns the diff of month */ |
27 | static int monthDiff( const QDate& first, const QDate& second ); | 27 | static int monthDiff( const QDate& first, const QDate& second ); |
28 | 28 | ||
29 | } | 29 | }; |
30 | 30 | ||
31 | class OPimNotifyManager; | 31 | class OPimNotifyManager; |
32 | class ORecur; | 32 | class ORecur; |
33 | class OEvent : public OPimRecord { | 33 | class OEvent : public OPimRecord { |
34 | public: | 34 | public: |
35 | typedef QValueList<OEvent> ValueList; | 35 | typedef QValueList<OEvent> ValueList; |
36 | enum RecordFields { | 36 | enum RecordFields { |
37 | Uid = Qtopia::UID_ID, | 37 | Uid = Qtopia::UID_ID, |
38 | Category = Qtopia::CATEGORY_ID, | 38 | Category = Qtopia::CATEGORY_ID, |
39 | Description, | 39 | Description, |
40 | Location, | 40 | Location, |
41 | Alarm, | 41 | Alarm, |
42 | Reminder, | 42 | Reminder, |
43 | Recurrence, | 43 | Recurrence, |
44 | Note, | 44 | Note, |
45 | Created, | 45 | Created, |
46 | StartDate, | 46 | StartDate, |
47 | EndDate, | 47 | EndDate, |
48 | AllDay, | 48 | AllDay, |
49 | TimeZone | 49 | TimeZone |
50 | }; | 50 | }; |
51 | 51 | ||
52 | OEvent(int uid = 0); | 52 | OEvent(int uid = 0); |
53 | OEvent( const OEvent& ); | 53 | OEvent( const OEvent& ); |
54 | ~OEvent(); | 54 | ~OEvent(); |
55 | OEvent &operator=( const OEvent& ); | 55 | OEvent &operator=( const OEvent& ); |
56 | 56 | ||
57 | QString description()const; | 57 | QString description()const; |
58 | void setDescription( const QString& description ); | 58 | void setDescription( const QString& description ); |
59 | 59 | ||
60 | QString location()const; | 60 | QString location()const; |
61 | void setLocation( const QString& loc ); | 61 | void setLocation( const QString& loc ); |
62 | 62 | ||
63 | bool hasNotifiers()const; | 63 | bool hasNotifiers()const; |
64 | OPimNotifyManager ¬ifiers(); | 64 | OPimNotifyManager ¬ifiers(); |
65 | 65 | ||
66 | ORecur recurrence()const; | 66 | ORecur recurrence()const; |
67 | void setRecurrence( const ORecur& ); | 67 | void setRecurrence( const ORecur& ); |
68 | bool hasRecurrence()const; | 68 | bool hasRecurrence()const; |
69 | 69 | ||
70 | QString note()const; | 70 | QString note()const; |
71 | void setNote( const QString& note ); | 71 | void setNote( const QString& note ); |
72 | 72 | ||
73 | 73 | ||
74 | QDateTime createdDateTime()const; | 74 | QDateTime createdDateTime()const; |
75 | void setCreatedDateTime( const QDateTime& dt); | 75 | void setCreatedDateTime( const QDateTime& dt); |
76 | 76 | ||
77 | /** set the date to dt. dt is the QDateTime in localtime */ | 77 | /** set the date to dt. dt is the QDateTime in localtime */ |
78 | void setStartDateTime( const QDateTime& ); | 78 | void setStartDateTime( const QDateTime& ); |
79 | /** returns the datetime in the local timeZone */ | 79 | /** returns the datetime in the local timeZone */ |
80 | QDateTime startDateTime()const; | 80 | QDateTime startDateTime()const; |
81 | 81 | ||
82 | /** returns the start datetime in the current zone */ | 82 | /** returns the start datetime in the current zone */ |
83 | QDateTime startDateTimeInZone()const; | 83 | QDateTime startDateTimeInZone()const; |
84 | 84 | ||
85 | /** in current timezone */ | 85 | /** in current timezone */ |
86 | void setEndDateTime( const QDateTime& ); | 86 | void setEndDateTime( const QDateTime& ); |
87 | /** in current timezone */ | 87 | /** in current timezone */ |
88 | QDateTime endDateTime()const; | 88 | QDateTime endDateTime()const; |
89 | QDateTime endDateTimeInZone()const; | 89 | QDateTime endDateTimeInZone()const; |
90 | 90 | ||
91 | bool isMultipleDay()const; | 91 | bool isMultipleDay()const; |
92 | bool isAllDay()const; | 92 | bool isAllDay()const; |
93 | void setAllDay( bool isAllDay ); | 93 | void setAllDay( bool isAllDay ); |
94 | 94 | ||
95 | /* pin this event to a timezone! FIXME */ | 95 | /* pin this event to a timezone! FIXME */ |
96 | void setTimeZone( const QString& timeZone ); | 96 | void setTimeZone( const QString& timeZone ); |
97 | QString timeZone()const; | 97 | QString timeZone()const; |
98 | 98 | ||
99 | 99 | ||
100 | bool match( const QRegExp& )const; | 100 | bool match( const QRegExp& )const; |
101 | 101 | ||
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
105 | /* needed reimp */ | 105 | /* needed reimp */ |
106 | QString toRichText()const; | 106 | QString toRichText()const; |
107 | QString toShortText()const; | 107 | QString toShortText()const; |
108 | QString type()const; | 108 | QString type()const; |
109 | 109 | ||
110 | QMap<int, QString> toMap()const; | 110 | QMap<int, QString> toMap()const; |
111 | QMap<QString, QString> toExtraMap()const; | 111 | QMap<QString, QString> toExtraMap()const; |
112 | QString recordField(int )const; | 112 | QString recordField(int )const; |
113 | 113 | ||
114 | static int rtti(); | 114 | static int rtti(); |
115 | 115 | ||
116 | bool loadFromStream( QDataStream& ); | 116 | bool loadFromStream( QDataStream& ); |
117 | bool saveToStream( QDataStream& )const; | 117 | bool saveToStream( QDataStream& )const; |
118 | 118 | ||
119 | /* bool operator==( const OEvent& ); | 119 | /* bool operator==( const OEvent& ); |
120 | bool operator!=( const OEvent& ); | 120 | bool operator!=( const OEvent& ); |
121 | bool operator<( const OEvent& ); | 121 | bool operator<( const OEvent& ); |
122 | bool operator<=( const OEvent& ); | 122 | bool operator<=( const OEvent& ); |
123 | bool operator>( const OEvent& ); | 123 | bool operator>( const OEvent& ); |
124 | bool operator>=(const OEvent& ); | 124 | bool operator>=(const OEvent& ); |
125 | */ | 125 | */ |
126 | private: | 126 | private: |
127 | inline void changeOrModify(); | 127 | inline void changeOrModify(); |
128 | void deref(); | 128 | void deref(); |
129 | struct Data; | 129 | struct Data; |
130 | Data* data; | 130 | Data* data; |
131 | class Private; | 131 | class Private; |
132 | Private* priv; | 132 | Private* priv; |
133 | 133 | ||
134 | }; | 134 | }; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * AN Event can span through multiple days. We split up a multiday eve | 137 | * AN Event can span through multiple days. We split up a multiday eve |
138 | */ | 138 | */ |
139 | 139 | ||
140 | class OEffectiveEvent { | 140 | class OEffectiveEvent { |
141 | public: | 141 | public: |
142 | QValueList<OEffectiveEvent> ValueList; | 142 | typedef QValueList<OEffectiveEvent> ValueList; |
143 | enum Position { MidWay, Start, End, StartEnd }; | 143 | enum Position { MidWay, Start, End, StartEnd }; |
144 | // If we calculate the effective event of a multi-day event | 144 | // If we calculate the effective event of a multi-day event |
145 | // we have to figure out whether we are at the first day, | 145 | // we have to figure out whether we are at the first day, |
146 | // at the end, or anywhere else ("middle"). This is important | 146 | // at the end, or anywhere else ("middle"). This is important |
147 | // for the start/end times (00:00/23:59) | 147 | // for the start/end times (00:00/23:59) |
148 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | 148 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- |
149 | // day event | 149 | // day event |
150 | // Start: start time -> 23:59 | 150 | // Start: start time -> 23:59 |
151 | // End: 00:00 -> end time | 151 | // End: 00:00 -> end time |
152 | // Start | End == StartEnd: for single-day events (default) | 152 | // Start | End == StartEnd: for single-day events (default) |
153 | // here we draw start time -> end time | 153 | // here we draw start time -> end time |
154 | OEffectiveEvent(); | 154 | OEffectiveEvent(); |
155 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); | 155 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); |
156 | OEffectiveEvent( const OEffectiveEvent& ); | 156 | OEffectiveEvent( const OEffectiveEvent& ); |
157 | OEffectiveEvent &operator=(const OEffectiveEvent& ); | 157 | OEffectiveEvent &operator=(const OEffectiveEvent& ); |
158 | ~OEffectiveEvent(); | 158 | ~OEffectiveEvent(); |
159 | 159 | ||
160 | void setStartTime( const QTime& ); | 160 | void setStartTime( const QTime& ); |
161 | void setEndTime( const QTime& ); | 161 | void setEndTime( const QTime& ); |
162 | void setEvent( const OEvent& ); | 162 | void setEvent( const OEvent& ); |
163 | void setDate( const QDate& ); | 163 | void setDate( const QDate& ); |
164 | 164 | ||
165 | void setEffectiveDates( const QDate& from, const QDate& to ); | 165 | void setEffectiveDates( const QDate& from, const QDate& to ); |
166 | 166 | ||
167 | QString description()const; | 167 | QString description()const; |
168 | QString location()const; | 168 | QString location()const; |
169 | QString note()const; | 169 | QString note()const; |
170 | OEvent event()const; | 170 | OEvent event()const; |
171 | QTime startTime()const; | 171 | QTime startTime()const; |
172 | QTime endTime()const; | 172 | QTime endTime()const; |
173 | QDate date()const; | 173 | QDate date()const; |
174 | 174 | ||
175 | /* return the length in hours */ | 175 | /* return the length in hours */ |
176 | int length()const; | 176 | int length()const; |
177 | int size()const; | 177 | int size()const; |
178 | 178 | ||
179 | QDate startDate()const; | 179 | QDate startDate()const; |
180 | QDate endDate()const; | 180 | QDate endDate()const; |
181 | 181 | ||
182 | bool operator<( const OEffectiveEvent &e ) const; | 182 | bool operator<( const OEffectiveEvent &e ) const; |
183 | bool operator<=( const OEffectiveEvent &e ) const; | 183 | bool operator<=( const OEffectiveEvent &e ) const; |
184 | bool operator==( const OEffectiveEvent &e ) const; | 184 | bool operator==( const OEffectiveEvent &e ) const; |
185 | bool operator!=( const OEffectiveEvent &e ) const; | 185 | bool operator!=( const OEffectiveEvent &e ) const; |
186 | bool operator>( const OEffectiveEvent &e ) const; | 186 | bool operator>( const OEffectiveEvent &e ) const; |
187 | bool operator>= ( const OEffectiveEvent &e ) const; | 187 | bool operator>= ( const OEffectiveEvent &e ) const; |
188 | 188 | ||
189 | private: | 189 | private: |
190 | void deref(); | 190 | void deref(); |
191 | inline void changeOrModify(); | 191 | inline void changeOrModify(); |
192 | class Private; | 192 | class Private; |
193 | Private* priv; | 193 | Private* priv; |
194 | struct Data; | 194 | struct Data; |
195 | Data* data; | 195 | Data* data; |
196 | 196 | ||
197 | }; | 197 | }; |
198 | #endif | 198 | #endif |