-rw-r--r-- | libopie/libopie.pro | 4 | ||||
-rw-r--r-- | libopie/pim/odatebookaccess.cpp | 37 | ||||
-rw-r--r-- | libopie/pim/odatebookaccess.h | 32 | ||||
-rw-r--r-- | libopie/pim/odatebookaccessbackend.cpp | 156 | ||||
-rw-r--r-- | libopie/pim/odatebookaccessbackend.h | 32 | ||||
-rw-r--r-- | libopie/pim/oevent.cpp | 57 | ||||
-rw-r--r-- | libopie/pim/oevent.h | 6 |
7 files changed, 292 insertions, 32 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index 2b843c1..70399ea 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro | |||
@@ -17,85 +17,89 @@ HEADERS = ofontmenu.h \ | |||
17 | pim/opimaccesstemplate.h \ | 17 | pim/opimaccesstemplate.h \ |
18 | pim/opimaccessbackend.h \ | 18 | pim/opimaccessbackend.h \ |
19 | pim/otodoaccess.h \ | 19 | pim/otodoaccess.h \ |
20 | pim/otodoaccessbackend.h \ | 20 | pim/otodoaccessbackend.h \ |
21 | pim/ocontact.h \ | 21 | pim/ocontact.h \ |
22 | pim/ocontactaccess.h \ | 22 | pim/ocontactaccess.h \ |
23 | pim/ocontactaccessbackend.h \ | 23 | pim/ocontactaccessbackend.h \ |
24 | pim/ocontactaccessbackend_xml.h \ | 24 | pim/ocontactaccessbackend_xml.h \ |
25 | pim/ocontactaccessbackend_vcard.h \ | 25 | pim/ocontactaccessbackend_vcard.h \ |
26 | pim/obackendfactory.h \ | 26 | pim/obackendfactory.h \ |
27 | pim/opimcache.h \ | 27 | pim/opimcache.h \ |
28 | pim/otodoaccessvcal.h \ | 28 | pim/otodoaccessvcal.h \ |
29 | pim/orecur.h \ | 29 | pim/orecur.h \ |
30 | pim/opimstate.h \ | 30 | pim/opimstate.h \ |
31 | pim/opimxrefpartner.h \ | 31 | pim/opimxrefpartner.h \ |
32 | pim/opimxref.h \ | 32 | pim/opimxref.h \ |
33 | pim/opimxrefmanager.h \ | 33 | pim/opimxrefmanager.h \ |
34 | pim/opimmaintainer.h \ | 34 | pim/opimmaintainer.h \ |
35 | pim/opimnotify.h \ | 35 | pim/opimnotify.h \ |
36 | pim/opimnotifymanager.h \ | 36 | pim/opimnotifymanager.h \ |
37 | pim/opimmainwindow.h \ | 37 | pim/opimmainwindow.h \ |
38 | pim/opimresolver.h \ | 38 | pim/opimresolver.h \ |
39 | pim/oevent.h \ | 39 | pim/oevent.h \ |
40 | pim/otimezone.h \ | 40 | pim/otimezone.h \ |
41 | pim/odatebookaccess.h \ | ||
42 | pim/odatebookaccessbackend.h \ | ||
41 | orecurrancewidget.h \ | 43 | orecurrancewidget.h \ |
42 | oticker.h | 44 | oticker.h |
43 | # pim/otodoaccesssql.h \ | 45 | # pim/otodoaccesssql.h \ |
44 | 46 | ||
45 | SOURCES = ofontmenu.cc \ | 47 | SOURCES = ofontmenu.cc \ |
46 | ocolorbutton.cpp \ | 48 | ocolorbutton.cpp \ |
47 | sharp_compat.cpp \ | 49 | sharp_compat.cpp \ |
48 | xmltree.cc \ | 50 | xmltree.cc \ |
49 | ofiledialog.cc ofileselector.cc \ | 51 | ofiledialog.cc ofileselector.cc \ |
50 | ocheckitem.cpp \ | 52 | ocheckitem.cpp \ |
51 | colordialog.cpp \ | 53 | colordialog.cpp \ |
52 | colorpopupmenu.cpp oclickablelabel.cpp \ | 54 | colorpopupmenu.cpp oclickablelabel.cpp \ |
53 | oprocctrl.cpp oprocess.cpp \ | 55 | oprocctrl.cpp oprocess.cpp \ |
54 | odevice.cpp odevicebutton.cpp otimepicker.cpp \ | 56 | odevice.cpp odevicebutton.cpp otimepicker.cpp \ |
55 | otabwidget.cpp otabbar.cpp \ | 57 | otabwidget.cpp otabbar.cpp \ |
56 | ofontselector.cpp \ | 58 | ofontselector.cpp \ |
57 | pim/otodo.cpp \ | 59 | pim/otodo.cpp \ |
58 | pim/opimrecord.cpp \ | 60 | pim/opimrecord.cpp \ |
59 | pim/otodoaccess.cpp \ | 61 | pim/otodoaccess.cpp \ |
60 | pim/otodoaccessbackend.cpp \ | 62 | pim/otodoaccessbackend.cpp \ |
61 | pim/otodoaccessxml.cpp \ | 63 | pim/otodoaccessxml.cpp \ |
62 | pim/ocontact.cpp \ | 64 | pim/ocontact.cpp \ |
63 | pim/ocontactaccess.cpp \ | 65 | pim/ocontactaccess.cpp \ |
64 | pim/ocontactaccessbackend_vcard.cpp \ | 66 | pim/ocontactaccessbackend_vcard.cpp \ |
65 | pim/otodoaccessvcal.cpp \ | 67 | pim/otodoaccessvcal.cpp \ |
66 | pim/orecur.cpp \ | 68 | pim/orecur.cpp \ |
67 | pim/opimstate.cpp \ | 69 | pim/opimstate.cpp \ |
68 | pim/opimxrefpartner.cpp \ | 70 | pim/opimxrefpartner.cpp \ |
69 | pim/opimxref.cpp \ | 71 | pim/opimxref.cpp \ |
70 | pim/opimxrefmanager.cpp \ | 72 | pim/opimxrefmanager.cpp \ |
71 | pim/opimmaintainer.cpp \ | 73 | pim/opimmaintainer.cpp \ |
72 | pim/opimnotify.cpp \ | 74 | pim/opimnotify.cpp \ |
73 | pim/opimnotifymanager.cpp \ | 75 | pim/opimnotifymanager.cpp \ |
74 | pim/opimmainwindow.cpp \ | 76 | pim/opimmainwindow.cpp \ |
75 | pim/opimresolver.cpp \ | 77 | pim/opimresolver.cpp \ |
76 | pim/oevent.cpp \ | 78 | pim/oevent.cpp \ |
77 | pim/otimezone.cpp \ | 79 | pim/otimezone.cpp \ |
80 | pim/odatebookaccess.cpp \ | ||
81 | pim/odatebookaccessbackend.cpp \ | ||
78 | orecurrancewidget.cpp \ | 82 | orecurrancewidget.cpp \ |
79 | oticker.cpp | 83 | oticker.cpp |
80 | # pim/otodoaccesssql.cpp \ | 84 | # pim/otodoaccesssql.cpp \ |
81 | 85 | ||
82 | TARGET = opie | 86 | TARGET = opie |
83 | INCLUDEPATH += $(OPIEDIR)/include | 87 | INCLUDEPATH += $(OPIEDIR)/include |
84 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | 88 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) |
85 | #VERSION = 1.0.0 | 89 | #VERSION = 1.0.0 |
86 | 90 | ||
87 | LIBS += -lqpe | 91 | LIBS += -lqpe |
88 | 92 | ||
89 | # LIBS += -lopiesql | 93 | # LIBS += -lopiesql |
90 | 94 | ||
91 | INTERFACES = otimepickerbase.ui orecurrancebase.ui | 95 | INTERFACES = otimepickerbase.ui orecurrancebase.ui |
92 | 96 | ||
93 | TRANSLATIONS = ../i18n/de/libopie.ts \ | 97 | TRANSLATIONS = ../i18n/de/libopie.ts \ |
94 | ../i18n/xx/libopie.ts \ | 98 | ../i18n/xx/libopie.ts \ |
95 | ../i18n/en/libopie.ts \ | 99 | ../i18n/en/libopie.ts \ |
96 | ../i18n/es/libopie.ts \ | 100 | ../i18n/es/libopie.ts \ |
97 | ../i18n/fr/libopie.ts \ | 101 | ../i18n/fr/libopie.ts \ |
98 | ../i18n/hu/libopie.ts \ | 102 | ../i18n/hu/libopie.ts \ |
99 | ../i18n/ja/libopie.ts \ | 103 | ../i18n/ja/libopie.ts \ |
100 | ../i18n/ko/libopie.ts \ | 104 | ../i18n/ko/libopie.ts \ |
101 | ../i18n/no/libopie.ts \ | 105 | ../i18n/no/libopie.ts \ |
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 | |||
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/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 | |||
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/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 | |||
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/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 | |||
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/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp index 71b9441..aaae3b2 100644 --- a/libopie/pim/oevent.cpp +++ b/libopie/pim/oevent.cpp | |||
@@ -1,66 +1,64 @@ | |||
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 | ||
@@ -109,49 +107,50 @@ OPimNotifyManager &OEvent::notifiers() { | |||
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 | ||
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 | |||
@@ -1,53 +1,53 @@ | |||
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& ); |
@@ -118,49 +118,49 @@ public: | |||
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 | ||