Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp index 9bf4bf0..f3b7b5f 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp | |||
@@ -19,37 +19,37 @@ | |||
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qtl.h> | 29 | #include <qtl.h> |
30 | 30 | ||
31 | #include <opie2/orecur.h> | 31 | #include <opie2/opimrecurrence.h> |
32 | 32 | ||
33 | #include <opie2/odatebookaccessbackend.h> | 33 | #include <opie2/odatebookaccessbackend.h> |
34 | 34 | ||
35 | using namespace Opie; | 35 | using namespace Opie; |
36 | 36 | ||
37 | namespace { | 37 | namespace { |
38 | /* a small helper to get all NonRepeating events for a range of time */ | 38 | /* a small helper to get all NonRepeating events for a range of time */ |
39 | void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events, | 39 | void events( OEffectiveEvent::ValueList& tmpList, const OPimEvent::ValueList& events, |
40 | const QDate& from, const QDate& to ) { | 40 | const QDate& from, const QDate& to ) { |
41 | QDateTime dtStart, dtEnd; | 41 | QDateTime dtStart, dtEnd; |
42 | 42 | ||
43 | for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { | 43 | for ( OPimEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { |
44 | dtStart = (*it).startDateTime(); | 44 | dtStart = (*it).startDateTime(); |
45 | dtEnd = (*it).endDateTime(); | 45 | dtEnd = (*it).endDateTime(); |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * If in range | 48 | * If in range |
49 | */ | 49 | */ |
50 | if (dtStart.date() >= from && dtEnd.date() <= to ) { | 50 | if (dtStart.date() >= from && dtEnd.date() <= to ) { |
51 | OEffectiveEvent eff; | 51 | OEffectiveEvent eff; |
52 | eff.setEvent( (*it) ); | 52 | eff.setEvent( (*it) ); |
53 | eff.setDate( dtStart.date() ); | 53 | eff.setDate( dtStart.date() ); |
54 | eff.setStartTime( dtStart.time() ); | 54 | eff.setStartTime( dtStart.time() ); |
55 | 55 | ||
@@ -82,31 +82,31 @@ namespace { | |||
82 | if ( dt.date() == dtEnd.date() ) | 82 | if ( dt.date() == dtEnd.date() ) |
83 | eff.setEndTime( dtEnd.time() ); | 83 | eff.setEndTime( dtEnd.time() ); |
84 | else | 84 | else |
85 | eff.setEndTime( QTime(23, 59, 0 ) ); | 85 | eff.setEndTime( QTime(23, 59, 0 ) ); |
86 | tmpList.append( eff ); | 86 | tmpList.append( eff ); |
87 | } | 87 | } |
88 | dt = dt.addDays( 1 ); | 88 | dt = dt.addDays( 1 ); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | void repeat( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& list, | 94 | void repeat( OEffectiveEvent::ValueList& tmpList, const OPimEvent::ValueList& list, |
95 | const QDate& from, const QDate& to ) { | 95 | const QDate& from, const QDate& to ) { |
96 | QDate repeat; | 96 | QDate repeat; |
97 | for ( OEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 97 | for ( OPimEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
98 | int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() ); | 98 | int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() ); |
99 | QDate itDate = from.addDays(-dur ); | 99 | QDate itDate = from.addDays(-dur ); |
100 | ORecur rec = (*it).recurrence(); | 100 | OPimRecurrence rec = (*it).recurrence(); |
101 | if ( !rec.hasEndDate() || rec.endDate() > to ) { | 101 | if ( !rec.hasEndDate() || rec.endDate() > to ) { |
102 | rec.setEndDate( to ); | 102 | rec.setEndDate( to ); |
103 | rec.setHasEndDate( true ); | 103 | rec.setHasEndDate( true ); |
104 | } | 104 | } |
105 | while (rec.nextOcurrence(itDate, repeat ) ) { | 105 | while (rec.nextOcurrence(itDate, repeat ) ) { |
106 | if (repeat > to ) break; | 106 | if (repeat > to ) break; |
107 | OEffectiveEvent eff; | 107 | OEffectiveEvent eff; |
108 | eff.setDate( repeat ); | 108 | eff.setDate( repeat ); |
109 | if ( (*it).isAllDay() ) { | 109 | if ( (*it).isAllDay() ) { |
110 | eff.setStartTime( QTime(0, 0, 0 ) ); | 110 | eff.setStartTime( QTime(0, 0, 0 ) ); |
111 | eff.setEndTime( QTime(23, 59, 59 ) ); | 111 | eff.setEndTime( QTime(23, 59, 59 ) ); |
112 | }else { | 112 | }else { |
@@ -143,35 +143,35 @@ namespace { | |||
143 | eff.setEvent( (*it) ); | 143 | eff.setEvent( (*it) ); |
144 | tmpList.append( eff ); | 144 | tmpList.append( eff ); |
145 | itDate = repeat.addDays( 1 ); | 145 | itDate = repeat.addDays( 1 ); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | } | 148 | } |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | namespace Opie { | 152 | namespace Opie { |
153 | 153 | ||
154 | ODateBookAccessBackend::ODateBookAccessBackend() | 154 | ODateBookAccessBackend::ODateBookAccessBackend() |
155 | : OPimAccessBackend<OEvent>() | 155 | : OPimAccessBackend<OPimEvent>() |
156 | { | 156 | { |
157 | 157 | ||
158 | } | 158 | } |
159 | ODateBookAccessBackend::~ODateBookAccessBackend() { | 159 | ODateBookAccessBackend::~ODateBookAccessBackend() { |
160 | 160 | ||
161 | } | 161 | } |
162 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from, | 162 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from, |
163 | const QDate& to ) { | 163 | const QDate& to ) { |
164 | OEffectiveEvent::ValueList tmpList; | 164 | OEffectiveEvent::ValueList tmpList; |
165 | OEvent::ValueList list = directNonRepeats(); | 165 | OPimEvent::ValueList list = directNonRepeats(); |
166 | 166 | ||
167 | events( tmpList, list, from, to ); | 167 | events( tmpList, list, from, to ); |
168 | repeat( tmpList, directRawRepeats(),from,to ); | 168 | repeat( tmpList, directRawRepeats(),from,to ); |
169 | 169 | ||
170 | list = directRawRepeats(); // Useless, isn't it ? (eilers) | 170 | list = directRawRepeats(); // Useless, isn't it ? (eilers) |
171 | 171 | ||
172 | qHeapSort( tmpList ); | 172 | qHeapSort( tmpList ); |
173 | return tmpList; | 173 | return tmpList; |
174 | } | 174 | } |
175 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateTime& dt ) { | 175 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateTime& dt ) { |
176 | OEffectiveEvent::ValueList day = effectiveEvents( dt.date(), dt.date() ); | 176 | OEffectiveEvent::ValueList day = effectiveEvents( dt.date(), dt.date() ); |
177 | OEffectiveEvent::ValueList::Iterator it; | 177 | OEffectiveEvent::ValueList::Iterator it; |
@@ -181,25 +181,25 @@ OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateT | |||
181 | for ( it = day.begin(); it != day.end(); ++it ) { | 181 | for ( it = day.begin(); it != day.end(); ++it ) { |
182 | dtTmp = QDateTime( (*it).date(), (*it).startTime() ); | 182 | dtTmp = QDateTime( (*it).date(), (*it).startTime() ); |
183 | if ( QABS(dt.secsTo(dtTmp) ) < 60 ) | 183 | if ( QABS(dt.secsTo(dtTmp) ) < 60 ) |
184 | tmpList.append( (*it) ); | 184 | tmpList.append( (*it) ); |
185 | } | 185 | } |
186 | 186 | ||
187 | return tmpList; | 187 | return tmpList; |
188 | } | 188 | } |
189 | 189 | ||
190 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from, | 190 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from, |
191 | const QDate& to ) { | 191 | const QDate& to ) { |
192 | OEffectiveEvent::ValueList tmpList; | 192 | OEffectiveEvent::ValueList tmpList; |
193 | OEvent::ValueList list = directNonRepeats(); | 193 | OPimEvent::ValueList list = directNonRepeats(); |
194 | 194 | ||
195 | events( tmpList, list, from, to ); | 195 | events( tmpList, list, from, to ); |
196 | 196 | ||
197 | qHeapSort( tmpList ); | 197 | qHeapSort( tmpList ); |
198 | return tmpList; | 198 | return tmpList; |
199 | } | 199 | } |
200 | 200 | ||
201 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt ) { | 201 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt ) { |
202 | OEffectiveEvent::ValueList day = effectiveNonRepeatingEvents( dt.date(), dt.date() ); | 202 | OEffectiveEvent::ValueList day = effectiveNonRepeatingEvents( dt.date(), dt.date() ); |
203 | OEffectiveEvent::ValueList::Iterator it; | 203 | OEffectiveEvent::ValueList::Iterator it; |
204 | 204 | ||
205 | OEffectiveEvent::ValueList tmpList; | 205 | OEffectiveEvent::ValueList tmpList; |