summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/otodo.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/otodo.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/otodo.cpp294
1 files changed, 228 insertions, 66 deletions
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index 3eb0026..f534067 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -28,7 +28,11 @@
28*/ 28*/
29#include <qobject.h>
30#include <qshared.h>
31
32 29
30#include "otodo.h"
33 31
32/* OPIE */
33#include <opie2/opimstate.h>
34#include <opie2/orecur.h>
35#include <opie2/opimmaintainer.h>
36#include <opie2/opimnotifymanager.h>
37#include <opie2/opimresolver.h>
34#include <qpe/palmtopuidgen.h> 38#include <qpe/palmtopuidgen.h>
@@ -40,15 +44,13 @@
40 44
45/* QT */
46#include <qobject.h>
47#include <qshared.h>
41 48
42#include <opie2/opimstate.h> 49namespace Opie
43#include <opie2/orecur.h> 50{
44#include <opie2/opimmaintainer.h>
45#include <opie2/opimnotifymanager.h>
46#include <opie2/opimresolver.h>
47
48#include <opie2/otodo.h>
49
50namespace Opie {
51 51
52struct OTodo::OTodoData : public QShared { 52struct OTodo::OTodoData : public QShared
53 OTodoData() : QShared() { 53{
54 OTodoData() : QShared()
55 {
54 recur = 0; 56 recur = 0;
@@ -58,3 +60,4 @@ struct OTodo::OTodoData : public QShared {
58 }; 60 };
59 ~OTodoData() { 61 ~OTodoData()
62 {
60 delete recur; 63 delete recur;
@@ -80,2 +83,3 @@ struct OTodo::OTodoData : public QShared {
80 83
84
81OTodo::OTodo(const OTodo &event ) 85OTodo::OTodo(const OTodo &event )
@@ -86,6 +90,10 @@ OTodo::OTodo(const OTodo &event )
86} 90}
87OTodo::~OTodo() { 91
92
93OTodo::~OTodo()
94{
88 95
89// qWarning("~OTodo " ); 96// qWarning("~OTodo " );
90 if ( data->deref() ) { 97 if ( data->deref() )
98 {
91// qWarning("OTodo::dereffing"); 99// qWarning("OTodo::dereffing");
@@ -95,2 +103,4 @@ OTodo::~OTodo() {
95} 103}
104
105
96OTodo::OTodo(bool completed, int priority, 106OTodo::OTodo(bool completed, int priority,
@@ -116,2 +126,4 @@ OTodo::OTodo(bool completed, int priority,
116} 126}
127
128
117OTodo::OTodo(bool completed, int priority, 129OTodo::OTodo(bool completed, int priority,
@@ -137,14 +149,23 @@ OTodo::OTodo(bool completed, int priority,
137} 149}
150
151
138bool OTodo::match( const QRegExp &regExp )const 152bool OTodo::match( const QRegExp &regExp )const
139{ 153{
140 if( QString::number( data->priority ).find( regExp ) != -1 ){ 154 if ( QString::number( data->priority ).find( regExp ) != -1 )
155 {
141 setLastHitField( Priority ); 156 setLastHitField( Priority );
142 return true; 157 return true;
143 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 158 }
159 else if ( data->hasDate && data->date.toString().find( regExp ) != -1 )
160 {
144 setLastHitField( HasDate ); 161 setLastHitField( HasDate );
145 return true; 162 return true;
146 }else if(data->desc.find( regExp ) != -1 ){ 163 }
164 else if ( data->desc.find( regExp ) != -1 )
165 {
147 setLastHitField( Description ); 166 setLastHitField( Description );
148 return true; 167 return true;
149 }else if(data->sum.find( regExp ) != -1 ) { 168 }
169 else if ( data->sum.find( regExp ) != -1 )
170 {
150 setLastHitField( Summary ); 171 setLastHitField( Summary );
@@ -154,2 +175,4 @@ bool OTodo::match( const QRegExp &regExp )const
154} 175}
176
177
155bool OTodo::isCompleted() const 178bool OTodo::isCompleted() const
@@ -158,2 +181,4 @@ bool OTodo::isCompleted() const
158} 181}
182
183
159bool OTodo::hasDueDate() const 184bool OTodo::hasDueDate() const
@@ -162,8 +187,16 @@ bool OTodo::hasDueDate() const
162} 187}
163bool OTodo::hasStartDate()const { 188
189
190bool OTodo::hasStartDate() const
191{
164 return data->start.isValid(); 192 return data->start.isValid();
165} 193}
166bool OTodo::hasCompletedDate()const { 194
195
196bool OTodo::hasCompletedDate() const
197{
167 return data->completed.isValid(); 198 return data->completed.isValid();
168} 199}
200
201
169int OTodo::priority()const 202int OTodo::priority()const
@@ -172,2 +205,4 @@ int OTodo::priority()const
172} 205}
206
207
173QString OTodo::summary() const 208QString OTodo::summary() const
@@ -176,2 +211,4 @@ QString OTodo::summary() const
176} 211}
212
213
177ushort OTodo::progress() const 214ushort OTodo::progress() const
@@ -180,2 +217,4 @@ ushort OTodo::progress() const
180} 217}
218
219
181QDate OTodo::dueDate()const 220QDate OTodo::dueDate()const
@@ -184,8 +223,16 @@ QDate OTodo::dueDate()const
184} 223}
185QDate OTodo::startDate()const { 224
225
226QDate OTodo::startDate() const
227{
186 return data->start; 228 return data->start;
187} 229}
188QDate OTodo::completedDate()const { 230
231
232QDate OTodo::completedDate() const
233{
189 return data->completed; 234 return data->completed;
190} 235}
236
237
191QString OTodo::description()const 238QString OTodo::description()const
@@ -194,3 +241,6 @@ QString OTodo::description()const
194} 241}
195bool OTodo::hasState() const{ 242
243
244bool OTodo::hasState() const
245{
196 if (!data->state ) return false; 246 if (!data->state ) return false;
@@ -198,4 +248,8 @@ bool OTodo::hasState() const{
198} 248}
199OPimState OTodo::state()const { 249
200 if (!data->state ) { 250
251OPimState OTodo::state() const
252{
253 if ( !data->state )
254 {
201 OPimState state; 255 OPimState state;
@@ -206,3 +260,6 @@ OPimState OTodo::state()const {
206} 260}
207bool OTodo::hasRecurrence()const { 261
262
263bool OTodo::hasRecurrence() const
264{
208 if (!data->recur) return false; 265 if (!data->recur) return false;
@@ -210,3 +267,6 @@ bool OTodo::hasRecurrence()const {
210} 267}
211ORecur OTodo::recurrence()const { 268
269
270ORecur OTodo::recurrence() const
271{
212 if (!data->recur) return ORecur(); 272 if (!data->recur) return ORecur();
@@ -215,3 +275,6 @@ ORecur OTodo::recurrence()const {
215} 275}
216bool OTodo::hasMaintainer()const { 276
277
278bool OTodo::hasMaintainer() const
279{
217 if (!data->maintainer) return false; 280 if (!data->maintainer) return false;
@@ -220,3 +283,6 @@ bool OTodo::hasMaintainer()const {
220} 283}
221OPimMaintainer OTodo::maintainer()const { 284
285
286OPimMaintainer OTodo::maintainer() const
287{
222 if (!data->maintainer) return OPimMaintainer(); 288 if (!data->maintainer) return OPimMaintainer();
@@ -225,2 +291,4 @@ OPimMaintainer OTodo::maintainer()const {
225} 291}
292
293
226void OTodo::setCompleted( bool completed ) 294void OTodo::setCompleted( bool completed )
@@ -230,2 +298,4 @@ void OTodo::setCompleted( bool completed )
230} 298}
299
300
231void OTodo::setHasDueDate( bool hasDate ) 301void OTodo::setHasDueDate( bool hasDate )
@@ -235,2 +305,4 @@ void OTodo::setHasDueDate( bool hasDate )
235} 305}
306
307
236void OTodo::setDescription(const QString &desc ) 308void OTodo::setDescription(const QString &desc )
@@ -241,2 +313,4 @@ void OTodo::setDescription(const QString &desc )
241} 313}
314
315
242void OTodo::setSummary( const QString& sum ) 316void OTodo::setSummary( const QString& sum )
@@ -246,2 +320,4 @@ void OTodo::setSummary( const QString& sum )
246} 320}
321
322
247void OTodo::setPriority(int prio ) 323void OTodo::setPriority(int prio )
@@ -251,2 +327,4 @@ void OTodo::setPriority(int prio )
251} 327}
328
329
252void OTodo::setDueDate( const QDate& date ) 330void OTodo::setDueDate( const QDate& date )
@@ -256,3 +334,6 @@ void OTodo::setDueDate( const QDate& date )
256} 334}
257void OTodo::setStartDate( const QDate& date ) { 335
336
337void OTodo::setStartDate( const QDate& date )
338{
258 changeOrModify(); 339 changeOrModify();
@@ -260,3 +341,6 @@ void OTodo::setStartDate( const QDate& date ) {
260} 341}
261void OTodo::setCompletedDate( const QDate& date ) { 342
343
344void OTodo::setCompletedDate( const QDate& date )
345{
262 changeOrModify(); 346 changeOrModify();
@@ -264,3 +348,6 @@ void OTodo::setCompletedDate( const QDate& date ) {
264} 348}
265void OTodo::setState( const OPimState& state ) { 349
350
351void OTodo::setState( const OPimState& state )
352{
266 changeOrModify(); 353 changeOrModify();
@@ -271,3 +358,6 @@ void OTodo::setState( const OPimState& state ) {
271} 358}
272void OTodo::setRecurrence( const ORecur& rec) { 359
360
361void OTodo::setRecurrence( const ORecur& rec )
362{
273 changeOrModify(); 363 changeOrModify();
@@ -278,3 +368,6 @@ void OTodo::setRecurrence( const ORecur& rec) {
278} 368}
279void OTodo::setMaintainer( const OPimMaintainer& pim ) { 369
370
371void OTodo::setMaintainer( const OPimMaintainer& pim )
372{
280 changeOrModify(); 373 changeOrModify();
@@ -286,2 +379,4 @@ void OTodo::setMaintainer( const OPimMaintainer& pim ) {
286} 379}
380
381
287bool OTodo::isOverdue( ) 382bool OTodo::isOverdue( )
@@ -292,2 +387,4 @@ bool OTodo::isOverdue( )
292} 387}
388
389
293void OTodo::setProgress(ushort progress ) 390void OTodo::setProgress(ushort progress )
@@ -297,5 +394,10 @@ void OTodo::setProgress(ushort progress )
297} 394}
298QString OTodo::toShortText() const { 395
396
397QString OTodo::toShortText() const
398{
299 return summary(); 399 return summary();
300} 400}
401
402
301/*! 403/*!
@@ -310,3 +412,4 @@ QString OTodo::toRichText() const
310 text += "<b><h3><img src=\"todo/TodoList\"> "; 412 text += "<b><h3><img src=\"todo/TodoList\"> ";
311 if ( !summary().isEmpty() ) { 413 if ( !summary().isEmpty() )
414 {
312 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); 415 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" );
@@ -316,3 +419,4 @@ QString OTodo::toRichText() const
316 // description 419 // description
317 if( !description().isEmpty() ){ 420 if ( !description().isEmpty() )
421 {
318 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 422 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
@@ -346,3 +450,4 @@ QString OTodo::toRichText() const
346 // due date 450 // due date
347 if (hasDueDate() ){ 451 if ( hasDueDate() )
452 {
348 QDate dd = dueDate(); 453 QDate dd = dueDate();
@@ -368,3 +473,6 @@ QString OTodo::toRichText() const
368} 473}
369bool OTodo::hasNotifiers()const { 474
475
476bool OTodo::hasNotifiers() const
477{
370 if (!data->notifiers) return false; 478 if (!data->notifiers) return false;
@@ -372,3 +480,6 @@ bool OTodo::hasNotifiers()const {
372} 480}
373OPimNotifyManager& OTodo::notifiers() { 481
482
483OPimNotifyManager& OTodo::notifiers()
484{
374 if (!data->notifiers ) 485 if (!data->notifiers )
@@ -377,3 +488,6 @@ OPimNotifyManager& OTodo::notifiers() {
377} 488}
378const OPimNotifyManager& OTodo::notifiers()const{ 489
490
491const OPimNotifyManager& OTodo::notifiers() const
492{
379 if (!data->notifiers ) 493 if (!data->notifiers )
@@ -384,9 +498,15 @@ const OPimNotifyManager& OTodo::notifiers()const{
384 498
385bool OTodo::operator<( const OTodo &toDoEvent )const{ 499
500bool OTodo::operator<( const OTodo &toDoEvent ) const
501{
386 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 502 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
387 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 503 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
388 if( hasDueDate() && toDoEvent.hasDueDate() ){ 504 if ( hasDueDate() && toDoEvent.hasDueDate() )
389 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 505 {
506 if ( dueDate() == toDoEvent.dueDate() )
507 { // let's the priority decide
390 return priority() < toDoEvent.priority(); 508 return priority() < toDoEvent.priority();
391 }else{ 509 }
510 else
511 {
392 return dueDate() < toDoEvent.dueDate(); 512 return dueDate() < toDoEvent.dueDate();
@@ -396,2 +516,4 @@ bool OTodo::operator<( const OTodo &toDoEvent )const{
396} 516}
517
518
397bool OTodo::operator<=(const OTodo &toDoEvent )const 519bool OTodo::operator<=(const OTodo &toDoEvent )const
@@ -400,6 +522,10 @@ bool OTodo::operator<=(const OTodo &toDoEvent )const
400 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 522 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
401 if( hasDueDate() && toDoEvent.hasDueDate() ){ 523 if ( hasDueDate() && toDoEvent.hasDueDate() )
402 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 524 {
525 if ( dueDate() == toDoEvent.dueDate() )
526 { // let's the priority decide
403 return priority() <= toDoEvent.priority(); 527 return priority() <= toDoEvent.priority();
404 }else{ 528 }
529 else
530 {
405 return dueDate() <= toDoEvent.dueDate(); 531 return dueDate() <= toDoEvent.dueDate();
@@ -409,2 +535,4 @@ bool OTodo::operator<=(const OTodo &toDoEvent )const
409} 535}
536
537
410bool OTodo::operator>(const OTodo &toDoEvent )const 538bool OTodo::operator>(const OTodo &toDoEvent )const
@@ -413,6 +541,10 @@ bool OTodo::operator>(const OTodo &toDoEvent )const
413 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 541 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
414 if( hasDueDate() && toDoEvent.hasDueDate() ){ 542 if ( hasDueDate() && toDoEvent.hasDueDate() )
415 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 543 {
544 if ( dueDate() == toDoEvent.dueDate() )
545 { // let's the priority decide
416 return priority() > toDoEvent.priority(); 546 return priority() > toDoEvent.priority();
417 }else{ 547 }
548 else
549 {
418 return dueDate() > toDoEvent.dueDate(); 550 return dueDate() > toDoEvent.dueDate();
@@ -422,2 +554,4 @@ bool OTodo::operator>(const OTodo &toDoEvent )const
422} 554}
555
556
423bool OTodo::operator>=(const OTodo &toDoEvent )const 557bool OTodo::operator>=(const OTodo &toDoEvent )const
@@ -426,6 +560,10 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
426 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 560 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
427 if( hasDueDate() && toDoEvent.hasDueDate() ){ 561 if ( hasDueDate() && toDoEvent.hasDueDate() )
428 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 562 {
563 if ( dueDate() == toDoEvent.dueDate() )
564 { // let's the priority decide
429 return priority() > toDoEvent.priority(); 565 return priority() > toDoEvent.priority();
430 }else{ 566 }
567 else
568 {
431 return dueDate() > toDoEvent.dueDate(); 569 return dueDate() > toDoEvent.dueDate();
@@ -435,2 +573,4 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
435} 573}
574
575
436bool OTodo::operator==(const OTodo &toDoEvent )const 576bool OTodo::operator==(const OTodo &toDoEvent )const
@@ -449,6 +589,10 @@ bool OTodo::operator==(const OTodo &toDoEvent )const
449} 589}
450void OTodo::deref() { 590
591
592void OTodo::deref()
593{
451 594
452// qWarning("deref in ToDoEvent"); 595// qWarning("deref in ToDoEvent");
453 if ( data->deref() ) { 596 if ( data->deref() )
597 {
454// qWarning("deleting"); 598// qWarning("deleting");
@@ -458,2 +602,4 @@ void OTodo::deref() {
458} 602}
603
604
459OTodo &OTodo::operator=(const OTodo &item ) 605OTodo &OTodo::operator=(const OTodo &item )
@@ -471,3 +617,5 @@ OTodo &OTodo::operator=(const OTodo &item )
471 617
472QMap<int, QString> OTodo::toMap() const { 618
619QMap<int, QString> OTodo::toMap() const
620{
473 QMap<int, QString> map; 621 QMap<int, QString> map;
@@ -494,2 +642,3 @@ QMap<int, QString> OTodo::toMap() const {
494 642
643
495/** 644/**
@@ -499,4 +648,6 @@ QMap<int, QString> OTodo::toMap() const {
499 */ 648 */
500void OTodo::changeOrModify() { 649void OTodo::changeOrModify()
501 if ( data->count != 1 ) { 650{
651 if ( data->count != 1 )
652 {
502 qWarning("changeOrModify"); 653 qWarning("changeOrModify");
@@ -508,2 +659,4 @@ void OTodo::changeOrModify() {
508} 659}
660
661
509// WATCHOUT 662// WATCHOUT
@@ -513,3 +666,4 @@ void OTodo::changeOrModify() {
513 */ 666 */
514void OTodo::copy( OTodoData* src, OTodoData* dest ) { 667void OTodo::copy( OTodoData* src, OTodoData* dest )
668{
515 dest->date = src->date; 669 dest->date = src->date;
@@ -538,6 +692,12 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
538} 692}
539QString OTodo::type() const { 693
694
695QString OTodo::type() const
696{
540 return QString::fromLatin1("OTodo"); 697 return QString::fromLatin1("OTodo");
541} 698}
542QString OTodo::recordField(int /*id*/ )const { 699
700
701QString OTodo::recordField( int /*id*/ ) const
702{
543 return QString::null; 703 return QString::null;
@@ -545,3 +705,5 @@ QString OTodo::recordField(int /*id*/ )const {
545 705
546int OTodo::rtti(){ 706
707int OTodo::rtti()
708{
547 return OPimResolver::TodoList; 709 return OPimResolver::TodoList;