Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessxml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 191 |
1 files changed, 98 insertions, 93 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index cce6111..3e06d88 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -17,48 +17,53 @@ | |||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
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 | |||
30 | /* OPIE */ | ||
31 | #include <opie2/opimdateconversion.h> | ||
32 | #include <opie2/opimstate.h> | ||
33 | #include <opie2/opimtimezone.h> | ||
34 | #include <opie2/opimnotifymanager.h> | ||
35 | #include <opie2/opimrecurrence.h> | ||
36 | #include <opie2/otodoaccessxml.h> | ||
37 | #include <opie2/odebug.h> | ||
38 | |||
39 | #include <qpe/global.h> | ||
40 | #include <qpe/stringutil.h> | ||
41 | #include <qpe/timeconversion.h> | ||
42 | |||
43 | /* QT */ | ||
44 | #include <qfile.h> | ||
45 | #include <qvector.h> | ||
46 | |||
47 | /* STD */ | ||
29 | #include <errno.h> | 48 | #include <errno.h> |
30 | #include <fcntl.h> | 49 | #include <fcntl.h> |
31 | 50 | ||
32 | #include <sys/mman.h> | 51 | #include <sys/mman.h> |
33 | #include <sys/stat.h> | 52 | #include <sys/stat.h> |
34 | #include <sys/types.h> | 53 | #include <sys/types.h> |
35 | 54 | ||
36 | #include <unistd.h> | 55 | #include <unistd.h> |
37 | 56 | ||
38 | 57 | ||
39 | #include <qfile.h> | ||
40 | #include <qvector.h> | ||
41 | |||
42 | #include <qpe/global.h> | ||
43 | #include <qpe/stringutil.h> | ||
44 | #include <qpe/timeconversion.h> | ||
45 | |||
46 | #include <opie2/opimdateconversion.h> | ||
47 | #include <opie2/opimstate.h> | ||
48 | #include <opie2/opimtimezone.h> | ||
49 | #include <opie2/opimnotifymanager.h> | ||
50 | #include <opie2/opimrecurrence.h> | ||
51 | #include <opie2/otodoaccessxml.h> | ||
52 | |||
53 | using namespace Opie; | 58 | using namespace Opie; |
54 | 59 | ||
55 | namespace { | 60 | namespace { |
56 | time_t rp_end; | 61 | time_t rp_end; |
57 | OPimRecurrence* rec; | 62 | OPimRecurrence* rec; |
58 | OPimRecurrence *recur() { | 63 | OPimRecurrence *recur() { |
59 | if (!rec ) rec = new OPimRecurrence; | 64 | if (!rec ) rec = new OPimRecurrence; |
60 | return rec; | 65 | return rec; |
61 | } | 66 | } |
62 | int snd; | 67 | int snd; |
63 | enum MoreAttributes { | 68 | enum MoreAttributes { |
64 | FRType = OPimTodo::CompletedDate + 2, | 69 | FRType = OPimTodo::CompletedDate + 2, |
@@ -67,39 +72,39 @@ namespace { | |||
67 | FRFreq, | 72 | FRFreq, |
68 | FRHasEndDate, | 73 | FRHasEndDate, |
69 | FREndDate, | 74 | FREndDate, |
70 | FRStart, | 75 | FRStart, |
71 | FREnd | 76 | FREnd |
72 | }; | 77 | }; |
73 | // FROM TT again | 78 | // FROM TT again |
74 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | 79 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) |
75 | { | 80 | { |
76 | char needleChar; | 81 | char needleChar; |
77 | char haystackChar; | 82 | char haystackChar; |
78 | if (!needle || !haystack || !hLen || !nLen) | 83 | if (!needle || !haystack || !hLen || !nLen) |
79 | return 0; | 84 | return 0; |
80 | 85 | ||
81 | const char* hsearch = haystack; | 86 | const char* hsearch = haystack; |
82 | 87 | ||
83 | if ((needleChar = *needle++) != 0) { | 88 | if ((needleChar = *needle++) != 0) { |
84 | nLen--; //(to make up for needle++) | 89 | nLen--; //(to make up for needle++) |
85 | do { | 90 | do { |
86 | do { | 91 | do { |
87 | if ((haystackChar = *hsearch++) == 0) | 92 | if ((haystackChar = *hsearch++) == 0) |
88 | return (0); | 93 | return (0); |
89 | if (hsearch >= haystack + hLen) | 94 | if (hsearch >= haystack + hLen) |
90 | return (0); | 95 | return (0); |
91 | } while (haystackChar != needleChar); | 96 | } while (haystackChar != needleChar); |
92 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | 97 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); |
93 | hsearch--; | 98 | hsearch--; |
94 | } | 99 | } |
95 | return ((char *)hsearch); | 100 | return ((char *)hsearch); |
96 | } | 101 | } |
97 | } | 102 | } |
98 | 103 | ||
99 | namespace Opie { | 104 | namespace Opie { |
100 | 105 | ||
101 | OPimTodoAccessXML::OPimTodoAccessXML( const QString& appName, | 106 | OPimTodoAccessXML::OPimTodoAccessXML( const QString& appName, |
102 | const QString& fileName ) | 107 | const QString& fileName ) |
103 | : OPimTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) | 108 | : OPimTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) |
104 | { | 109 | { |
105 | if (!fileName.isEmpty() ) | 110 | if (!fileName.isEmpty() ) |
@@ -168,114 +173,114 @@ bool OPimTodoAccessXML::load() { | |||
168 | /* we do not the file any more */ | 173 | /* we do not the file any more */ |
169 | ::close( fd ); | 174 | ::close( fd ); |
170 | 175 | ||
171 | char* dt = (char*)map_addr; | 176 | char* dt = (char*)map_addr; |
172 | int len = attribut.st_size; | 177 | int len = attribut.st_size; |
173 | int i = 0; | 178 | int i = 0; |
174 | char *point; | 179 | char *point; |
175 | const char* collectionString = "<Task "; | 180 | const char* collectionString = "<Task "; |
176 | int strLen = strlen(collectionString); | 181 | int strLen = strlen(collectionString); |
177 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { | 182 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { |
178 | i = point -dt; | 183 | i = point -dt; |
179 | i+= strLen; | 184 | i+= strLen; |
180 | qWarning("Found a start at %d %d", i, (point-dt) ); | 185 | owarn << "Found a start at " << i << " " << (point-dt) << "" << oendl; |
181 | 186 | ||
182 | OPimTodo ev; | 187 | OPimTodo ev; |
183 | m_year = m_month = m_day = 0; | 188 | m_year = m_month = m_day = 0; |
184 | 189 | ||
185 | while ( TRUE ) { | 190 | while ( TRUE ) { |
186 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) | 191 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) |
187 | ++i; | 192 | ++i; |
188 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) | 193 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) |
189 | break; | 194 | break; |
190 | 195 | ||
191 | // we have another attribute, read it. | 196 | // we have another attribute, read it. |
192 | int j = i; | 197 | int j = i; |
193 | while ( j < len && dt[j] != '=' ) | 198 | while ( j < len && dt[j] != '=' ) |
194 | ++j; | 199 | ++j; |
195 | QCString attr( dt+i, j-i+1); | 200 | QCString attr( dt+i, j-i+1); |
196 | 201 | ||
197 | i = ++j; // skip = | 202 | i = ++j; // skip = |
198 | 203 | ||
199 | // find the start of quotes | 204 | // find the start of quotes |
200 | while ( i < len && dt[i] != '"' ) | 205 | while ( i < len && dt[i] != '"' ) |
201 | ++i; | 206 | ++i; |
202 | j = ++i; | 207 | j = ++i; |
203 | 208 | ||
204 | bool haveUtf = FALSE; | 209 | bool haveUtf = FALSE; |
205 | bool haveEnt = FALSE; | 210 | bool haveEnt = FALSE; |
206 | while ( j < len && dt[j] != '"' ) { | 211 | while ( j < len && dt[j] != '"' ) { |
207 | if ( ((unsigned char)dt[j]) > 0x7f ) | 212 | if ( ((unsigned char)dt[j]) > 0x7f ) |
208 | haveUtf = TRUE; | 213 | haveUtf = TRUE; |
209 | if ( dt[j] == '&' ) | 214 | if ( dt[j] == '&' ) |
210 | haveEnt = TRUE; | 215 | haveEnt = TRUE; |
211 | ++j; | 216 | ++j; |
212 | } | 217 | } |
213 | if ( i == j ) { | 218 | if ( i == j ) { |
214 | // empty value | 219 | // empty value |
215 | i = j + 1; | 220 | i = j + 1; |
216 | continue; | 221 | continue; |
217 | } | 222 | } |
218 | 223 | ||
219 | QCString value( dt+i, j-i+1 ); | 224 | QCString value( dt+i, j-i+1 ); |
220 | i = j + 1; | 225 | i = j + 1; |
221 | 226 | ||
222 | QString str = (haveUtf ? QString::fromUtf8( value ) | 227 | QString str = (haveUtf ? QString::fromUtf8( value ) |
223 | : QString::fromLatin1( value ) ); | 228 | : QString::fromLatin1( value ) ); |
224 | if ( haveEnt ) | 229 | if ( haveEnt ) |
225 | str = Qtopia::plainString( str ); | 230 | str = Qtopia::plainString( str ); |
226 | 231 | ||
227 | /* | 232 | /* |
228 | * add key + value | 233 | * add key + value |
229 | */ | 234 | */ |
230 | todo( &dict, ev, attr, str ); | 235 | todo( &dict, ev, attr, str ); |
231 | 236 | ||
232 | } | 237 | } |
233 | /* | 238 | /* |
234 | * now add it | 239 | * now add it |
235 | */ | 240 | */ |
236 | qWarning("End at %d", i ); | 241 | owarn << "End at " << i << "" << oendl; |
237 | if (m_events.contains( ev.uid() ) || ev.uid() == 0) { | 242 | if (m_events.contains( ev.uid() ) || ev.uid() == 0) { |
238 | ev.setUid( 1 ); | 243 | ev.setUid( 1 ); |
239 | m_changed = true; | 244 | m_changed = true; |
240 | } | 245 | } |
241 | if ( ev.hasDueDate() ) { | 246 | if ( ev.hasDueDate() ) { |
242 | ev.setDueDate( QDate(m_year, m_month, m_day) ); | 247 | ev.setDueDate( QDate(m_year, m_month, m_day) ); |
243 | } | 248 | } |
244 | if ( rec && rec->doesRecur() ) { | 249 | if ( rec && rec->doesRecur() ) { |
245 | OPimTimeZone utc = OPimTimeZone::utc(); | 250 | OPimTimeZone utc = OPimTimeZone::utc(); |
246 | OPimRecurrence recu( *rec ); // call copy c'tor | 251 | OPimRecurrence recu( *rec ); // call copy c'tor |
247 | recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); | 252 | recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); |
248 | recu.setStart( ev.dueDate() ); | 253 | recu.setStart( ev.dueDate() ); |
249 | ev.setRecurrence( recu ); | 254 | ev.setRecurrence( recu ); |
250 | } | 255 | } |
251 | m_events.insert(ev.uid(), ev ); | 256 | m_events.insert(ev.uid(), ev ); |
252 | m_year = m_month = m_day = -1; | 257 | m_year = m_month = m_day = -1; |
253 | delete rec; | 258 | delete rec; |
254 | rec = 0; | 259 | rec = 0; |
255 | } | 260 | } |
256 | 261 | ||
257 | munmap(map_addr, attribut.st_size ); | 262 | munmap(map_addr, attribut.st_size ); |
258 | 263 | ||
259 | qWarning("counts %d records loaded!", m_events.count() ); | 264 | owarn << "counts " << m_events.count() << " records loaded!" << oendl; |
260 | return true; | 265 | return true; |
261 | } | 266 | } |
262 | bool OPimTodoAccessXML::reload() { | 267 | bool OPimTodoAccessXML::reload() { |
263 | m_events.clear(); | 268 | m_events.clear(); |
264 | return load(); | 269 | return load(); |
265 | } | 270 | } |
266 | bool OPimTodoAccessXML::save() { | 271 | bool OPimTodoAccessXML::save() { |
267 | // qWarning("saving"); | 272 | // owarn << "saving" << oendl; |
268 | if (!m_opened || !m_changed ) { | 273 | if (!m_opened || !m_changed ) { |
269 | // qWarning("not saving"); | 274 | // owarn << "not saving" << oendl; |
270 | return true; | 275 | return true; |
271 | } | 276 | } |
272 | QString strNewFile = m_file + ".new"; | 277 | QString strNewFile = m_file + ".new"; |
273 | QFile f( strNewFile ); | 278 | QFile f( strNewFile ); |
274 | if (!f.open( IO_WriteOnly|IO_Raw ) ) | 279 | if (!f.open( IO_WriteOnly|IO_Raw ) ) |
275 | return false; | 280 | return false; |
276 | 281 | ||
277 | int written; | 282 | int written; |
278 | QString out; | 283 | QString out; |
279 | out = "<!DOCTYPE Tasks>\n<Tasks>\n"; | 284 | out = "<!DOCTYPE Tasks>\n<Tasks>\n"; |
280 | 285 | ||
281 | // for all todos | 286 | // for all todos |
@@ -298,25 +303,25 @@ bool OPimTodoAccessXML::save() { | |||
298 | QCString cstr = out.utf8(); | 303 | QCString cstr = out.utf8(); |
299 | written = f.writeBlock( cstr.data(), cstr.length() ); | 304 | written = f.writeBlock( cstr.data(), cstr.length() ); |
300 | 305 | ||
301 | if ( written != (int)cstr.length() ) { | 306 | if ( written != (int)cstr.length() ) { |
302 | f.close(); | 307 | f.close(); |
303 | QFile::remove( strNewFile ); | 308 | QFile::remove( strNewFile ); |
304 | return false; | 309 | return false; |
305 | } | 310 | } |
306 | /* flush before renaming */ | 311 | /* flush before renaming */ |
307 | f.close(); | 312 | f.close(); |
308 | 313 | ||
309 | if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { | 314 | if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { |
310 | // qWarning("error renaming"); | 315 | // owarn << "error renaming" << oendl; |
311 | QFile::remove( strNewFile ); | 316 | QFile::remove( strNewFile ); |
312 | } | 317 | } |
313 | 318 | ||
314 | m_changed = false; | 319 | m_changed = false; |
315 | return true; | 320 | return true; |
316 | } | 321 | } |
317 | QArray<int> OPimTodoAccessXML::allRecords()const { | 322 | QArray<int> OPimTodoAccessXML::allRecords()const { |
318 | QArray<int> ids( m_events.count() ); | 323 | QArray<int> ids( m_events.count() ); |
319 | QMap<int, OPimTodo>::ConstIterator it; | 324 | QMap<int, OPimTodo>::ConstIterator it; |
320 | int i = 0; | 325 | int i = 0; |
321 | 326 | ||
322 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 327 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
@@ -336,25 +341,25 @@ OPimTodo OPimTodoAccessXML::find( int uid )const { | |||
336 | if ( it != m_events.end() ) | 341 | if ( it != m_events.end() ) |
337 | todo = it.data(); | 342 | todo = it.data(); |
338 | 343 | ||
339 | return todo; | 344 | return todo; |
340 | } | 345 | } |
341 | void OPimTodoAccessXML::clear() { | 346 | void OPimTodoAccessXML::clear() { |
342 | if (m_opened ) | 347 | if (m_opened ) |
343 | m_changed = true; | 348 | m_changed = true; |
344 | 349 | ||
345 | m_events.clear(); | 350 | m_events.clear(); |
346 | } | 351 | } |
347 | bool OPimTodoAccessXML::add( const OPimTodo& todo ) { | 352 | bool OPimTodoAccessXML::add( const OPimTodo& todo ) { |
348 | // qWarning("add"); | 353 | // owarn << "add" << oendl; |
349 | m_changed = true; | 354 | m_changed = true; |
350 | m_events.insert( todo.uid(), todo ); | 355 | m_events.insert( todo.uid(), todo ); |
351 | 356 | ||
352 | return true; | 357 | return true; |
353 | } | 358 | } |
354 | bool OPimTodoAccessXML::remove( int uid ) { | 359 | bool OPimTodoAccessXML::remove( int uid ) { |
355 | m_changed = true; | 360 | m_changed = true; |
356 | m_events.remove( uid ); | 361 | m_events.remove( uid ); |
357 | 362 | ||
358 | return true; | 363 | return true; |
359 | } | 364 | } |
360 | bool OPimTodoAccessXML::replace( const OPimTodo& todo) { | 365 | bool OPimTodoAccessXML::replace( const OPimTodo& todo) { |
@@ -395,31 +400,31 @@ QArray<int> OPimTodoAccessXML::overDue() { | |||
395 | ids[i] = it.key(); | 400 | ids[i] = it.key(); |
396 | i++; | 401 | i++; |
397 | } | 402 | } |
398 | } | 403 | } |
399 | ids.resize( i ); | 404 | ids.resize( i ); |
400 | return ids; | 405 | return ids; |
401 | } | 406 | } |
402 | 407 | ||
403 | 408 | ||
404 | /* private */ | 409 | /* private */ |
405 | void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, | 410 | void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, |
406 | const QCString& attr, const QString& val) { | 411 | const QCString& attr, const QString& val) { |
407 | // qWarning("parse to do from XMLElement" ); | 412 | // owarn << "parse to do from XMLElement" << oendl; |
408 | 413 | ||
409 | int *find=0; | 414 | int *find=0; |
410 | 415 | ||
411 | find = (*dict)[ attr.data() ]; | 416 | find = (*dict)[ attr.data() ]; |
412 | if (!find ) { | 417 | if (!find ) { |
413 | // qWarning("Unknown option" + it.key() ); | 418 | // owarn << "Unknown option" + it.key() << oendl; |
414 | ev.setCustomField( attr, val ); | 419 | ev.setCustomField( attr, val ); |
415 | return; | 420 | return; |
416 | } | 421 | } |
417 | 422 | ||
418 | switch( *find ) { | 423 | switch( *find ) { |
419 | case OPimTodo::Uid: | 424 | case OPimTodo::Uid: |
420 | ev.setUid( val.toInt() ); | 425 | ev.setUid( val.toInt() ); |
421 | break; | 426 | break; |
422 | case OPimTodo::Category: | 427 | case OPimTodo::Category: |
423 | ev.setCategories( ev.idsFromString( val ) ); | 428 | ev.setCategories( ev.idsFromString( val ) ); |
424 | break; | 429 | break; |
425 | case OPimTodo::HasDate: | 430 | case OPimTodo::HasDate: |
@@ -454,26 +459,26 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, | |||
454 | break; | 459 | break; |
455 | case OPimTodo::StartDate: | 460 | case OPimTodo::StartDate: |
456 | ev.setStartDate( OPimDateConversion::dateFromString( val ) ); | 461 | ev.setStartDate( OPimDateConversion::dateFromString( val ) ); |
457 | break; | 462 | break; |
458 | case OPimTodo::State: | 463 | case OPimTodo::State: |
459 | ev.setState( val.toInt() ); | 464 | ev.setState( val.toInt() ); |
460 | break; | 465 | break; |
461 | case OPimTodo::Alarms:{ | 466 | case OPimTodo::Alarms:{ |
462 | OPimNotifyManager &manager = ev.notifiers(); | 467 | OPimNotifyManager &manager = ev.notifiers(); |
463 | QStringList als = QStringList::split(";", val ); | 468 | QStringList als = QStringList::split(";", val ); |
464 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | 469 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { |
465 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | 470 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty |
466 | qWarning("alarm: %s", alarm.join("___").latin1() ); | 471 | owarn << "alarm: " << alarm.join("___") << "" << oendl; |
467 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), OPimDateConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); | 472 | owarn << "alarm[0]: " << alarm[0] << " " << OPimDateConversion::dateTimeFromString( alarm[0] ).toString() << "" << oendl; |
468 | OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); | 473 | OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); |
469 | manager.add( al ); | 474 | manager.add( al ); |
470 | } | 475 | } |
471 | } | 476 | } |
472 | break; | 477 | break; |
473 | case OPimTodo::Reminders:{ | 478 | case OPimTodo::Reminders:{ |
474 | OPimNotifyManager &manager = ev.notifiers(); | 479 | OPimNotifyManager &manager = ev.notifiers(); |
475 | QStringList rems = QStringList::split(";", val ); | 480 | QStringList rems = QStringList::split(";", val ); |
476 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | 481 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { |
477 | OPimReminder rem( (*it).toInt() ); | 482 | OPimReminder rem( (*it).toInt() ); |
478 | manager.add( rem ); | 483 | manager.add( rem ); |
479 | } | 484 | } |
@@ -528,58 +533,58 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, | |||
528 | break; | 533 | break; |
529 | } | 534 | } |
530 | default: | 535 | default: |
531 | ev.setCustomField( attr, val ); | 536 | ev.setCustomField( attr, val ); |
532 | break; | 537 | break; |
533 | } | 538 | } |
534 | } | 539 | } |
535 | 540 | ||
536 | // from PalmtopRecord... GPL ### FIXME | 541 | // from PalmtopRecord... GPL ### FIXME |
537 | namespace { | 542 | namespace { |
538 | QString customToXml(const QMap<QString, QString>& customMap ) | 543 | QString customToXml(const QMap<QString, QString>& customMap ) |
539 | { | 544 | { |
540 | //qWarning(QString("writing custom %1").arg(customMap.count())); | 545 | //owarn << QString("writing custom %1").arg(customMap.count()) << oendl; |
541 | QString buf(" "); | 546 | QString buf(" "); |
542 | for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); | 547 | for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); |
543 | cit != customMap.end(); ++cit) { | 548 | cit != customMap.end(); ++cit) { |
544 | // qWarning(".ITEM."); | 549 | // owarn << ".ITEM." << oendl; |
545 | buf += cit.key(); | 550 | buf += cit.key(); |
546 | buf += "=\""; | 551 | buf += "=\""; |
547 | buf += Qtopia::escapeString(cit.data()); | 552 | buf += Qtopia::escapeString(cit.data()); |
548 | buf += "\" "; | 553 | buf += "\" "; |
549 | } | 554 | } |
550 | return buf; | 555 | return buf; |
551 | } | 556 | } |
552 | 557 | ||
553 | 558 | ||
554 | } | 559 | } |
555 | 560 | ||
556 | QString OPimTodoAccessXML::toString( const OPimTodo& ev )const { | 561 | QString OPimTodoAccessXML::toString( const OPimTodo& ev )const { |
557 | QString str; | 562 | QString str; |
558 | 563 | ||
559 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; | 564 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; |
560 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; | 565 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; |
561 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; | 566 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; |
562 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; | 567 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; |
563 | 568 | ||
564 | str += "Categories=\"" + toString( ev.categories() ) + "\" "; | 569 | str += "Categories=\"" + toString( ev.categories() ) + "\" "; |
565 | str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; | 570 | str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; |
566 | str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; | 571 | str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; |
567 | 572 | ||
568 | if ( ev.hasDueDate() ) { | 573 | if ( ev.hasDueDate() ) { |
569 | str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; | 574 | str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; |
570 | str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; | 575 | str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; |
571 | str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; | 576 | str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; |
572 | } | 577 | } |
573 | // qWarning( "Uid %d", ev.uid() ); | 578 | // owarn << "Uid " << ev.uid() << "" << oendl; |
574 | str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; | 579 | str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; |
575 | 580 | ||
576 | // append the extra options | 581 | // append the extra options |
577 | /* FIXME Qtopia::Record this is currently not | 582 | /* FIXME Qtopia::Record this is currently not |
578 | * possible you can set custom fields | 583 | * possible you can set custom fields |
579 | * but don' iterate over the list | 584 | * but don' iterate over the list |
580 | * I may do #define private protected | 585 | * I may do #define private protected |
581 | * for this case - cough --zecke | 586 | * for this case - cough --zecke |
582 | */ | 587 | */ |
583 | /* | 588 | /* |
584 | QMap<QString, QString> extras = ev.extras(); | 589 | QMap<QString, QString> extras = ev.extras(); |
585 | QMap<QString, QString>::Iterator extIt; | 590 | QMap<QString, QString>::Iterator extIt; |
@@ -608,25 +613,25 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const { | |||
608 | QStringList als; | 613 | QStringList als; |
609 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | 614 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); |
610 | for ( ; it != alarms.end(); ++it ) { | 615 | for ( ; it != alarms.end(); ++it ) { |
611 | /* only if time is valid */ | 616 | /* only if time is valid */ |
612 | if ( (*it).dateTime().isValid() ) { | 617 | if ( (*it).dateTime().isValid() ) { |
613 | als << OPimDateConversion::dateTimeToString( (*it).dateTime() ) | 618 | als << OPimDateConversion::dateTimeToString( (*it).dateTime() ) |
614 | + ":" + QString::number( (*it).duration() ) | 619 | + ":" + QString::number( (*it).duration() ) |
615 | + ":" + QString::number( (*it).sound() ) | 620 | + ":" + QString::number( (*it).sound() ) |
616 | + ":"; | 621 | + ":"; |
617 | } | 622 | } |
618 | } | 623 | } |
619 | // now write the list | 624 | // now write the list |
620 | qWarning("als: %s", als.join("____________").latin1() ); | 625 | owarn << "als: " << als.join("____________") << "" << oendl; |
621 | str += "Alarms=\""+als.join(";") +"\" "; | 626 | str += "Alarms=\""+als.join(";") +"\" "; |
622 | } | 627 | } |
623 | 628 | ||
624 | /* | 629 | /* |
625 | * now the same for reminders but more easy. We just save the uid of the OPimEvent. | 630 | * now the same for reminders but more easy. We just save the uid of the OPimEvent. |
626 | */ | 631 | */ |
627 | OPimNotifyManager::Reminders reminders = manager.reminders(); | 632 | OPimNotifyManager::Reminders reminders = manager.reminders(); |
628 | if (!reminders.isEmpty() ) { | 633 | if (!reminders.isEmpty() ) { |
629 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | 634 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); |
630 | QStringList records; | 635 | QStringList records; |
631 | for ( ; it != reminders.end(); ++it ) { | 636 | for ( ; it != reminders.end(); ++it ) { |
632 | records << QString::number( (*it).recordUid() ); | 637 | records << QString::number( (*it).recordUid() ); |
@@ -829,25 +834,25 @@ QArray<int> OPimTodoAccessXML::sorted( bool asc, int sortOrder, | |||
829 | 834 | ||
830 | /* show category */ | 835 | /* show category */ |
831 | /* -1 == unfiled */ | 836 | /* -1 == unfiled */ |
832 | if ( bCat && cat == -1 ) { | 837 | if ( bCat && cat == -1 ) { |
833 | if(!(*it).categories().isEmpty() ) | 838 | if(!(*it).categories().isEmpty() ) |
834 | continue; | 839 | continue; |
835 | }else if ( bCat && cat != 0) | 840 | }else if ( bCat && cat != 0) |
836 | if (!(*it).categories().contains( cat ) ) { | 841 | if (!(*it).categories().contains( cat ) ) { |
837 | continue; | 842 | continue; |
838 | } | 843 | } |
839 | /* isOverdue but we should not show overdue - why?*/ | 844 | /* isOverdue but we should not show overdue - why?*/ |
840 | /* if ( (*it).isOverdue() && !bOnly ) { | 845 | /* if ( (*it).isOverdue() && !bOnly ) { |
841 | qWarning("item is overdue but !bOnly"); | 846 | owarn << "item is overdue but !bOnly" << oendl; |
842 | continue; | 847 | continue; |
843 | } | 848 | } |
844 | */ | 849 | */ |
845 | if ( !(*it).isOverdue() && bOnly ) { | 850 | if ( !(*it).isOverdue() && bOnly ) { |
846 | continue; | 851 | continue; |
847 | } | 852 | } |
848 | 853 | ||
849 | if ((*it).isCompleted() && comp ) { | 854 | if ((*it).isCompleted() && comp ) { |
850 | continue; | 855 | continue; |
851 | } | 856 | } |
852 | 857 | ||
853 | 858 | ||
@@ -882,28 +887,28 @@ QBitArray OPimTodoAccessXML::sup() { | |||
882 | QBitArray ar( OPimTodo::CompletedDate +1 ); | 887 | QBitArray ar( OPimTodo::CompletedDate +1 ); |
883 | ar.fill( true ); | 888 | ar.fill( true ); |
884 | ar[OPimTodo::CrossReference] = false; | 889 | ar[OPimTodo::CrossReference] = false; |
885 | ar[OPimTodo::State ] = false; | 890 | ar[OPimTodo::State ] = false; |
886 | ar[OPimTodo::Reminders] = false; | 891 | ar[OPimTodo::Reminders] = false; |
887 | ar[OPimTodo::Notifiers] = false; | 892 | ar[OPimTodo::Notifiers] = false; |
888 | ar[OPimTodo::Maintainer] = false; | 893 | ar[OPimTodo::Maintainer] = false; |
889 | 894 | ||
890 | return ar; | 895 | return ar; |
891 | } | 896 | } |
892 | QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const | 897 | QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const |
893 | { | 898 | { |
894 | QArray<int> m_currentQuery( m_events.count() ); | 899 | QArray<int> m_currentQuery( m_events.count() ); |
895 | uint arraycounter = 0; | 900 | uint arraycounter = 0; |
896 | 901 | ||
897 | QMap<int, OPimTodo>::ConstIterator it; | 902 | QMap<int, OPimTodo>::ConstIterator it; |
898 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | 903 | for (it = m_events.begin(); it != m_events.end(); ++it ) { |
899 | if ( it.data().match( r ) ) | 904 | if ( it.data().match( r ) ) |
900 | m_currentQuery[arraycounter++] = it.data().uid(); | 905 | m_currentQuery[arraycounter++] = it.data().uid(); |
901 | 906 | ||
902 | } | 907 | } |
903 | // Shrink to fit.. | 908 | // Shrink to fit.. |
904 | m_currentQuery.resize(arraycounter); | 909 | m_currentQuery.resize(arraycounter); |
905 | 910 | ||
906 | return m_currentQuery; | 911 | return m_currentQuery; |
907 | } | 912 | } |
908 | 913 | ||
909 | } | 914 | } |