Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessxml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 228 |
1 files changed, 114 insertions, 114 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 2d50ecd..cce6111 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -34,43 +34,43 @@ | |||
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | 35 | ||
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | 37 | ||
38 | 38 | ||
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qvector.h> | 40 | #include <qvector.h> |
41 | 41 | ||
42 | #include <qpe/global.h> | 42 | #include <qpe/global.h> |
43 | #include <qpe/stringutil.h> | 43 | #include <qpe/stringutil.h> |
44 | #include <qpe/timeconversion.h> | 44 | #include <qpe/timeconversion.h> |
45 | 45 | ||
46 | #include <opie2/oconversion.h> | 46 | #include <opie2/opimdateconversion.h> |
47 | #include <opie2/opimstate.h> | 47 | #include <opie2/opimstate.h> |
48 | #include <opie2/otimezone.h> | 48 | #include <opie2/opimtimezone.h> |
49 | #include <opie2/opimnotifymanager.h> | 49 | #include <opie2/opimnotifymanager.h> |
50 | #include <opie2/orecur.h> | 50 | #include <opie2/opimrecurrence.h> |
51 | #include <opie2/otodoaccessxml.h> | 51 | #include <opie2/otodoaccessxml.h> |
52 | 52 | ||
53 | using namespace Opie; | 53 | using namespace Opie; |
54 | 54 | ||
55 | namespace { | 55 | namespace { |
56 | time_t rp_end; | 56 | time_t rp_end; |
57 | ORecur* rec; | 57 | OPimRecurrence* rec; |
58 | ORecur *recur() { | 58 | OPimRecurrence *recur() { |
59 | if (!rec ) rec = new ORecur; | 59 | if (!rec ) rec = new OPimRecurrence; |
60 | return rec; | 60 | return rec; |
61 | } | 61 | } |
62 | int snd; | 62 | int snd; |
63 | enum MoreAttributes { | 63 | enum MoreAttributes { |
64 | FRType = OTodo::CompletedDate + 2, | 64 | FRType = OPimTodo::CompletedDate + 2, |
65 | FRWeekdays, | 65 | FRWeekdays, |
66 | FRPosition, | 66 | FRPosition, |
67 | FRFreq, | 67 | FRFreq, |
68 | FRHasEndDate, | 68 | FRHasEndDate, |
69 | FREndDate, | 69 | FREndDate, |
70 | FRStart, | 70 | FRStart, |
71 | FREnd | 71 | FREnd |
72 | }; | 72 | }; |
73 | // FROM TT again | 73 | // FROM TT again |
74 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | 74 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) |
75 | { | 75 | { |
76 | char needleChar; | 76 | char needleChar; |
@@ -89,65 +89,65 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | |||
89 | if (hsearch >= haystack + hLen) | 89 | if (hsearch >= haystack + hLen) |
90 | return (0); | 90 | return (0); |
91 | } while (haystackChar != needleChar); | 91 | } while (haystackChar != needleChar); |
92 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | 92 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); |
93 | hsearch--; | 93 | hsearch--; |
94 | } | 94 | } |
95 | return ((char *)hsearch); | 95 | return ((char *)hsearch); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | namespace Opie { | 99 | namespace Opie { |
100 | 100 | ||
101 | OTodoAccessXML::OTodoAccessXML( const QString& appName, | 101 | OPimTodoAccessXML::OPimTodoAccessXML( const QString& appName, |
102 | const QString& fileName ) | 102 | const QString& fileName ) |
103 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) | 103 | : OPimTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) |
104 | { | 104 | { |
105 | if (!fileName.isEmpty() ) | 105 | if (!fileName.isEmpty() ) |
106 | m_file = fileName; | 106 | m_file = fileName; |
107 | else | 107 | else |
108 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); | 108 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); |
109 | } | 109 | } |
110 | OTodoAccessXML::~OTodoAccessXML() { | 110 | OPimTodoAccessXML::~OPimTodoAccessXML() { |
111 | 111 | ||
112 | } | 112 | } |
113 | bool OTodoAccessXML::load() { | 113 | bool OPimTodoAccessXML::load() { |
114 | rec = 0; | 114 | rec = 0; |
115 | m_opened = true; | 115 | m_opened = true; |
116 | m_changed = false; | 116 | m_changed = false; |
117 | /* initialize dict */ | 117 | /* initialize dict */ |
118 | /* | 118 | /* |
119 | * UPDATE dict if you change anything!!! | 119 | * UPDATE dict if you change anything!!! |
120 | */ | 120 | */ |
121 | QAsciiDict<int> dict(26); | 121 | QAsciiDict<int> dict(26); |
122 | dict.setAutoDelete( TRUE ); | 122 | dict.setAutoDelete( TRUE ); |
123 | dict.insert("Categories" , new int(OTodo::Category) ); | 123 | dict.insert("Categories" , new int(OPimTodo::Category) ); |
124 | dict.insert("Uid" , new int(OTodo::Uid) ); | 124 | dict.insert("Uid" , new int(OPimTodo::Uid) ); |
125 | dict.insert("HasDate" , new int(OTodo::HasDate) ); | 125 | dict.insert("HasDate" , new int(OPimTodo::HasDate) ); |
126 | dict.insert("Completed" , new int(OTodo::Completed) ); | 126 | dict.insert("Completed" , new int(OPimTodo::Completed) ); |
127 | dict.insert("Description" , new int(OTodo::Description) ); | 127 | dict.insert("Description" , new int(OPimTodo::Description) ); |
128 | dict.insert("Summary" , new int(OTodo::Summary) ); | 128 | dict.insert("Summary" , new int(OPimTodo::Summary) ); |
129 | dict.insert("Priority" , new int(OTodo::Priority) ); | 129 | dict.insert("Priority" , new int(OPimTodo::Priority) ); |
130 | dict.insert("DateDay" , new int(OTodo::DateDay) ); | 130 | dict.insert("DateDay" , new int(OPimTodo::DateDay) ); |
131 | dict.insert("DateMonth" , new int(OTodo::DateMonth) ); | 131 | dict.insert("DateMonth" , new int(OPimTodo::DateMonth) ); |
132 | dict.insert("DateYear" , new int(OTodo::DateYear) ); | 132 | dict.insert("DateYear" , new int(OPimTodo::DateYear) ); |
133 | dict.insert("Progress" , new int(OTodo::Progress) ); | 133 | dict.insert("Progress" , new int(OPimTodo::Progress) ); |
134 | dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); | 134 | dict.insert("CompletedDate", new int(OPimTodo::CompletedDate) ); |
135 | dict.insert("StartDate", new int(OTodo::StartDate) ); | 135 | dict.insert("StartDate", new int(OPimTodo::StartDate) ); |
136 | dict.insert("CrossReference", new int(OTodo::CrossReference) ); | 136 | dict.insert("CrossReference", new int(OPimTodo::CrossReference) ); |
137 | dict.insert("State", new int(OTodo::State) ); | 137 | dict.insert("State", new int(OPimTodo::State) ); |
138 | dict.insert("Alarms", new int(OTodo::Alarms) ); | 138 | dict.insert("Alarms", new int(OPimTodo::Alarms) ); |
139 | dict.insert("Reminders", new int(OTodo::Reminders) ); | 139 | dict.insert("Reminders", new int(OPimTodo::Reminders) ); |
140 | dict.insert("Notifiers", new int(OTodo::Notifiers) ); | 140 | dict.insert("Notifiers", new int(OPimTodo::Notifiers) ); |
141 | dict.insert("Maintainer", new int(OTodo::Maintainer) ); | 141 | dict.insert("Maintainer", new int(OPimTodo::Maintainer) ); |
142 | dict.insert("rtype", new int(FRType) ); | 142 | dict.insert("rtype", new int(FRType) ); |
143 | dict.insert("rweekdays", new int(FRWeekdays) ); | 143 | dict.insert("rweekdays", new int(FRWeekdays) ); |
144 | dict.insert("rposition", new int(FRPosition) ); | 144 | dict.insert("rposition", new int(FRPosition) ); |
145 | dict.insert("rfreq", new int(FRFreq) ); | 145 | dict.insert("rfreq", new int(FRFreq) ); |
146 | dict.insert("start", new int(FRStart) ); | 146 | dict.insert("start", new int(FRStart) ); |
147 | dict.insert("rhasenddate", new int(FRHasEndDate) ); | 147 | dict.insert("rhasenddate", new int(FRHasEndDate) ); |
148 | dict.insert("enddt", new int(FREndDate) ); | 148 | dict.insert("enddt", new int(FREndDate) ); |
149 | 149 | ||
150 | // here the custom XML parser from TT it's GPL | 150 | // here the custom XML parser from TT it's GPL |
151 | // but we want to push OpiePIM... to TT..... | 151 | // but we want to push OpiePIM... to TT..... |
152 | // mmap part from zecke :) | 152 | // mmap part from zecke :) |
153 | int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); | 153 | int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); |
@@ -170,25 +170,25 @@ bool OTodoAccessXML::load() { | |||
170 | 170 | ||
171 | char* dt = (char*)map_addr; | 171 | char* dt = (char*)map_addr; |
172 | int len = attribut.st_size; | 172 | int len = attribut.st_size; |
173 | int i = 0; | 173 | int i = 0; |
174 | char *point; | 174 | char *point; |
175 | const char* collectionString = "<Task "; | 175 | const char* collectionString = "<Task "; |
176 | int strLen = strlen(collectionString); | 176 | int strLen = strlen(collectionString); |
177 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { | 177 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { |
178 | i = point -dt; | 178 | i = point -dt; |
179 | i+= strLen; | 179 | i+= strLen; |
180 | qWarning("Found a start at %d %d", i, (point-dt) ); | 180 | qWarning("Found a start at %d %d", i, (point-dt) ); |
181 | 181 | ||
182 | OTodo ev; | 182 | OPimTodo ev; |
183 | m_year = m_month = m_day = 0; | 183 | m_year = m_month = m_day = 0; |
184 | 184 | ||
185 | while ( TRUE ) { | 185 | while ( TRUE ) { |
186 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) | 186 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) |
187 | ++i; | 187 | ++i; |
188 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) | 188 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) |
189 | break; | 189 | break; |
190 | 190 | ||
191 | // we have another attribute, read it. | 191 | // we have another attribute, read it. |
192 | int j = i; | 192 | int j = i; |
193 | while ( j < len && dt[j] != '=' ) | 193 | while ( j < len && dt[j] != '=' ) |
194 | ++j; | 194 | ++j; |
@@ -233,62 +233,62 @@ bool OTodoAccessXML::load() { | |||
233 | /* | 233 | /* |
234 | * now add it | 234 | * now add it |
235 | */ | 235 | */ |
236 | qWarning("End at %d", i ); | 236 | qWarning("End at %d", i ); |
237 | if (m_events.contains( ev.uid() ) || ev.uid() == 0) { | 237 | if (m_events.contains( ev.uid() ) || ev.uid() == 0) { |
238 | ev.setUid( 1 ); | 238 | ev.setUid( 1 ); |
239 | m_changed = true; | 239 | m_changed = true; |
240 | } | 240 | } |
241 | if ( ev.hasDueDate() ) { | 241 | if ( ev.hasDueDate() ) { |
242 | ev.setDueDate( QDate(m_year, m_month, m_day) ); | 242 | ev.setDueDate( QDate(m_year, m_month, m_day) ); |
243 | } | 243 | } |
244 | if ( rec && rec->doesRecur() ) { | 244 | if ( rec && rec->doesRecur() ) { |
245 | OTimeZone utc = OTimeZone::utc(); | 245 | OPimTimeZone utc = OPimTimeZone::utc(); |
246 | ORecur recu( *rec ); // call copy c'tor | 246 | OPimRecurrence recu( *rec ); // call copy c'tor |
247 | recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); | 247 | recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); |
248 | recu.setStart( ev.dueDate() ); | 248 | recu.setStart( ev.dueDate() ); |
249 | ev.setRecurrence( recu ); | 249 | ev.setRecurrence( recu ); |
250 | } | 250 | } |
251 | m_events.insert(ev.uid(), ev ); | 251 | m_events.insert(ev.uid(), ev ); |
252 | m_year = m_month = m_day = -1; | 252 | m_year = m_month = m_day = -1; |
253 | delete rec; | 253 | delete rec; |
254 | rec = 0; | 254 | rec = 0; |
255 | } | 255 | } |
256 | 256 | ||
257 | munmap(map_addr, attribut.st_size ); | 257 | munmap(map_addr, attribut.st_size ); |
258 | 258 | ||
259 | qWarning("counts %d records loaded!", m_events.count() ); | 259 | qWarning("counts %d records loaded!", m_events.count() ); |
260 | return true; | 260 | return true; |
261 | } | 261 | } |
262 | bool OTodoAccessXML::reload() { | 262 | bool OPimTodoAccessXML::reload() { |
263 | m_events.clear(); | 263 | m_events.clear(); |
264 | return load(); | 264 | return load(); |
265 | } | 265 | } |
266 | bool OTodoAccessXML::save() { | 266 | bool OPimTodoAccessXML::save() { |
267 | // qWarning("saving"); | 267 | // qWarning("saving"); |
268 | if (!m_opened || !m_changed ) { | 268 | if (!m_opened || !m_changed ) { |
269 | // qWarning("not saving"); | 269 | // qWarning("not saving"); |
270 | return true; | 270 | return true; |
271 | } | 271 | } |
272 | QString strNewFile = m_file + ".new"; | 272 | QString strNewFile = m_file + ".new"; |
273 | QFile f( strNewFile ); | 273 | QFile f( strNewFile ); |
274 | if (!f.open( IO_WriteOnly|IO_Raw ) ) | 274 | if (!f.open( IO_WriteOnly|IO_Raw ) ) |
275 | return false; | 275 | return false; |
276 | 276 | ||
277 | int written; | 277 | int written; |
278 | QString out; | 278 | QString out; |
279 | out = "<!DOCTYPE Tasks>\n<Tasks>\n"; | 279 | out = "<!DOCTYPE Tasks>\n<Tasks>\n"; |
280 | 280 | ||
281 | // for all todos | 281 | // for all todos |
282 | QMap<int, OTodo>::Iterator it; | 282 | QMap<int, OPimTodo>::Iterator it; |
283 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | 283 | for (it = m_events.begin(); it != m_events.end(); ++it ) { |
284 | out+= "<Task " + toString( (*it) ) + " />\n"; | 284 | out+= "<Task " + toString( (*it) ) + " />\n"; |
285 | QCString cstr = out.utf8(); | 285 | QCString cstr = out.utf8(); |
286 | written = f.writeBlock( cstr.data(), cstr.length() ); | 286 | written = f.writeBlock( cstr.data(), cstr.length() ); |
287 | 287 | ||
288 | /* less written then we wanted */ | 288 | /* less written then we wanted */ |
289 | if ( written != (int)cstr.length() ) { | 289 | if ( written != (int)cstr.length() ) { |
290 | f.close(); | 290 | f.close(); |
291 | QFile::remove( strNewFile ); | 291 | QFile::remove( strNewFile ); |
292 | return false; | 292 | return false; |
293 | } | 293 | } |
294 | out = QString::null; | 294 | out = QString::null; |
@@ -305,220 +305,220 @@ bool OTodoAccessXML::save() { | |||
305 | } | 305 | } |
306 | /* flush before renaming */ | 306 | /* flush before renaming */ |
307 | f.close(); | 307 | f.close(); |
308 | 308 | ||
309 | if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { | 309 | if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { |
310 | // qWarning("error renaming"); | 310 | // qWarning("error renaming"); |
311 | QFile::remove( strNewFile ); | 311 | QFile::remove( strNewFile ); |
312 | } | 312 | } |
313 | 313 | ||
314 | m_changed = false; | 314 | m_changed = false; |
315 | return true; | 315 | return true; |
316 | } | 316 | } |
317 | QArray<int> OTodoAccessXML::allRecords()const { | 317 | QArray<int> OPimTodoAccessXML::allRecords()const { |
318 | QArray<int> ids( m_events.count() ); | 318 | QArray<int> ids( m_events.count() ); |
319 | QMap<int, OTodo>::ConstIterator it; | 319 | QMap<int, OPimTodo>::ConstIterator it; |
320 | int i = 0; | 320 | int i = 0; |
321 | 321 | ||
322 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 322 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
323 | ids[i] = it.key(); | 323 | ids[i] = it.key(); |
324 | i++; | 324 | i++; |
325 | } | 325 | } |
326 | return ids; | 326 | return ids; |
327 | } | 327 | } |
328 | QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int, const QDateTime& ) { | 328 | QArray<int> OPimTodoAccessXML::queryByExample( const OPimTodo&, int, const QDateTime& ) { |
329 | QArray<int> ids(0); | 329 | QArray<int> ids(0); |
330 | return ids; | 330 | return ids; |
331 | } | 331 | } |
332 | OTodo OTodoAccessXML::find( int uid )const { | 332 | OPimTodo OPimTodoAccessXML::find( int uid )const { |
333 | OTodo todo; | 333 | OPimTodo todo; |
334 | todo.setUid( 0 ); // isEmpty() | 334 | todo.setUid( 0 ); // isEmpty() |
335 | QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); | 335 | QMap<int, OPimTodo>::ConstIterator it = m_events.find( uid ); |
336 | if ( it != m_events.end() ) | 336 | if ( it != m_events.end() ) |
337 | todo = it.data(); | 337 | todo = it.data(); |
338 | 338 | ||
339 | return todo; | 339 | return todo; |
340 | } | 340 | } |
341 | void OTodoAccessXML::clear() { | 341 | void OPimTodoAccessXML::clear() { |
342 | if (m_opened ) | 342 | if (m_opened ) |
343 | m_changed = true; | 343 | m_changed = true; |
344 | 344 | ||
345 | m_events.clear(); | 345 | m_events.clear(); |
346 | } | 346 | } |
347 | bool OTodoAccessXML::add( const OTodo& todo ) { | 347 | bool OPimTodoAccessXML::add( const OPimTodo& todo ) { |
348 | // qWarning("add"); | 348 | // qWarning("add"); |
349 | m_changed = true; | 349 | m_changed = true; |
350 | m_events.insert( todo.uid(), todo ); | 350 | m_events.insert( todo.uid(), todo ); |
351 | 351 | ||
352 | return true; | 352 | return true; |
353 | } | 353 | } |
354 | bool OTodoAccessXML::remove( int uid ) { | 354 | bool OPimTodoAccessXML::remove( int uid ) { |
355 | m_changed = true; | 355 | m_changed = true; |
356 | m_events.remove( uid ); | 356 | m_events.remove( uid ); |
357 | 357 | ||
358 | return true; | 358 | return true; |
359 | } | 359 | } |
360 | bool OTodoAccessXML::replace( const OTodo& todo) { | 360 | bool OPimTodoAccessXML::replace( const OPimTodo& todo) { |
361 | m_changed = true; | 361 | m_changed = true; |
362 | m_events.replace( todo.uid(), todo ); | 362 | m_events.replace( todo.uid(), todo ); |
363 | 363 | ||
364 | return true; | 364 | return true; |
365 | } | 365 | } |
366 | QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, | 366 | QArray<int> OPimTodoAccessXML::effectiveToDos( const QDate& start, |
367 | const QDate& end, | 367 | const QDate& end, |
368 | bool includeNoDates ) { | 368 | bool includeNoDates ) { |
369 | QArray<int> ids( m_events.count() ); | 369 | QArray<int> ids( m_events.count() ); |
370 | QMap<int, OTodo>::Iterator it; | 370 | QMap<int, OPimTodo>::Iterator it; |
371 | 371 | ||
372 | int i = 0; | 372 | int i = 0; |
373 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 373 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
374 | if ( !it.data().hasDueDate() ) { | 374 | if ( !it.data().hasDueDate() ) { |
375 | if ( includeNoDates ) { | 375 | if ( includeNoDates ) { |
376 | ids[i] = it.key(); | 376 | ids[i] = it.key(); |
377 | i++; | 377 | i++; |
378 | } | 378 | } |
379 | }else if ( it.data().dueDate() >= start && | 379 | }else if ( it.data().dueDate() >= start && |
380 | it.data().dueDate() <= end ) { | 380 | it.data().dueDate() <= end ) { |
381 | ids[i] = it.key(); | 381 | ids[i] = it.key(); |
382 | i++; | 382 | i++; |
383 | } | 383 | } |
384 | } | 384 | } |
385 | ids.resize( i ); | 385 | ids.resize( i ); |
386 | return ids; | 386 | return ids; |
387 | } | 387 | } |
388 | QArray<int> OTodoAccessXML::overDue() { | 388 | QArray<int> OPimTodoAccessXML::overDue() { |
389 | QArray<int> ids( m_events.count() ); | 389 | QArray<int> ids( m_events.count() ); |
390 | int i = 0; | 390 | int i = 0; |
391 | 391 | ||
392 | QMap<int, OTodo>::Iterator it; | 392 | QMap<int, OPimTodo>::Iterator it; |
393 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 393 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
394 | if ( it.data().isOverdue() ) { | 394 | if ( it.data().isOverdue() ) { |
395 | ids[i] = it.key(); | 395 | ids[i] = it.key(); |
396 | i++; | 396 | i++; |
397 | } | 397 | } |
398 | } | 398 | } |
399 | ids.resize( i ); | 399 | ids.resize( i ); |
400 | return ids; | 400 | return ids; |
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
404 | /* private */ | 404 | /* private */ |
405 | void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, | 405 | void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, |
406 | const QCString& attr, const QString& val) { | 406 | const QCString& attr, const QString& val) { |
407 | // qWarning("parse to do from XMLElement" ); | 407 | // qWarning("parse to do from XMLElement" ); |
408 | 408 | ||
409 | int *find=0; | 409 | int *find=0; |
410 | 410 | ||
411 | find = (*dict)[ attr.data() ]; | 411 | find = (*dict)[ attr.data() ]; |
412 | if (!find ) { | 412 | if (!find ) { |
413 | // qWarning("Unknown option" + it.key() ); | 413 | // qWarning("Unknown option" + it.key() ); |
414 | ev.setCustomField( attr, val ); | 414 | ev.setCustomField( attr, val ); |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | 417 | ||
418 | switch( *find ) { | 418 | switch( *find ) { |
419 | case OTodo::Uid: | 419 | case OPimTodo::Uid: |
420 | ev.setUid( val.toInt() ); | 420 | ev.setUid( val.toInt() ); |
421 | break; | 421 | break; |
422 | case OTodo::Category: | 422 | case OPimTodo::Category: |
423 | ev.setCategories( ev.idsFromString( val ) ); | 423 | ev.setCategories( ev.idsFromString( val ) ); |
424 | break; | 424 | break; |
425 | case OTodo::HasDate: | 425 | case OPimTodo::HasDate: |
426 | ev.setHasDueDate( val.toInt() ); | 426 | ev.setHasDueDate( val.toInt() ); |
427 | break; | 427 | break; |
428 | case OTodo::Completed: | 428 | case OPimTodo::Completed: |
429 | ev.setCompleted( val.toInt() ); | 429 | ev.setCompleted( val.toInt() ); |
430 | break; | 430 | break; |
431 | case OTodo::Description: | 431 | case OPimTodo::Description: |
432 | ev.setDescription( val ); | 432 | ev.setDescription( val ); |
433 | break; | 433 | break; |
434 | case OTodo::Summary: | 434 | case OPimTodo::Summary: |
435 | ev.setSummary( val ); | 435 | ev.setSummary( val ); |
436 | break; | 436 | break; |
437 | case OTodo::Priority: | 437 | case OPimTodo::Priority: |
438 | ev.setPriority( val.toInt() ); | 438 | ev.setPriority( val.toInt() ); |
439 | break; | 439 | break; |
440 | case OTodo::DateDay: | 440 | case OPimTodo::DateDay: |
441 | m_day = val.toInt(); | 441 | m_day = val.toInt(); |
442 | break; | 442 | break; |
443 | case OTodo::DateMonth: | 443 | case OPimTodo::DateMonth: |
444 | m_month = val.toInt(); | 444 | m_month = val.toInt(); |
445 | break; | 445 | break; |
446 | case OTodo::DateYear: | 446 | case OPimTodo::DateYear: |
447 | m_year = val.toInt(); | 447 | m_year = val.toInt(); |
448 | break; | 448 | break; |
449 | case OTodo::Progress: | 449 | case OPimTodo::Progress: |
450 | ev.setProgress( val.toInt() ); | 450 | ev.setProgress( val.toInt() ); |
451 | break; | 451 | break; |
452 | case OTodo::CompletedDate: | 452 | case OPimTodo::CompletedDate: |
453 | ev.setCompletedDate( OConversion::dateFromString( val ) ); | 453 | ev.setCompletedDate( OPimDateConversion::dateFromString( val ) ); |
454 | break; | 454 | break; |
455 | case OTodo::StartDate: | 455 | case OPimTodo::StartDate: |
456 | ev.setStartDate( OConversion::dateFromString( val ) ); | 456 | ev.setStartDate( OPimDateConversion::dateFromString( val ) ); |
457 | break; | 457 | break; |
458 | case OTodo::State: | 458 | case OPimTodo::State: |
459 | ev.setState( val.toInt() ); | 459 | ev.setState( val.toInt() ); |
460 | break; | 460 | break; |
461 | case OTodo::Alarms:{ | 461 | case OPimTodo::Alarms:{ |
462 | OPimNotifyManager &manager = ev.notifiers(); | 462 | OPimNotifyManager &manager = ev.notifiers(); |
463 | QStringList als = QStringList::split(";", val ); | 463 | QStringList als = QStringList::split(";", val ); |
464 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | 464 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { |
465 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | 465 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty |
466 | qWarning("alarm: %s", alarm.join("___").latin1() ); | 466 | qWarning("alarm: %s", alarm.join("___").latin1() ); |
467 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); | 467 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), OPimDateConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); |
468 | OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); | 468 | OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); |
469 | manager.add( al ); | 469 | manager.add( al ); |
470 | } | 470 | } |
471 | } | 471 | } |
472 | break; | 472 | break; |
473 | case OTodo::Reminders:{ | 473 | case OPimTodo::Reminders:{ |
474 | OPimNotifyManager &manager = ev.notifiers(); | 474 | OPimNotifyManager &manager = ev.notifiers(); |
475 | QStringList rems = QStringList::split(";", val ); | 475 | QStringList rems = QStringList::split(";", val ); |
476 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | 476 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { |
477 | OPimReminder rem( (*it).toInt() ); | 477 | OPimReminder rem( (*it).toInt() ); |
478 | manager.add( rem ); | 478 | manager.add( rem ); |
479 | } | 479 | } |
480 | } | 480 | } |
481 | break; | 481 | break; |
482 | case OTodo::CrossReference: | 482 | case OPimTodo::CrossReference: |
483 | { | 483 | { |
484 | /* | 484 | /* |
485 | * A cross refernce looks like | 485 | * A cross refernce looks like |
486 | * appname,id;appname,id | 486 | * appname,id;appname,id |
487 | * we need to split it up | 487 | * we need to split it up |
488 | */ | 488 | */ |
489 | QStringList refs = QStringList::split(';', val ); | 489 | QStringList refs = QStringList::split(';', val ); |
490 | QStringList::Iterator strIt; | 490 | QStringList::Iterator strIt; |
491 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { | 491 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { |
492 | int pos = (*strIt).find(','); | 492 | int pos = (*strIt).find(','); |
493 | if ( pos > -1 ) | 493 | if ( pos > -1 ) |
494 | ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); | 494 | ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); |
495 | 495 | ||
496 | } | 496 | } |
497 | break; | 497 | break; |
498 | } | 498 | } |
499 | /* Recurrence stuff below + post processing later */ | 499 | /* Recurrence stuff below + post processing later */ |
500 | case FRType: | 500 | case FRType: |
501 | if ( val == "Daily" ) | 501 | if ( val == "Daily" ) |
502 | recur()->setType( ORecur::Daily ); | 502 | recur()->setType( OPimRecurrence::Daily ); |
503 | else if ( val == "Weekly" ) | 503 | else if ( val == "Weekly" ) |
504 | recur()->setType( ORecur::Weekly); | 504 | recur()->setType( OPimRecurrence::Weekly); |
505 | else if ( val == "MonthlyDay" ) | 505 | else if ( val == "MonthlyDay" ) |
506 | recur()->setType( ORecur::MonthlyDay ); | 506 | recur()->setType( OPimRecurrence::MonthlyDay ); |
507 | else if ( val == "MonthlyDate" ) | 507 | else if ( val == "MonthlyDate" ) |
508 | recur()->setType( ORecur::MonthlyDate ); | 508 | recur()->setType( OPimRecurrence::MonthlyDate ); |
509 | else if ( val == "Yearly" ) | 509 | else if ( val == "Yearly" ) |
510 | recur()->setType( ORecur::Yearly ); | 510 | recur()->setType( OPimRecurrence::Yearly ); |
511 | else | 511 | else |
512 | recur()->setType( ORecur::NoRepeat ); | 512 | recur()->setType( OPimRecurrence::NoRepeat ); |
513 | break; | 513 | break; |
514 | case FRWeekdays: | 514 | case FRWeekdays: |
515 | recur()->setDays( val.toInt() ); | 515 | recur()->setDays( val.toInt() ); |
516 | break; | 516 | break; |
517 | case FRPosition: | 517 | case FRPosition: |
518 | recur()->setPosition( val.toInt() ); | 518 | recur()->setPosition( val.toInt() ); |
519 | break; | 519 | break; |
520 | case FRFreq: | 520 | case FRFreq: |
521 | recur()->setFrequency( val.toInt() ); | 521 | recur()->setFrequency( val.toInt() ); |
522 | break; | 522 | break; |
523 | case FRHasEndDate: | 523 | case FRHasEndDate: |
524 | recur()->setHasEndDate( val.toInt() ); | 524 | recur()->setHasEndDate( val.toInt() ); |
@@ -544,25 +544,25 @@ QString customToXml(const QMap<QString, QString>& customMap ) | |||
544 | // qWarning(".ITEM."); | 544 | // qWarning(".ITEM."); |
545 | buf += cit.key(); | 545 | buf += cit.key(); |
546 | buf += "=\""; | 546 | buf += "=\""; |
547 | buf += Qtopia::escapeString(cit.data()); | 547 | buf += Qtopia::escapeString(cit.data()); |
548 | buf += "\" "; | 548 | buf += "\" "; |
549 | } | 549 | } |
550 | return buf; | 550 | return buf; |
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | } | 554 | } |
555 | 555 | ||
556 | QString OTodoAccessXML::toString( const OTodo& ev )const { | 556 | QString OPimTodoAccessXML::toString( const OPimTodo& ev )const { |
557 | QString str; | 557 | QString str; |
558 | 558 | ||
559 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; | 559 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; |
560 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; | 560 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; |
561 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; | 561 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; |
562 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; | 562 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; |
563 | 563 | ||
564 | str += "Categories=\"" + toString( ev.categories() ) + "\" "; | 564 | str += "Categories=\"" + toString( ev.categories() ) + "\" "; |
565 | str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; | 565 | str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; |
566 | str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; | 566 | str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; |
567 | 567 | ||
568 | if ( ev.hasDueDate() ) { | 568 | if ( ev.hasDueDate() ) { |
@@ -582,104 +582,104 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
582 | */ | 582 | */ |
583 | /* | 583 | /* |
584 | QMap<QString, QString> extras = ev.extras(); | 584 | QMap<QString, QString> extras = ev.extras(); |
585 | QMap<QString, QString>::Iterator extIt; | 585 | QMap<QString, QString>::Iterator extIt; |
586 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) | 586 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) |
587 | str += extIt.key() + "=\"" + extIt.data() + "\" "; | 587 | str += extIt.key() + "=\"" + extIt.data() + "\" "; |
588 | */ | 588 | */ |
589 | // cross refernce | 589 | // cross refernce |
590 | if ( ev.hasRecurrence() ) { | 590 | if ( ev.hasRecurrence() ) { |
591 | str += ev.recurrence().toString(); | 591 | str += ev.recurrence().toString(); |
592 | } | 592 | } |
593 | if ( ev.hasStartDate() ) | 593 | if ( ev.hasStartDate() ) |
594 | str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; | 594 | str += "StartDate=\""+ OPimDateConversion::dateToString( ev.startDate() ) +"\" "; |
595 | if ( ev.hasCompletedDate() ) | 595 | if ( ev.hasCompletedDate() ) |
596 | str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; | 596 | str += "CompletedDate=\""+ OPimDateConversion::dateToString( ev.completedDate() ) +"\" "; |
597 | if ( ev.hasState() ) | 597 | if ( ev.hasState() ) |
598 | str += "State=\""+QString::number( ev.state().state() )+"\" "; | 598 | str += "State=\""+QString::number( ev.state().state() )+"\" "; |
599 | 599 | ||
600 | /* | 600 | /* |
601 | * save reminders and notifiers! | 601 | * save reminders and notifiers! |
602 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... | 602 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... |
603 | */ | 603 | */ |
604 | if ( ev.hasNotifiers() ) { | 604 | if ( ev.hasNotifiers() ) { |
605 | OPimNotifyManager manager = ev.notifiers(); | 605 | OPimNotifyManager manager = ev.notifiers(); |
606 | OPimNotifyManager::Alarms alarms = manager.alarms(); | 606 | OPimNotifyManager::Alarms alarms = manager.alarms(); |
607 | if (!alarms.isEmpty() ) { | 607 | if (!alarms.isEmpty() ) { |
608 | QStringList als; | 608 | QStringList als; |
609 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | 609 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); |
610 | for ( ; it != alarms.end(); ++it ) { | 610 | for ( ; it != alarms.end(); ++it ) { |
611 | /* only if time is valid */ | 611 | /* only if time is valid */ |
612 | if ( (*it).dateTime().isValid() ) { | 612 | if ( (*it).dateTime().isValid() ) { |
613 | als << OConversion::dateTimeToString( (*it).dateTime() ) | 613 | als << OPimDateConversion::dateTimeToString( (*it).dateTime() ) |
614 | + ":" + QString::number( (*it).duration() ) | 614 | + ":" + QString::number( (*it).duration() ) |
615 | + ":" + QString::number( (*it).sound() ) | 615 | + ":" + QString::number( (*it).sound() ) |
616 | + ":"; | 616 | + ":"; |
617 | } | 617 | } |
618 | } | 618 | } |
619 | // now write the list | 619 | // now write the list |
620 | qWarning("als: %s", als.join("____________").latin1() ); | 620 | qWarning("als: %s", als.join("____________").latin1() ); |
621 | str += "Alarms=\""+als.join(";") +"\" "; | 621 | str += "Alarms=\""+als.join(";") +"\" "; |
622 | } | 622 | } |
623 | 623 | ||
624 | /* | 624 | /* |
625 | * now the same for reminders but more easy. We just save the uid of the OEvent. | 625 | * now the same for reminders but more easy. We just save the uid of the OPimEvent. |
626 | */ | 626 | */ |
627 | OPimNotifyManager::Reminders reminders = manager.reminders(); | 627 | OPimNotifyManager::Reminders reminders = manager.reminders(); |
628 | if (!reminders.isEmpty() ) { | 628 | if (!reminders.isEmpty() ) { |
629 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | 629 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); |
630 | QStringList records; | 630 | QStringList records; |
631 | for ( ; it != reminders.end(); ++it ) { | 631 | for ( ; it != reminders.end(); ++it ) { |
632 | records << QString::number( (*it).recordUid() ); | 632 | records << QString::number( (*it).recordUid() ); |
633 | } | 633 | } |
634 | str += "Reminders=\""+ records.join(";") +"\" "; | 634 | str += "Reminders=\""+ records.join(";") +"\" "; |
635 | } | 635 | } |
636 | } | 636 | } |
637 | str += customToXml( ev.toExtraMap() ); | 637 | str += customToXml( ev.toExtraMap() ); |
638 | 638 | ||
639 | 639 | ||
640 | return str; | 640 | return str; |
641 | } | 641 | } |
642 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { | 642 | QString OPimTodoAccessXML::toString( const QArray<int>& ints ) const { |
643 | return Qtopia::Record::idsToString( ints ); | 643 | return Qtopia::Record::idsToString( ints ); |
644 | } | 644 | } |
645 | 645 | ||
646 | /* internal class for sorting | 646 | /* internal class for sorting |
647 | * | 647 | * |
648 | * Inspired by todoxmlio.cpp from TT | 648 | * Inspired by todoxmlio.cpp from TT |
649 | */ | 649 | */ |
650 | 650 | ||
651 | struct OTodoXMLContainer { | 651 | struct OPimTodoXMLContainer { |
652 | OTodo todo; | 652 | OPimTodo todo; |
653 | }; | 653 | }; |
654 | 654 | ||
655 | namespace { | 655 | namespace { |
656 | inline QString string( const OTodo& todo) { | 656 | inline QString string( const OPimTodo& todo) { |
657 | return todo.summary().isEmpty() ? | 657 | return todo.summary().isEmpty() ? |
658 | todo.description().left(20 ) : | 658 | todo.description().left(20 ) : |
659 | todo.summary(); | 659 | todo.summary(); |
660 | } | 660 | } |
661 | inline int completed( const OTodo& todo1, const OTodo& todo2) { | 661 | inline int completed( const OPimTodo& todo1, const OPimTodo& todo2) { |
662 | int ret = 0; | 662 | int ret = 0; |
663 | if ( todo1.isCompleted() ) ret++; | 663 | if ( todo1.isCompleted() ) ret++; |
664 | if ( todo2.isCompleted() ) ret--; | 664 | if ( todo2.isCompleted() ) ret--; |
665 | return ret; | 665 | return ret; |
666 | } | 666 | } |
667 | inline int priority( const OTodo& t1, const OTodo& t2) { | 667 | inline int priority( const OPimTodo& t1, const OPimTodo& t2) { |
668 | return ( t1.priority() - t2.priority() ); | 668 | return ( t1.priority() - t2.priority() ); |
669 | } | 669 | } |
670 | inline int description( const OTodo& t1, const OTodo& t2) { | 670 | inline int description( const OPimTodo& t1, const OPimTodo& t2) { |
671 | return QString::compare( string(t1), string(t2) ); | 671 | return QString::compare( string(t1), string(t2) ); |
672 | } | 672 | } |
673 | inline int deadline( const OTodo& t1, const OTodo& t2) { | 673 | inline int deadline( const OPimTodo& t1, const OPimTodo& t2) { |
674 | int ret = 0; | 674 | int ret = 0; |
675 | if ( t1.hasDueDate() && | 675 | if ( t1.hasDueDate() && |
676 | t2.hasDueDate() ) | 676 | t2.hasDueDate() ) |
677 | ret = t2.dueDate().daysTo( t1.dueDate() ); | 677 | ret = t2.dueDate().daysTo( t1.dueDate() ); |
678 | else if ( t1.hasDueDate() ) | 678 | else if ( t1.hasDueDate() ) |
679 | ret = -1; | 679 | ret = -1; |
680 | else if ( t2.hasDueDate() ) | 680 | else if ( t2.hasDueDate() ) |
681 | ret = 1; | 681 | ret = 1; |
682 | else | 682 | else |
683 | ret = 0; | 683 | ret = 0; |
684 | 684 | ||
685 | return ret; | 685 | return ret; |
@@ -694,49 +694,49 @@ namespace { | |||
694 | * non-zero if item1 != item2 | 694 | * non-zero if item1 != item2 |
695 | * | 695 | * |
696 | * This function returns int rather than bool so that reimplementations | 696 | * This function returns int rather than bool so that reimplementations |
697 | * can return one of three values and use it to sort by: | 697 | * can return one of three values and use it to sort by: |
698 | * | 698 | * |
699 | * 0 if item1 == item2 | 699 | * 0 if item1 == item2 |
700 | * | 700 | * |
701 | * > 0 (positive integer) if item1 > item2 | 701 | * > 0 (positive integer) if item1 > item2 |
702 | * | 702 | * |
703 | * < 0 (negative integer) if item1 < item2 | 703 | * < 0 (negative integer) if item1 < item2 |
704 | * | 704 | * |
705 | */ | 705 | */ |
706 | class OTodoXMLVector : public QVector<OTodoXMLContainer> { | 706 | class OPimTodoXMLVector : public QVector<OPimTodoXMLContainer> { |
707 | public: | 707 | public: |
708 | OTodoXMLVector(int size, bool asc, int sort) | 708 | OPimTodoXMLVector(int size, bool asc, int sort) |
709 | : QVector<OTodoXMLContainer>( size ) | 709 | : QVector<OPimTodoXMLContainer>( size ) |
710 | { | 710 | { |
711 | setAutoDelete( true ); | 711 | setAutoDelete( true ); |
712 | m_asc = asc; | 712 | m_asc = asc; |
713 | m_sort = sort; | 713 | m_sort = sort; |
714 | } | 714 | } |
715 | /* return the summary/description */ | 715 | /* return the summary/description */ |
716 | QString string( const OTodo& todo) { | 716 | QString string( const OPimTodo& todo) { |
717 | return todo.summary().isEmpty() ? | 717 | return todo.summary().isEmpty() ? |
718 | todo.description().left(20 ) : | 718 | todo.description().left(20 ) : |
719 | todo.summary(); | 719 | todo.summary(); |
720 | } | 720 | } |
721 | /** | 721 | /** |
722 | * we take the sortorder( switch on it ) | 722 | * we take the sortorder( switch on it ) |
723 | * | 723 | * |
724 | */ | 724 | */ |
725 | int compareItems( Item d1, Item d2 ) { | 725 | int compareItems( Item d1, Item d2 ) { |
726 | bool seComp, sePrio, seDesc, seDeadline; | 726 | bool seComp, sePrio, seDesc, seDeadline; |
727 | seComp = sePrio = seDeadline = seDesc = false; | 727 | seComp = sePrio = seDeadline = seDesc = false; |
728 | int ret =0; | 728 | int ret =0; |
729 | OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1; | 729 | OPimTodoXMLContainer* con1 = (OPimTodoXMLContainer*)d1; |
730 | OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2; | 730 | OPimTodoXMLContainer* con2 = (OPimTodoXMLContainer*)d2; |
731 | 731 | ||
732 | /* same item */ | 732 | /* same item */ |
733 | if ( con1->todo.uid() == con2->todo.uid() ) | 733 | if ( con1->todo.uid() == con2->todo.uid() ) |
734 | return 0; | 734 | return 0; |
735 | 735 | ||
736 | switch ( m_sort ) { | 736 | switch ( m_sort ) { |
737 | /* completed */ | 737 | /* completed */ |
738 | case 0: { | 738 | case 0: { |
739 | ret = completed( con1->todo, con2->todo ); | 739 | ret = completed( con1->todo, con2->todo ); |
740 | seComp = TRUE; | 740 | seComp = TRUE; |
741 | break; | 741 | break; |
742 | } | 742 | } |
@@ -807,28 +807,28 @@ public: | |||
807 | return ret; | 807 | return ret; |
808 | } | 808 | } |
809 | } | 809 | } |
810 | 810 | ||
811 | return 0; | 811 | return 0; |
812 | } | 812 | } |
813 | private: | 813 | private: |
814 | bool m_asc; | 814 | bool m_asc; |
815 | int m_sort; | 815 | int m_sort; |
816 | 816 | ||
817 | }; | 817 | }; |
818 | 818 | ||
819 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | 819 | QArray<int> OPimTodoAccessXML::sorted( bool asc, int sortOrder, |
820 | int sortFilter, int cat ) { | 820 | int sortFilter, int cat ) { |
821 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); | 821 | OPimTodoXMLVector vector(m_events.count(), asc,sortOrder ); |
822 | QMap<int, OTodo>::Iterator it; | 822 | QMap<int, OPimTodo>::Iterator it; |
823 | int item = 0; | 823 | int item = 0; |
824 | 824 | ||
825 | bool bCat = sortFilter & 1 ? true : false; | 825 | bool bCat = sortFilter & 1 ? true : false; |
826 | bool bOnly = sortFilter & 2 ? true : false; | 826 | bool bOnly = sortFilter & 2 ? true : false; |
827 | bool comp = sortFilter & 4 ? true : false; | 827 | bool comp = sortFilter & 4 ? true : false; |
828 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 828 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
829 | 829 | ||
830 | /* show category */ | 830 | /* show category */ |
831 | /* -1 == unfiled */ | 831 | /* -1 == unfiled */ |
832 | if ( bCat && cat == -1 ) { | 832 | if ( bCat && cat == -1 ) { |
833 | if(!(*it).categories().isEmpty() ) | 833 | if(!(*it).categories().isEmpty() ) |
834 | continue; | 834 | continue; |
@@ -842,68 +842,68 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | |||
842 | continue; | 842 | continue; |
843 | } | 843 | } |
844 | */ | 844 | */ |
845 | if ( !(*it).isOverdue() && bOnly ) { | 845 | if ( !(*it).isOverdue() && bOnly ) { |
846 | continue; | 846 | continue; |
847 | } | 847 | } |
848 | 848 | ||
849 | if ((*it).isCompleted() && comp ) { | 849 | if ((*it).isCompleted() && comp ) { |
850 | continue; | 850 | continue; |
851 | } | 851 | } |
852 | 852 | ||
853 | 853 | ||
854 | OTodoXMLContainer* con = new OTodoXMLContainer(); | 854 | OPimTodoXMLContainer* con = new OPimTodoXMLContainer(); |
855 | con->todo = (*it); | 855 | con->todo = (*it); |
856 | vector.insert(item, con ); | 856 | vector.insert(item, con ); |
857 | item++; | 857 | item++; |
858 | } | 858 | } |
859 | vector.resize( item ); | 859 | vector.resize( item ); |
860 | /* sort it now */ | 860 | /* sort it now */ |
861 | vector.sort(); | 861 | vector.sort(); |
862 | /* now get the uids */ | 862 | /* now get the uids */ |
863 | QArray<int> array( vector.count() ); | 863 | QArray<int> array( vector.count() ); |
864 | for (uint i= 0; i < vector.count(); i++ ) { | 864 | for (uint i= 0; i < vector.count(); i++ ) { |
865 | array[i] = ( vector.at(i) )->todo.uid(); | 865 | array[i] = ( vector.at(i) )->todo.uid(); |
866 | } | 866 | } |
867 | return array; | 867 | return array; |
868 | }; | 868 | }; |
869 | void OTodoAccessXML::removeAllCompleted() { | 869 | void OPimTodoAccessXML::removeAllCompleted() { |
870 | QMap<int, OTodo> events = m_events; | 870 | QMap<int, OPimTodo> events = m_events; |
871 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { | 871 | for ( QMap<int, OPimTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { |
872 | if ( (*it).isCompleted() ) | 872 | if ( (*it).isCompleted() ) |
873 | events.remove( it.key() ); | 873 | events.remove( it.key() ); |
874 | } | 874 | } |
875 | m_events = events; | 875 | m_events = events; |
876 | } | 876 | } |
877 | QBitArray OTodoAccessXML::supports()const { | 877 | QBitArray OPimTodoAccessXML::supports()const { |
878 | static QBitArray ar = sup(); | 878 | static QBitArray ar = sup(); |
879 | return ar; | 879 | return ar; |
880 | } | 880 | } |
881 | QBitArray OTodoAccessXML::sup() { | 881 | QBitArray OPimTodoAccessXML::sup() { |
882 | QBitArray ar( OTodo::CompletedDate +1 ); | 882 | QBitArray ar( OPimTodo::CompletedDate +1 ); |
883 | ar.fill( true ); | 883 | ar.fill( true ); |
884 | ar[OTodo::CrossReference] = false; | 884 | ar[OPimTodo::CrossReference] = false; |
885 | ar[OTodo::State ] = false; | 885 | ar[OPimTodo::State ] = false; |
886 | ar[OTodo::Reminders] = false; | 886 | ar[OPimTodo::Reminders] = false; |
887 | ar[OTodo::Notifiers] = false; | 887 | ar[OPimTodo::Notifiers] = false; |
888 | ar[OTodo::Maintainer] = false; | 888 | ar[OPimTodo::Maintainer] = false; |
889 | 889 | ||
890 | return ar; | 890 | return ar; |
891 | } | 891 | } |
892 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const | 892 | QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const |
893 | { | 893 | { |
894 | QArray<int> m_currentQuery( m_events.count() ); | 894 | QArray<int> m_currentQuery( m_events.count() ); |
895 | uint arraycounter = 0; | 895 | uint arraycounter = 0; |
896 | 896 | ||
897 | QMap<int, OTodo>::ConstIterator it; | 897 | QMap<int, OPimTodo>::ConstIterator it; |
898 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | 898 | for (it = m_events.begin(); it != m_events.end(); ++it ) { |
899 | if ( it.data().match( r ) ) | 899 | if ( it.data().match( r ) ) |
900 | m_currentQuery[arraycounter++] = it.data().uid(); | 900 | m_currentQuery[arraycounter++] = it.data().uid(); |
901 | 901 | ||
902 | } | 902 | } |
903 | // Shrink to fit.. | 903 | // Shrink to fit.. |
904 | m_currentQuery.resize(arraycounter); | 904 | m_currentQuery.resize(arraycounter); |
905 | 905 | ||
906 | return m_currentQuery; | 906 | return m_currentQuery; |
907 | } | 907 | } |
908 | 908 | ||
909 | } | 909 | } |