summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/odatebookaccessbackend.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
index 8fa1a68..f0c5d65 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
@@ -82,75 +82,101 @@ namespace {
82 }else { 82 }else {
83 /* we only occur by days, not hours/minutes/seconds. Hence 83 /* we only occur by days, not hours/minutes/seconds. Hence
84 * the actual end and start times will be the same for 84 * the actual end and start times will be the same for
85 * every repeated event. For multi day events this is 85 * every repeated event. For multi day events this is
86 * fixed up later if on wronge day span 86 * fixed up later if on wronge day span
87 */ 87 */
88 eff.setStartTime( (*it).startDateTime().time() ); 88 eff.setStartTime( (*it).startDateTime().time() );
89 eff.setEndTime( (*it).endDateTime().time() ); 89 eff.setEndTime( (*it).endDateTime().time() );
90 } 90 }
91 if ( dur != 0 ) { 91 if ( dur != 0 ) {
92 // multi-day repeating events 92 // multi-day repeating events
93 QDate sub_it = QMAX( repeat, from ); 93 QDate sub_it = QMAX( repeat, from );
94 QDate startDate = repeat; 94 QDate startDate = repeat;
95 QDate endDate = startDate.addDays( dur ); 95 QDate endDate = startDate.addDays( dur );
96 96
97 while ( sub_it <= endDate && sub_it <= to ) { 97 while ( sub_it <= endDate && sub_it <= to ) {
98 OEffectiveEvent tmpEff = eff; 98 OEffectiveEvent tmpEff = eff;
99 tmpEff.setEvent( (*it) ); 99 tmpEff.setEvent( (*it) );
100 if ( sub_it != startDate ) 100 if ( sub_it != startDate )
101 tmpEff.setStartTime( QTime(0, 0, 0 ) ); 101 tmpEff.setStartTime( QTime(0, 0, 0 ) );
102 if ( sub_it != endDate ) 102 if ( sub_it != endDate )
103 tmpEff.setEndTime( QTime( 23, 59, 59 ) ); 103 tmpEff.setEndTime( QTime( 23, 59, 59 ) );
104 104
105 tmpEff.setDate( sub_it ); 105 tmpEff.setDate( sub_it );
106 tmpEff.setEffectiveDates( startDate, endDate ); 106 tmpEff.setEffectiveDates( startDate, endDate );
107 tmpList.append( tmpEff ); 107 tmpList.append( tmpEff );
108 108
109 sub_it = sub_it.addDays( 1 ); 109 sub_it = sub_it.addDays( 1 );
110 } 110 }
111 itDate = endDate; 111 itDate = endDate;
112 }else { 112 }else {
113 eff.setEvent( (*it) ); 113 eff.setEvent( (*it) );
114 tmpList.append( eff ); 114 tmpList.append( eff );
115 itDate = repeat.addDays( 1 ); 115 itDate = repeat.addDays( 1 );
116 } 116 }
117 } 117 }
118 } 118 }
119 } 119 }
120} 120}
121 121
122ODateBookAccessBackend::ODateBookAccessBackend() 122ODateBookAccessBackend::ODateBookAccessBackend()
123 : OPimAccessBackend<OEvent>() 123 : OPimAccessBackend<OEvent>()
124{ 124{
125 125
126} 126}
127ODateBookAccessBackend::~ODateBookAccessBackend() { 127ODateBookAccessBackend::~ODateBookAccessBackend() {
128 128
129} 129}
130OEffectiveEvent::ValueList ODateBookAccessBackend::effecticeEvents( const QDate& from, 130OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from,
131 const QDate& to ) { 131 const QDate& to ) {
132 OEffectiveEvent::ValueList tmpList; 132 OEffectiveEvent::ValueList tmpList;
133 OEvent::ValueList list = directNonRepeats(); 133 OEvent::ValueList list = directNonRepeats();
134 134
135 events( tmpList, list, from, to ); 135 events( tmpList, list, from, to );
136 repeat( tmpList, directRawRepeats(),from,to ); 136 repeat( tmpList, directRawRepeats(),from,to );
137 137
138 list = directRawRepeats(); 138 list = directRawRepeats(); // Useless, isn't it ? (eilers)
139 139
140 qHeapSort( tmpList ); 140 qHeapSort( tmpList );
141 return tmpList; 141 return tmpList;
142} 142}
143OEffectiveEvent::ValueList ODateBookAccessBackend::effecticeEvents( const QDateTime& dt ) { 143OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateTime& dt ) {
144 OEffectiveEvent::ValueList day = effecticeEvents( dt.date(), dt.date() ); 144 OEffectiveEvent::ValueList day = effectiveEvents( 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}
157
158OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from,
159 const QDate& to ) {
160 OEffectiveEvent::ValueList tmpList;
161 OEvent::ValueList list = directNonRepeats();
162
163 events( tmpList, list, from, to );
164
165 qHeapSort( tmpList );
166 return tmpList;
167}
168
169OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt ) {
170 OEffectiveEvent::ValueList day = effectiveNonRepeatingEvents( dt.date(), dt.date() );
145 OEffectiveEvent::ValueList::Iterator it; 171 OEffectiveEvent::ValueList::Iterator it;
146 172
147 OEffectiveEvent::ValueList tmpList; 173 OEffectiveEvent::ValueList tmpList;
148 QDateTime dtTmp; 174 QDateTime dtTmp;
149 for ( it = day.begin(); it != day.end(); ++it ) { 175 for ( it = day.begin(); it != day.end(); ++it ) {
150 dtTmp = QDateTime( (*it).date(), (*it).startTime() ); 176 dtTmp = QDateTime( (*it).date(), (*it).startTime() );
151 if ( QABS(dt.secsTo(dtTmp) ) < 60 ) 177 if ( QABS(dt.secsTo(dtTmp) ) < 60 )
152 tmpList.append( (*it) ); 178 tmpList.append( (*it) );
153 } 179 }
154 180
155 return tmpList; 181 return tmpList;
156} 182}