summaryrefslogtreecommitdiff
path: root/libopie2
authorzecke <zecke>2003-05-07 18:10:56 (UTC)
committer zecke <zecke>2003-05-07 18:10:56 (UTC)
commit3cee83b6e2931768fb0d0989b2235800914888a7 (patch) (unidiff)
treed99a7565fdb5be62cf739d82ec5de50c2bbf95e9 /libopie2
parent94371938792c70a40cdb75e37c69020438d450c9 (diff)
downloadopie-3cee83b6e2931768fb0d0989b2235800914888a7.zip
opie-3cee83b6e2931768fb0d0989b2235800914888a7.tar.gz
opie-3cee83b6e2931768fb0d0989b2235800914888a7.tar.bz2
save the state
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index a8e1503..285d2b8 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -1,770 +1,776 @@
1#include <errno.h> 1#include <errno.h>
2#include <fcntl.h> 2#include <fcntl.h>
3 3
4#include <sys/mman.h> 4#include <sys/mman.h>
5#include <sys/stat.h> 5#include <sys/stat.h>
6#include <sys/types.h> 6#include <sys/types.h>
7 7
8#include <unistd.h> 8#include <unistd.h>
9 9
10 10
11#include <qfile.h> 11#include <qfile.h>
12#include <qvector.h> 12#include <qvector.h>
13 13
14#include <qpe/global.h> 14#include <qpe/global.h>
15#include <qpe/stringutil.h> 15#include <qpe/stringutil.h>
16#include <qpe/timeconversion.h> 16#include <qpe/timeconversion.h>
17 17
18#include "oconversion.h" 18#include "oconversion.h"
19#include "opimstate.h"
19#include "otimezone.h" 20#include "otimezone.h"
20#include "orecur.h" 21#include "orecur.h"
21#include "otodoaccessxml.h" 22#include "otodoaccessxml.h"
22 23
23namespace { 24namespace {
24 time_t rp_end; 25 time_t rp_end;
25 ORecur* rec; 26 ORecur* rec;
26 ORecur *recur() { 27 ORecur *recur() {
27 if (!rec ) rec = new ORecur; 28 if (!rec ) rec = new ORecur;
28 return rec; 29 return rec;
29 } 30 }
30 int snd; 31 int snd;
31 enum MoreAttributes { 32 enum MoreAttributes {
32 FRType = OTodo::CompletedDate + 2, 33 FRType = OTodo::CompletedDate + 2,
33 FRWeekdays, 34 FRWeekdays,
34 FRPosition, 35 FRPosition,
35 FRFreq, 36 FRFreq,
36 FRHasEndDate, 37 FRHasEndDate,
37 FREndDate, 38 FREndDate,
38 FRStart, 39 FRStart,
39 FREnd 40 FREnd
40 }; 41 };
41 // FROM TT again 42 // FROM TT again
42char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) 43char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
43{ 44{
44 char needleChar; 45 char needleChar;
45 char haystackChar; 46 char haystackChar;
46 if (!needle || !haystack || !hLen || !nLen) 47 if (!needle || !haystack || !hLen || !nLen)
47 return 0; 48 return 0;
48 49
49 const char* hsearch = haystack; 50 const char* hsearch = haystack;
50 51
51 if ((needleChar = *needle++) != 0) { 52 if ((needleChar = *needle++) != 0) {
52 nLen--; //(to make up for needle++) 53 nLen--; //(to make up for needle++)
53 do { 54 do {
54 do { 55 do {
55 if ((haystackChar = *hsearch++) == 0) 56 if ((haystackChar = *hsearch++) == 0)
56 return (0); 57 return (0);
57 if (hsearch >= haystack + hLen) 58 if (hsearch >= haystack + hLen)
58 return (0); 59 return (0);
59 } while (haystackChar != needleChar); 60 } while (haystackChar != needleChar);
60 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); 61 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
61 hsearch--; 62 hsearch--;
62 } 63 }
63 return ((char *)hsearch); 64 return ((char *)hsearch);
64} 65}
65} 66}
66 67
67 68
68OTodoAccessXML::OTodoAccessXML( const QString& appName, 69OTodoAccessXML::OTodoAccessXML( const QString& appName,
69 const QString& fileName ) 70 const QString& fileName )
70 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) 71 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
71{ 72{
72 if (!fileName.isEmpty() ) 73 if (!fileName.isEmpty() )
73 m_file = fileName; 74 m_file = fileName;
74 else 75 else
75 m_file = Global::applicationFileName( "todolist", "todolist.xml" ); 76 m_file = Global::applicationFileName( "todolist", "todolist.xml" );
76} 77}
77OTodoAccessXML::~OTodoAccessXML() { 78OTodoAccessXML::~OTodoAccessXML() {
78 79
79} 80}
80bool OTodoAccessXML::load() { 81bool OTodoAccessXML::load() {
81 rec = 0; 82 rec = 0;
82 m_opened = true; 83 m_opened = true;
83 m_changed = false; 84 m_changed = false;
84 /* initialize dict */ 85 /* initialize dict */
85 /* 86 /*
86 * UPDATE dict if you change anything!!! 87 * UPDATE dict if you change anything!!!
87 */ 88 */
88 QAsciiDict<int> dict(21); 89 QAsciiDict<int> dict(21);
89 dict.setAutoDelete( TRUE ); 90 dict.setAutoDelete( TRUE );
90 dict.insert("Categories" , new int(OTodo::Category) ); 91 dict.insert("Categories" , new int(OTodo::Category) );
91 dict.insert("Uid" , new int(OTodo::Uid) ); 92 dict.insert("Uid" , new int(OTodo::Uid) );
92 dict.insert("HasDate" , new int(OTodo::HasDate) ); 93 dict.insert("HasDate" , new int(OTodo::HasDate) );
93 dict.insert("Completed" , new int(OTodo::Completed) ); 94 dict.insert("Completed" , new int(OTodo::Completed) );
94 dict.insert("Description" , new int(OTodo::Description) ); 95 dict.insert("Description" , new int(OTodo::Description) );
95 dict.insert("Summary" , new int(OTodo::Summary) ); 96 dict.insert("Summary" , new int(OTodo::Summary) );
96 dict.insert("Priority" , new int(OTodo::Priority) ); 97 dict.insert("Priority" , new int(OTodo::Priority) );
97 dict.insert("DateDay" , new int(OTodo::DateDay) ); 98 dict.insert("DateDay" , new int(OTodo::DateDay) );
98 dict.insert("DateMonth" , new int(OTodo::DateMonth) ); 99 dict.insert("DateMonth" , new int(OTodo::DateMonth) );
99 dict.insert("DateYear" , new int(OTodo::DateYear) ); 100 dict.insert("DateYear" , new int(OTodo::DateYear) );
100 dict.insert("Progress" , new int(OTodo::Progress) ); 101 dict.insert("Progress" , new int(OTodo::Progress) );
101 dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); 102 dict.insert("CompletedDate", new int(OTodo::CompletedDate) );
102 dict.insert("StartDate", new int(OTodo::StartDate) ); 103 dict.insert("StartDate", new int(OTodo::StartDate) );
103 dict.insert("CrossReference", new int(OTodo::CrossReference) ); 104 dict.insert("CrossReference", new int(OTodo::CrossReference) );
104 dict.insert("State", new int(OTodo::State) ); 105 dict.insert("State", new int(OTodo::State) );
105 dict.insert("Alarms", new int(OTodo::Alarms) ); 106 dict.insert("Alarms", new int(OTodo::Alarms) );
106 dict.insert("Reminders", new int(OTodo::Reminders) ); 107 dict.insert("Reminders", new int(OTodo::Reminders) );
107 dict.insert("Notifiers", new int(OTodo::Notifiers) ); 108 dict.insert("Notifiers", new int(OTodo::Notifiers) );
108 dict.insert("Maintainer", new int(OTodo::Maintainer) ); 109 dict.insert("Maintainer", new int(OTodo::Maintainer) );
109 dict.insert("rtype", new int(FRType) ); 110 dict.insert("rtype", new int(FRType) );
110 dict.insert("rweekdays", new int(FRWeekdays) ); 111 dict.insert("rweekdays", new int(FRWeekdays) );
111 dict.insert("rposition", new int(FRPosition) ); 112 dict.insert("rposition", new int(FRPosition) );
112 dict.insert("rfreq", new int(FRFreq) ); 113 dict.insert("rfreq", new int(FRFreq) );
113 dict.insert("start", new int(FRStart) ); 114 dict.insert("start", new int(FRStart) );
114 dict.insert("rhasenddate", new int(FRHasEndDate) ); 115 dict.insert("rhasenddate", new int(FRHasEndDate) );
115 dict.insert("enddt", new int(FREndDate) ); 116 dict.insert("enddt", new int(FREndDate) );
116 117
117 // here the custom XML parser from TT it's GPL 118 // here the custom XML parser from TT it's GPL
118 // but we want to push OpiePIM... to TT..... 119 // but we want to push OpiePIM... to TT.....
119 // mmap part from zecke :) 120 // mmap part from zecke :)
120 int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); 121 int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY );
121 struct stat attribut; 122 struct stat attribut;
122 if ( fd < 0 ) return false; 123 if ( fd < 0 ) return false;
123 124
124 if ( fstat(fd, &attribut ) == -1 ) { 125 if ( fstat(fd, &attribut ) == -1 ) {
125 ::close( fd ); 126 ::close( fd );
126 return false; 127 return false;
127 } 128 }
128 void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 ); 129 void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 );
129 if ( map_addr == ( (caddr_t)-1) ) { 130 if ( map_addr == ( (caddr_t)-1) ) {
130 ::close(fd ); 131 ::close(fd );
131 return false; 132 return false;
132 } 133 }
133 /* advise the kernel who we want to read it */ 134 /* advise the kernel who we want to read it */
134 ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL ); 135 ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL );
135 /* we do not the file any more */ 136 /* we do not the file any more */
136 ::close( fd ); 137 ::close( fd );
137 138
138 char* dt = (char*)map_addr; 139 char* dt = (char*)map_addr;
139 int len = attribut.st_size; 140 int len = attribut.st_size;
140 int i = 0; 141 int i = 0;
141 char *point; 142 char *point;
142 const char* collectionString = "<Task "; 143 const char* collectionString = "<Task ";
143 int strLen = strlen(collectionString); 144 int strLen = strlen(collectionString);
144 while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { 145 while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) {
145 i = point -dt; 146 i = point -dt;
146 i+= strLen; 147 i+= strLen;
147 qWarning("Found a start at %d %d", i, (point-dt) ); 148 qWarning("Found a start at %d %d", i, (point-dt) );
148 149
149 OTodo ev; 150 OTodo ev;
150 m_year = m_month = m_day = 0; 151 m_year = m_month = m_day = 0;
151 152
152 while ( TRUE ) { 153 while ( TRUE ) {
153 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) 154 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
154 ++i; 155 ++i;
155 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) 156 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
156 break; 157 break;
157 158
158 // we have another attribute, read it. 159 // we have another attribute, read it.
159 int j = i; 160 int j = i;
160 while ( j < len && dt[j] != '=' ) 161 while ( j < len && dt[j] != '=' )
161 ++j; 162 ++j;
162 QCString attr( dt+i, j-i+1); 163 QCString attr( dt+i, j-i+1);
163 164
164 i = ++j; // skip = 165 i = ++j; // skip =
165 166
166 // find the start of quotes 167 // find the start of quotes
167 while ( i < len && dt[i] != '"' ) 168 while ( i < len && dt[i] != '"' )
168 ++i; 169 ++i;
169 j = ++i; 170 j = ++i;
170 171
171 bool haveUtf = FALSE; 172 bool haveUtf = FALSE;
172 bool haveEnt = FALSE; 173 bool haveEnt = FALSE;
173 while ( j < len && dt[j] != '"' ) { 174 while ( j < len && dt[j] != '"' ) {
174 if ( ((unsigned char)dt[j]) > 0x7f ) 175 if ( ((unsigned char)dt[j]) > 0x7f )
175 haveUtf = TRUE; 176 haveUtf = TRUE;
176 if ( dt[j] == '&' ) 177 if ( dt[j] == '&' )
177 haveEnt = TRUE; 178 haveEnt = TRUE;
178 ++j; 179 ++j;
179 } 180 }
180 if ( i == j ) { 181 if ( i == j ) {
181 // empty value 182 // empty value
182 i = j + 1; 183 i = j + 1;
183 continue; 184 continue;
184 } 185 }
185 186
186 QCString value( dt+i, j-i+1 ); 187 QCString value( dt+i, j-i+1 );
187 i = j + 1; 188 i = j + 1;
188 189
189 QString str = (haveUtf ? QString::fromUtf8( value ) 190 QString str = (haveUtf ? QString::fromUtf8( value )
190 : QString::fromLatin1( value ) ); 191 : QString::fromLatin1( value ) );
191 if ( haveEnt ) 192 if ( haveEnt )
192 str = Qtopia::plainString( str ); 193 str = Qtopia::plainString( str );
193 194
194 /* 195 /*
195 * add key + value 196 * add key + value
196 */ 197 */
197 todo( &dict, ev, attr, str ); 198 todo( &dict, ev, attr, str );
198 199
199 } 200 }
200 /* 201 /*
201 * now add it 202 * now add it
202 */ 203 */
203 qWarning("End at %d", i ); 204 qWarning("End at %d", i );
204 if (m_events.contains( ev.uid() ) || ev.uid() == 0) { 205 if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
205 ev.setUid( 1 ); 206 ev.setUid( 1 );
206 m_changed = true; 207 m_changed = true;
207 } 208 }
208 if ( ev.hasDueDate() ) { 209 if ( ev.hasDueDate() ) {
209 ev.setDueDate( QDate(m_year, m_month, m_day) ); 210 ev.setDueDate( QDate(m_year, m_month, m_day) );
210 } 211 }
211 if ( rec && rec->doesRecur() ) { 212 if ( rec && rec->doesRecur() ) {
212 OTimeZone utc = OTimeZone::utc(); 213 OTimeZone utc = OTimeZone::utc();
213 ORecur recu( *rec ); // call copy c'tor 214 ORecur recu( *rec ); // call copy c'tor
214 recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); 215 recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() );
215 recu.setStart( ev.dueDate() ); 216 recu.setStart( ev.dueDate() );
216 ev.setRecurrence( recu ); 217 ev.setRecurrence( recu );
217 } 218 }
218 m_events.insert(ev.uid(), ev ); 219 m_events.insert(ev.uid(), ev );
219 m_year = m_month = m_day = -1; 220 m_year = m_month = m_day = -1;
220 delete rec; 221 delete rec;
221 rec = 0; 222 rec = 0;
222 } 223 }
223 224
224 munmap(map_addr, attribut.st_size ); 225 munmap(map_addr, attribut.st_size );
225 226
226 qWarning("counts %d records loaded!", m_events.count() ); 227 qWarning("counts %d records loaded!", m_events.count() );
227 return true; 228 return true;
228} 229}
229bool OTodoAccessXML::reload() { 230bool OTodoAccessXML::reload() {
230 m_events.clear(); 231 m_events.clear();
231 return load(); 232 return load();
232} 233}
233bool OTodoAccessXML::save() { 234bool OTodoAccessXML::save() {
234// qWarning("saving"); 235// qWarning("saving");
235 if (!m_opened || !m_changed ) { 236 if (!m_opened || !m_changed ) {
236// qWarning("not saving"); 237// qWarning("not saving");
237 return true; 238 return true;
238 } 239 }
239 QString strNewFile = m_file + ".new"; 240 QString strNewFile = m_file + ".new";
240 QFile f( strNewFile ); 241 QFile f( strNewFile );
241 if (!f.open( IO_WriteOnly|IO_Raw ) ) 242 if (!f.open( IO_WriteOnly|IO_Raw ) )
242 return false; 243 return false;
243 244
244 int written; 245 int written;
245 QString out; 246 QString out;
246 out = "<!DOCTYPE Tasks>\n<Tasks>\n"; 247 out = "<!DOCTYPE Tasks>\n<Tasks>\n";
247 248
248 // for all todos 249 // for all todos
249 QMap<int, OTodo>::Iterator it; 250 QMap<int, OTodo>::Iterator it;
250 for (it = m_events.begin(); it != m_events.end(); ++it ) { 251 for (it = m_events.begin(); it != m_events.end(); ++it ) {
251 out+= "<Task " + toString( (*it) ) + " />\n"; 252 out+= "<Task " + toString( (*it) ) + " />\n";
252 QCString cstr = out.utf8(); 253 QCString cstr = out.utf8();
253 written = f.writeBlock( cstr.data(), cstr.length() ); 254 written = f.writeBlock( cstr.data(), cstr.length() );
254 255
255 /* less written then we wanted */ 256 /* less written then we wanted */
256 if ( written != (int)cstr.length() ) { 257 if ( written != (int)cstr.length() ) {
257 f.close(); 258 f.close();
258 QFile::remove( strNewFile ); 259 QFile::remove( strNewFile );
259 return false; 260 return false;
260 } 261 }
261 out = QString::null; 262 out = QString::null;
262 } 263 }
263 264
264 out += "</Tasks>"; 265 out += "</Tasks>";
265 QCString cstr = out.utf8(); 266 QCString cstr = out.utf8();
266 written = f.writeBlock( cstr.data(), cstr.length() ); 267 written = f.writeBlock( cstr.data(), cstr.length() );
267 268
268 if ( written != (int)cstr.length() ) { 269 if ( written != (int)cstr.length() ) {
269 f.close(); 270 f.close();
270 QFile::remove( strNewFile ); 271 QFile::remove( strNewFile );
271 return false; 272 return false;
272 } 273 }
273 /* flush before renaming */ 274 /* flush before renaming */
274 f.close(); 275 f.close();
275 276
276 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { 277 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
277// qWarning("error renaming"); 278// qWarning("error renaming");
278 QFile::remove( strNewFile ); 279 QFile::remove( strNewFile );
279 } 280 }
280 281
281 m_changed = false; 282 m_changed = false;
282 return true; 283 return true;
283} 284}
284QArray<int> OTodoAccessXML::allRecords()const { 285QArray<int> OTodoAccessXML::allRecords()const {
285 QArray<int> ids( m_events.count() ); 286 QArray<int> ids( m_events.count() );
286 QMap<int, OTodo>::ConstIterator it; 287 QMap<int, OTodo>::ConstIterator it;
287 int i = 0; 288 int i = 0;
288 289
289 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 290 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
290 ids[i] = it.key(); 291 ids[i] = it.key();
291 i++; 292 i++;
292 } 293 }
293 return ids; 294 return ids;
294} 295}
295QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int, const QDateTime& ) { 296QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int, const QDateTime& ) {
296 QArray<int> ids(0); 297 QArray<int> ids(0);
297 return ids; 298 return ids;
298} 299}
299OTodo OTodoAccessXML::find( int uid )const { 300OTodo OTodoAccessXML::find( int uid )const {
300 OTodo todo; 301 OTodo todo;
301 todo.setUid( 0 ); // isEmpty() 302 todo.setUid( 0 ); // isEmpty()
302 QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); 303 QMap<int, OTodo>::ConstIterator it = m_events.find( uid );
303 if ( it != m_events.end() ) 304 if ( it != m_events.end() )
304 todo = it.data(); 305 todo = it.data();
305 306
306 return todo; 307 return todo;
307} 308}
308void OTodoAccessXML::clear() { 309void OTodoAccessXML::clear() {
309 if (m_opened ) 310 if (m_opened )
310 m_changed = true; 311 m_changed = true;
311 312
312 m_events.clear(); 313 m_events.clear();
313} 314}
314bool OTodoAccessXML::add( const OTodo& todo ) { 315bool OTodoAccessXML::add( const OTodo& todo ) {
315// qWarning("add"); 316// qWarning("add");
316 m_changed = true; 317 m_changed = true;
317 m_events.insert( todo.uid(), todo ); 318 m_events.insert( todo.uid(), todo );
318 319
319 return true; 320 return true;
320} 321}
321bool OTodoAccessXML::remove( int uid ) { 322bool OTodoAccessXML::remove( int uid ) {
322 m_changed = true; 323 m_changed = true;
323 m_events.remove( uid ); 324 m_events.remove( uid );
324 325
325 return true; 326 return true;
326} 327}
327bool OTodoAccessXML::replace( const OTodo& todo) { 328bool OTodoAccessXML::replace( const OTodo& todo) {
328 m_changed = true; 329 m_changed = true;
329 m_events.replace( todo.uid(), todo ); 330 m_events.replace( todo.uid(), todo );
330 331
331 return true; 332 return true;
332} 333}
333QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, 334QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start,
334 const QDate& end, 335 const QDate& end,
335 bool includeNoDates ) { 336 bool includeNoDates ) {
336 QArray<int> ids( m_events.count() ); 337 QArray<int> ids( m_events.count() );
337 QMap<int, OTodo>::Iterator it; 338 QMap<int, OTodo>::Iterator it;
338 339
339 int i = 0; 340 int i = 0;
340 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 341 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
341 if ( !it.data().hasDueDate() ) { 342 if ( !it.data().hasDueDate() ) {
342 if ( includeNoDates ) { 343 if ( includeNoDates ) {
343 ids[i] = it.key(); 344 ids[i] = it.key();
344 i++; 345 i++;
345 } 346 }
346 }else if ( it.data().dueDate() >= start && 347 }else if ( it.data().dueDate() >= start &&
347 it.data().dueDate() <= end ) { 348 it.data().dueDate() <= end ) {
348 ids[i] = it.key(); 349 ids[i] = it.key();
349 i++; 350 i++;
350 } 351 }
351 } 352 }
352 ids.resize( i ); 353 ids.resize( i );
353 return ids; 354 return ids;
354} 355}
355QArray<int> OTodoAccessXML::overDue() { 356QArray<int> OTodoAccessXML::overDue() {
356 QArray<int> ids( m_events.count() ); 357 QArray<int> ids( m_events.count() );
357 int i = 0; 358 int i = 0;
358 359
359 QMap<int, OTodo>::Iterator it; 360 QMap<int, OTodo>::Iterator it;
360 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 361 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
361 if ( it.data().isOverdue() ) { 362 if ( it.data().isOverdue() ) {
362 ids[i] = it.key(); 363 ids[i] = it.key();
363 i++; 364 i++;
364 } 365 }
365 } 366 }
366 ids.resize( i ); 367 ids.resize( i );
367 return ids; 368 return ids;
368} 369}
369 370
370 371
371/* private */ 372/* private */
372void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, 373void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
373 const QCString& attr, const QString& val) { 374 const QCString& attr, const QString& val) {
374// qWarning("parse to do from XMLElement" ); 375// qWarning("parse to do from XMLElement" );
375 376
376 int *find=0; 377 int *find=0;
377 378
378 find = (*dict)[ attr.data() ]; 379 find = (*dict)[ attr.data() ];
379 if (!find ) { 380 if (!find ) {
380// qWarning("Unknown option" + it.key() ); 381// qWarning("Unknown option" + it.key() );
381 ev.setCustomField( attr, val ); 382 ev.setCustomField( attr, val );
382 return; 383 return;
383 } 384 }
384 385
385 switch( *find ) { 386 switch( *find ) {
386 case OTodo::Uid: 387 case OTodo::Uid:
387 ev.setUid( val.toInt() ); 388 ev.setUid( val.toInt() );
388 break; 389 break;
389 case OTodo::Category: 390 case OTodo::Category:
390 ev.setCategories( ev.idsFromString( val ) ); 391 ev.setCategories( ev.idsFromString( val ) );
391 break; 392 break;
392 case OTodo::HasDate: 393 case OTodo::HasDate:
393 ev.setHasDueDate( val.toInt() ); 394 ev.setHasDueDate( val.toInt() );
394 break; 395 break;
395 case OTodo::Completed: 396 case OTodo::Completed:
396 ev.setCompleted( val.toInt() ); 397 ev.setCompleted( val.toInt() );
397 break; 398 break;
398 case OTodo::Description: 399 case OTodo::Description:
399 ev.setDescription( val ); 400 ev.setDescription( val );
400 break; 401 break;
401 case OTodo::Summary: 402 case OTodo::Summary:
402 ev.setSummary( val ); 403 ev.setSummary( val );
403 break; 404 break;
404 case OTodo::Priority: 405 case OTodo::Priority:
405 ev.setPriority( val.toInt() ); 406 ev.setPriority( val.toInt() );
406 break; 407 break;
407 case OTodo::DateDay: 408 case OTodo::DateDay:
408 m_day = val.toInt(); 409 m_day = val.toInt();
409 break; 410 break;
410 case OTodo::DateMonth: 411 case OTodo::DateMonth:
411 m_month = val.toInt(); 412 m_month = val.toInt();
412 break; 413 break;
413 case OTodo::DateYear: 414 case OTodo::DateYear:
414 m_year = val.toInt(); 415 m_year = val.toInt();
415 break; 416 break;
416 case OTodo::Progress: 417 case OTodo::Progress:
417 ev.setProgress( val.toInt() ); 418 ev.setProgress( val.toInt() );
418 break; 419 break;
419 case OTodo::CompletedDate: 420 case OTodo::CompletedDate:
420 ev.setCompletedDate( OConversion::dateFromString( val ) ); 421 ev.setCompletedDate( OConversion::dateFromString( val ) );
421 break; 422 break;
422 case OTodo::StartDate: 423 case OTodo::StartDate:
423 ev.setStartDate( OConversion::dateFromString( val ) ); 424 ev.setStartDate( OConversion::dateFromString( val ) );
424 break; 425 break;
426 case OTodo::State:
427 ev.setState( val.toInt() );
428 break;
425 case OTodo::CrossReference: 429 case OTodo::CrossReference:
426 { 430 {
427 /* 431 /*
428 * A cross refernce looks like 432 * A cross refernce looks like
429 * appname,id;appname,id 433 * appname,id;appname,id
430 * we need to split it up 434 * we need to split it up
431 */ 435 */
432 QStringList refs = QStringList::split(';', val ); 436 QStringList refs = QStringList::split(';', val );
433 QStringList::Iterator strIt; 437 QStringList::Iterator strIt;
434 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { 438 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
435 int pos = (*strIt).find(','); 439 int pos = (*strIt).find(',');
436 if ( pos > -1 ) 440 if ( pos > -1 )
437 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); 441 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
438 442
439 } 443 }
440 break; 444 break;
441 } 445 }
442 /* Recurrence stuff below + post processing later */ 446 /* Recurrence stuff below + post processing later */
443 case FRType: 447 case FRType:
444 if ( val == "Daily" ) 448 if ( val == "Daily" )
445 recur()->setType( ORecur::Daily ); 449 recur()->setType( ORecur::Daily );
446 else if ( val == "Weekly" ) 450 else if ( val == "Weekly" )
447 recur()->setType( ORecur::Weekly); 451 recur()->setType( ORecur::Weekly);
448 else if ( val == "MonthlyDay" ) 452 else if ( val == "MonthlyDay" )
449 recur()->setType( ORecur::MonthlyDay ); 453 recur()->setType( ORecur::MonthlyDay );
450 else if ( val == "MonthlyDate" ) 454 else if ( val == "MonthlyDate" )
451 recur()->setType( ORecur::MonthlyDate ); 455 recur()->setType( ORecur::MonthlyDate );
452 else if ( val == "Yearly" ) 456 else if ( val == "Yearly" )
453 recur()->setType( ORecur::Yearly ); 457 recur()->setType( ORecur::Yearly );
454 else 458 else
455 recur()->setType( ORecur::NoRepeat ); 459 recur()->setType( ORecur::NoRepeat );
456 break; 460 break;
457 case FRWeekdays: 461 case FRWeekdays:
458 recur()->setDays( val.toInt() ); 462 recur()->setDays( val.toInt() );
459 break; 463 break;
460 case FRPosition: 464 case FRPosition:
461 recur()->setPosition( val.toInt() ); 465 recur()->setPosition( val.toInt() );
462 break; 466 break;
463 case FRFreq: 467 case FRFreq:
464 recur()->setFrequency( val.toInt() ); 468 recur()->setFrequency( val.toInt() );
465 break; 469 break;
466 case FRHasEndDate: 470 case FRHasEndDate:
467 recur()->setHasEndDate( val.toInt() ); 471 recur()->setHasEndDate( val.toInt() );
468 break; 472 break;
469 case FREndDate: { 473 case FREndDate: {
470 rp_end = (time_t) val.toLong(); 474 rp_end = (time_t) val.toLong();
471 break; 475 break;
472 } 476 }
473 default: 477 default:
474 break; 478 break;
475 } 479 }
476} 480}
477QString OTodoAccessXML::toString( const OTodo& ev )const { 481QString OTodoAccessXML::toString( const OTodo& ev )const {
478 QString str; 482 QString str;
479 483
480 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; 484 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
481 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; 485 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" ";
482 str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; 486 str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
483 str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; 487 str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
484 488
485 str += "Categories=\"" + toString( ev.categories() ) + "\" "; 489 str += "Categories=\"" + toString( ev.categories() ) + "\" ";
486 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; 490 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
487 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; 491 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
488 492
489 if ( ev.hasDueDate() ) { 493 if ( ev.hasDueDate() ) {
490 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; 494 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
491 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; 495 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
492 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; 496 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
493 } 497 }
494// qWarning( "Uid %d", ev.uid() ); 498// qWarning( "Uid %d", ev.uid() );
495 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 499 str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
496 500
497// append the extra options 501// append the extra options
498 /* FIXME Qtopia::Record this is currently not 502 /* FIXME Qtopia::Record this is currently not
499 * possible you can set custom fields 503 * possible you can set custom fields
500 * but don' iterate over the list 504 * but don' iterate over the list
501 * I may do #define private protected 505 * I may do #define private protected
502 * for this case - cough --zecke 506 * for this case - cough --zecke
503 */ 507 */
504 /* 508 /*
505 QMap<QString, QString> extras = ev.extras(); 509 QMap<QString, QString> extras = ev.extras();
506 QMap<QString, QString>::Iterator extIt; 510 QMap<QString, QString>::Iterator extIt;
507 for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) 511 for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
508 str += extIt.key() + "=\"" + extIt.data() + "\" "; 512 str += extIt.key() + "=\"" + extIt.data() + "\" ";
509 */ 513 */
510 // cross refernce 514 // cross refernce
511 if ( ev.hasRecurrence() ) { 515 if ( ev.hasRecurrence() ) {
512 str += ev.recurrence().toString(); 516 str += ev.recurrence().toString();
513 } 517 }
514 if ( ev.hasStartDate() ) 518 if ( ev.hasStartDate() )
515 str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; 519 str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" ";
516 if ( ev.hasCompletedDate() ) 520 if ( ev.hasCompletedDate() )
517 str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; 521 str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" ";
522 if ( ev.hasState() )
523 str += "State=\""+QString::number( ev.state().state() )+"\" ";
518 524
519 525
520 return str; 526 return str;
521} 527}
522QString OTodoAccessXML::toString( const QArray<int>& ints ) const { 528QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
523 return Qtopia::Record::idsToString( ints ); 529 return Qtopia::Record::idsToString( ints );
524} 530}
525 531
526/* internal class for sorting 532/* internal class for sorting
527 * 533 *
528 * Inspired by todoxmlio.cpp from TT 534 * Inspired by todoxmlio.cpp from TT
529 */ 535 */
530 536
531struct OTodoXMLContainer { 537struct OTodoXMLContainer {
532 OTodo todo; 538 OTodo todo;
533}; 539};
534 540
535namespace { 541namespace {
536 inline QString string( const OTodo& todo) { 542 inline QString string( const OTodo& todo) {
537 return todo.summary().isEmpty() ? 543 return todo.summary().isEmpty() ?
538 todo.description().left(20 ) : 544 todo.description().left(20 ) :
539 todo.summary(); 545 todo.summary();
540 } 546 }
541 inline int completed( const OTodo& todo1, const OTodo& todo2) { 547 inline int completed( const OTodo& todo1, const OTodo& todo2) {
542 int ret = 0; 548 int ret = 0;
543 if ( todo1.isCompleted() ) ret++; 549 if ( todo1.isCompleted() ) ret++;
544 if ( todo2.isCompleted() ) ret--; 550 if ( todo2.isCompleted() ) ret--;
545 return ret; 551 return ret;
546 } 552 }
547 inline int priority( const OTodo& t1, const OTodo& t2) { 553 inline int priority( const OTodo& t1, const OTodo& t2) {
548 return ( t1.priority() - t2.priority() ); 554 return ( t1.priority() - t2.priority() );
549 } 555 }
550 inline int description( const OTodo& t1, const OTodo& t2) { 556 inline int description( const OTodo& t1, const OTodo& t2) {
551 return QString::compare( string(t1), string(t2) ); 557 return QString::compare( string(t1), string(t2) );
552 } 558 }
553 inline int deadline( const OTodo& t1, const OTodo& t2) { 559 inline int deadline( const OTodo& t1, const OTodo& t2) {
554 int ret = 0; 560 int ret = 0;
555 if ( t1.hasDueDate() && 561 if ( t1.hasDueDate() &&
556 t2.hasDueDate() ) 562 t2.hasDueDate() )
557 ret = t2.dueDate().daysTo( t1.dueDate() ); 563 ret = t2.dueDate().daysTo( t1.dueDate() );
558 else if ( t1.hasDueDate() ) 564 else if ( t1.hasDueDate() )
559 ret = -1; 565 ret = -1;
560 else if ( t2.hasDueDate() ) 566 else if ( t2.hasDueDate() )
561 ret = 1; 567 ret = 1;
562 else 568 else
563 ret = 0; 569 ret = 0;
564 570
565 return ret; 571 return ret;
566 } 572 }
567 573
568}; 574};
569 575
570/* 576/*
571 * Returns: 577 * Returns:
572 * 0 if item1 == item2 578 * 0 if item1 == item2
573 * 579 *
574 * non-zero if item1 != item2 580 * non-zero if item1 != item2
575 * 581 *
576 * This function returns int rather than bool so that reimplementations 582 * This function returns int rather than bool so that reimplementations
577 * can return one of three values and use it to sort by: 583 * can return one of three values and use it to sort by:
578 * 584 *
579 * 0 if item1 == item2 585 * 0 if item1 == item2
580 * 586 *
581 * > 0 (positive integer) if item1 > item2 587 * > 0 (positive integer) if item1 > item2
582 * 588 *
583 * < 0 (negative integer) if item1 < item2 589 * < 0 (negative integer) if item1 < item2
584 * 590 *
585 */ 591 */
586class OTodoXMLVector : public QVector<OTodoXMLContainer> { 592class OTodoXMLVector : public QVector<OTodoXMLContainer> {
587public: 593public:
588 OTodoXMLVector(int size, bool asc, int sort) 594 OTodoXMLVector(int size, bool asc, int sort)
589 : QVector<OTodoXMLContainer>( size ) 595 : QVector<OTodoXMLContainer>( size )
590 { 596 {
591 setAutoDelete( true ); 597 setAutoDelete( true );
592 m_asc = asc; 598 m_asc = asc;
593 m_sort = sort; 599 m_sort = sort;
594 } 600 }
595 /* return the summary/description */ 601 /* return the summary/description */
596 QString string( const OTodo& todo) { 602 QString string( const OTodo& todo) {
597 return todo.summary().isEmpty() ? 603 return todo.summary().isEmpty() ?
598 todo.description().left(20 ) : 604 todo.description().left(20 ) :
599 todo.summary(); 605 todo.summary();
600 } 606 }
601 /** 607 /**
602 * we take the sortorder( switch on it ) 608 * we take the sortorder( switch on it )
603 * 609 *
604 */ 610 */
605 int compareItems( Item d1, Item d2 ) { 611 int compareItems( Item d1, Item d2 ) {
606 bool seComp, sePrio, seDesc, seDeadline; 612 bool seComp, sePrio, seDesc, seDeadline;
607 seComp = sePrio = seDeadline = seDesc = false; 613 seComp = sePrio = seDeadline = seDesc = false;
608 int ret =0; 614 int ret =0;
609 OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1; 615 OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1;
610 OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2; 616 OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2;
611 617
612 /* same item */ 618 /* same item */
613 if ( con1->todo.uid() == con2->todo.uid() ) 619 if ( con1->todo.uid() == con2->todo.uid() )
614 return 0; 620 return 0;
615 621
616 switch ( m_sort ) { 622 switch ( m_sort ) {
617 /* completed */ 623 /* completed */
618 case 0: { 624 case 0: {
619 ret = completed( con1->todo, con2->todo ); 625 ret = completed( con1->todo, con2->todo );
620 seComp = TRUE; 626 seComp = TRUE;
621 break; 627 break;
622 } 628 }
623 /* priority */ 629 /* priority */
624 case 1: { 630 case 1: {
625 ret = priority( con1->todo, con2->todo ); 631 ret = priority( con1->todo, con2->todo );
626 sePrio = TRUE; 632 sePrio = TRUE;
627 break; 633 break;
628 } 634 }
629 /* description */ 635 /* description */
630 case 2: { 636 case 2: {
631 ret = description( con1->todo, con2->todo ); 637 ret = description( con1->todo, con2->todo );
632 seDesc = TRUE; 638 seDesc = TRUE;
633 break; 639 break;
634 } 640 }
635 /* deadline */ 641 /* deadline */
636 case 3: { 642 case 3: {
637 ret = deadline( con1->todo, con2->todo ); 643 ret = deadline( con1->todo, con2->todo );
638 seDeadline = TRUE; 644 seDeadline = TRUE;
639 break; 645 break;
640 } 646 }
641 default: 647 default:
642 ret = 0; 648 ret = 0;
643 break; 649 break;
644 }; 650 };
645 /* 651 /*
646 * FIXME do better sorting if the first sort criteria 652 * FIXME do better sorting if the first sort criteria
647 * ret equals 0 start with complete and so on... 653 * ret equals 0 start with complete and so on...
648 */ 654 */
649 655
650 /* twist it we're not ascending*/ 656 /* twist it we're not ascending*/
651 if (!m_asc) 657 if (!m_asc)
652 ret = ret * -1; 658 ret = ret * -1;
653 659
654 if ( ret ) 660 if ( ret )
655 return ret; 661 return ret;
656 662
657 // default did not gave difference let's try it other way around 663 // default did not gave difference let's try it other way around
658 /* 664 /*
659 * General try if already checked if not test 665 * General try if already checked if not test
660 * and return 666 * and return
661 * 1.Completed 667 * 1.Completed
662 * 2.Priority 668 * 2.Priority
663 * 3.Description 669 * 3.Description
664 * 4.DueDate 670 * 4.DueDate
665 */ 671 */
666 if (!seComp ) { 672 if (!seComp ) {
667 if ( (ret = completed( con1->todo, con2->todo ) ) ) { 673 if ( (ret = completed( con1->todo, con2->todo ) ) ) {
668 if (!m_asc ) ret *= -1; 674 if (!m_asc ) ret *= -1;
669 return ret; 675 return ret;
670 } 676 }
671 } 677 }
672 if (!sePrio ) { 678 if (!sePrio ) {
673 if ( (ret = priority( con1->todo, con2->todo ) ) ) { 679 if ( (ret = priority( con1->todo, con2->todo ) ) ) {
674 if (!m_asc ) ret *= -1; 680 if (!m_asc ) ret *= -1;
675 return ret; 681 return ret;
676 } 682 }
677 } 683 }
678 if (!seDesc ) { 684 if (!seDesc ) {
679 if ( (ret = description(con1->todo, con2->todo ) ) ) { 685 if ( (ret = description(con1->todo, con2->todo ) ) ) {
680 if (!m_asc) ret *= -1; 686 if (!m_asc) ret *= -1;
681 return ret; 687 return ret;
682 } 688 }
683 } 689 }
684 if (!seDeadline) { 690 if (!seDeadline) {
685 if ( (ret = deadline( con1->todo, con2->todo ) ) ) { 691 if ( (ret = deadline( con1->todo, con2->todo ) ) ) {
686 if (!m_asc) ret *= -1; 692 if (!m_asc) ret *= -1;
687 return ret; 693 return ret;
688 } 694 }
689 } 695 }
690 696
691 return 0; 697 return 0;
692 } 698 }
693 private: 699 private:
694 bool m_asc; 700 bool m_asc;
695 int m_sort; 701 int m_sort;
696 702
697}; 703};
698 704
699QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, 705QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
700 int sortFilter, int cat ) { 706 int sortFilter, int cat ) {
701 qWarning("sorted! %d cat", cat); 707 qWarning("sorted! %d cat", cat);
702 OTodoXMLVector vector(m_events.count(), asc,sortOrder ); 708 OTodoXMLVector vector(m_events.count(), asc,sortOrder );
703 QMap<int, OTodo>::Iterator it; 709 QMap<int, OTodo>::Iterator it;
704 int item = 0; 710 int item = 0;
705 711
706 bool bCat = sortFilter & 1 ? true : false; 712 bool bCat = sortFilter & 1 ? true : false;
707 bool bOnly = sortFilter & 2 ? true : false; 713 bool bOnly = sortFilter & 2 ? true : false;
708 bool comp = sortFilter & 4 ? true : false; 714 bool comp = sortFilter & 4 ? true : false;
709 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 715 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
710 716
711 /* show category */ 717 /* show category */
712 if ( bCat && cat != 0) 718 if ( bCat && cat != 0)
713 if (!(*it).categories().contains( cat ) ) { 719 if (!(*it).categories().contains( cat ) ) {
714 qWarning("category mis match"); 720 qWarning("category mis match");
715 continue; 721 continue;
716 } 722 }
717 /* isOverdue but we should not show overdue - why?*/ 723 /* isOverdue but we should not show overdue - why?*/
718/* if ( (*it).isOverdue() && !bOnly ) { 724/* if ( (*it).isOverdue() && !bOnly ) {
719 qWarning("item is overdue but !bOnly"); 725 qWarning("item is overdue but !bOnly");
720 continue; 726 continue;
721 } 727 }
722*/ 728*/
723 if ( !(*it).isOverdue() && bOnly ) { 729 if ( !(*it).isOverdue() && bOnly ) {
724 qWarning("item is not overdue but bOnly checked"); 730 qWarning("item is not overdue but bOnly checked");
725 continue; 731 continue;
726 } 732 }
727 733
728 if ((*it).isCompleted() && comp ) { 734 if ((*it).isCompleted() && comp ) {
729 qWarning("completed continue!"); 735 qWarning("completed continue!");
730 continue; 736 continue;
731 } 737 }
732 738
733 739
734 OTodoXMLContainer* con = new OTodoXMLContainer(); 740 OTodoXMLContainer* con = new OTodoXMLContainer();
735 con->todo = (*it); 741 con->todo = (*it);
736 vector.insert(item, con ); 742 vector.insert(item, con );
737 item++; 743 item++;
738 } 744 }
739 qWarning("XXX %d Items added", item); 745 qWarning("XXX %d Items added", item);
740 vector.resize( item ); 746 vector.resize( item );
741 /* sort it now */ 747 /* sort it now */
742 vector.sort(); 748 vector.sort();
743 /* now get the uids */ 749 /* now get the uids */
744 QArray<int> array( vector.count() ); 750 QArray<int> array( vector.count() );
745 for (uint i= 0; i < vector.count(); i++ ) { 751 for (uint i= 0; i < vector.count(); i++ ) {
746 array[i] = ( vector.at(i) )->todo.uid(); 752 array[i] = ( vector.at(i) )->todo.uid();
747 } 753 }
748 return array; 754 return array;
749}; 755};
750void OTodoAccessXML::removeAllCompleted() { 756void OTodoAccessXML::removeAllCompleted() {
751 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { 757 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
752 if ( (*it).isCompleted() ) 758 if ( (*it).isCompleted() )
753 m_events.remove( it ); 759 m_events.remove( it );
754 } 760 }
755} 761}
756QBitArray OTodoAccessXML::supports()const { 762QBitArray OTodoAccessXML::supports()const {
757 static QBitArray ar = sup(); 763 static QBitArray ar = sup();
758 return ar; 764 return ar;
759} 765}
760QBitArray OTodoAccessXML::sup() { 766QBitArray OTodoAccessXML::sup() {
761 QBitArray ar( OTodo::CompletedDate +1 ); 767 QBitArray ar( OTodo::CompletedDate +1 );
762 ar.fill( true ); 768 ar.fill( true );
763 ar[OTodo::CrossReference] = false; 769 ar[OTodo::CrossReference] = false;
764 ar[OTodo::State ] = false; 770 ar[OTodo::State ] = false;
765 ar[OTodo::Reminders] = false; 771 ar[OTodo::Reminders] = false;
766 ar[OTodo::Notifiers] = false; 772 ar[OTodo::Notifiers] = false;
767 ar[OTodo::Maintainer] = false; 773 ar[OTodo::Maintainer] = false;
768 774
769 return ar; 775 return ar;
770} 776}