summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/odatebookaccessbackend.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
index f0c5d65..9bf4bf0 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
@@ -1,17 +1,47 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
1#include <qtl.h> 29#include <qtl.h>
2 30
3#include "orecur.h" 31#include <opie2/orecur.h>
32
33#include <opie2/odatebookaccessbackend.h>
4 34
5#include "odatebookaccessbackend.h" 35using namespace Opie;
6 36
7namespace { 37namespace {
8/* 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 */
9 void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events, 39 void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events,
10 const QDate& from, const QDate& to ) { 40 const QDate& from, const QDate& to ) {
11 QDateTime dtStart, dtEnd; 41 QDateTime dtStart, dtEnd;
12 42
13 for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { 43 for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) {
14 dtStart = (*it).startDateTime(); 44 dtStart = (*it).startDateTime();
15 dtEnd = (*it).endDateTime(); 45 dtEnd = (*it).endDateTime();
16 46
17 /* 47 /*
@@ -110,24 +140,26 @@ namespace {
110 } 140 }
111 itDate = endDate; 141 itDate = endDate;
112 }else { 142 }else {
113 eff.setEvent( (*it) ); 143 eff.setEvent( (*it) );
114 tmpList.append( eff ); 144 tmpList.append( eff );
115 itDate = repeat.addDays( 1 ); 145 itDate = repeat.addDays( 1 );
116 } 146 }
117 } 147 }
118 } 148 }
119 } 149 }
120} 150}
121 151
152namespace Opie {
153
122ODateBookAccessBackend::ODateBookAccessBackend() 154ODateBookAccessBackend::ODateBookAccessBackend()
123 : OPimAccessBackend<OEvent>() 155 : OPimAccessBackend<OEvent>()
124{ 156{
125 157
126} 158}
127ODateBookAccessBackend::~ODateBookAccessBackend() { 159ODateBookAccessBackend::~ODateBookAccessBackend() {
128 160
129} 161}
130OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from, 162OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from,
131 const QDate& to ) { 163 const QDate& to ) {
132 OEffectiveEvent::ValueList tmpList; 164 OEffectiveEvent::ValueList tmpList;
133 OEvent::ValueList list = directNonRepeats(); 165 OEvent::ValueList list = directNonRepeats();
@@ -171,12 +203,14 @@ OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents(
171 OEffectiveEvent::ValueList::Iterator it; 203 OEffectiveEvent::ValueList::Iterator it;
172 204
173 OEffectiveEvent::ValueList tmpList; 205 OEffectiveEvent::ValueList tmpList;
174 QDateTime dtTmp; 206 QDateTime dtTmp;
175 for ( it = day.begin(); it != day.end(); ++it ) { 207 for ( it = day.begin(); it != day.end(); ++it ) {
176 dtTmp = QDateTime( (*it).date(), (*it).startTime() ); 208 dtTmp = QDateTime( (*it).date(), (*it).startTime() );
177 if ( QABS(dt.secsTo(dtTmp) ) < 60 ) 209 if ( QABS(dt.secsTo(dtTmp) ) < 60 )
178 tmpList.append( (*it) ); 210 tmpList.append( (*it) );
179 } 211 }
180 212
181 return tmpList; 213 return tmpList;
182} 214}
215
216}