summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp23
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp6
-rw-r--r--libopie2/opiepim/core/opimrecord.h8
-rw-r--r--libopie2/opiepim/ocontact.cpp10
-rw-r--r--libopie2/opiepim/oevent.cpp11
-rw-r--r--libopie2/opiepim/oevent.h1
-rw-r--r--libopie2/opiepim/otodo.cpp13
-rw-r--r--libopie2/opiepim/otodo.h1
8 files changed, 47 insertions, 26 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 2b62f0d..3d15354 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -436,212 +436,235 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
436 qWarning("alarm[0]: %s %s", alarm[0].latin1(), OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); 436 qWarning("alarm[0]: %s %s", alarm[0].latin1(), OConversion::dateTimeFromString( alarm[0] ).toString().latin1() );
437 OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); 437 OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() );
438 manager.add( al ); 438 manager.add( al );
439 } 439 }
440 } 440 }
441 break; 441 break;
442 case OTodo::Reminders:{ 442 case OTodo::Reminders:{
443 OPimNotifyManager &manager = ev.notifiers(); 443 OPimNotifyManager &manager = ev.notifiers();
444 QStringList rems = QStringList::split(";", val ); 444 QStringList rems = QStringList::split(";", val );
445 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { 445 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
446 OPimReminder rem( (*it).toInt() ); 446 OPimReminder rem( (*it).toInt() );
447 manager.add( rem ); 447 manager.add( rem );
448 } 448 }
449 } 449 }
450 break; 450 break;
451 case OTodo::CrossReference: 451 case OTodo::CrossReference:
452 { 452 {
453 /* 453 /*
454 * A cross refernce looks like 454 * A cross refernce looks like
455 * appname,id;appname,id 455 * appname,id;appname,id
456 * we need to split it up 456 * we need to split it up
457 */ 457 */
458 QStringList refs = QStringList::split(';', val ); 458 QStringList refs = QStringList::split(';', val );
459 QStringList::Iterator strIt; 459 QStringList::Iterator strIt;
460 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { 460 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
461 int pos = (*strIt).find(','); 461 int pos = (*strIt).find(',');
462 if ( pos > -1 ) 462 if ( pos > -1 )
463 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); 463 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
464 464
465 } 465 }
466 break; 466 break;
467 } 467 }
468 /* Recurrence stuff below + post processing later */ 468 /* Recurrence stuff below + post processing later */
469 case FRType: 469 case FRType:
470 if ( val == "Daily" ) 470 if ( val == "Daily" )
471 recur()->setType( ORecur::Daily ); 471 recur()->setType( ORecur::Daily );
472 else if ( val == "Weekly" ) 472 else if ( val == "Weekly" )
473 recur()->setType( ORecur::Weekly); 473 recur()->setType( ORecur::Weekly);
474 else if ( val == "MonthlyDay" ) 474 else if ( val == "MonthlyDay" )
475 recur()->setType( ORecur::MonthlyDay ); 475 recur()->setType( ORecur::MonthlyDay );
476 else if ( val == "MonthlyDate" ) 476 else if ( val == "MonthlyDate" )
477 recur()->setType( ORecur::MonthlyDate ); 477 recur()->setType( ORecur::MonthlyDate );
478 else if ( val == "Yearly" ) 478 else if ( val == "Yearly" )
479 recur()->setType( ORecur::Yearly ); 479 recur()->setType( ORecur::Yearly );
480 else 480 else
481 recur()->setType( ORecur::NoRepeat ); 481 recur()->setType( ORecur::NoRepeat );
482 break; 482 break;
483 case FRWeekdays: 483 case FRWeekdays:
484 recur()->setDays( val.toInt() ); 484 recur()->setDays( val.toInt() );
485 break; 485 break;
486 case FRPosition: 486 case FRPosition:
487 recur()->setPosition( val.toInt() ); 487 recur()->setPosition( val.toInt() );
488 break; 488 break;
489 case FRFreq: 489 case FRFreq:
490 recur()->setFrequency( val.toInt() ); 490 recur()->setFrequency( val.toInt() );
491 break; 491 break;
492 case FRHasEndDate: 492 case FRHasEndDate:
493 recur()->setHasEndDate( val.toInt() ); 493 recur()->setHasEndDate( val.toInt() );
494 break; 494 break;
495 case FREndDate: { 495 case FREndDate: {
496 rp_end = (time_t) val.toLong(); 496 rp_end = (time_t) val.toLong();
497 break; 497 break;
498 } 498 }
499 default: 499 default:
500 ev.setCustomField( attr, val );
500 break; 501 break;
501 } 502 }
502} 503}
504
505// from PalmtopRecord... GPL ### FIXME
506namespace {
507QString customToXml(const QMap<QString, QString>& customMap )
508{
509 //qWarning(QString("writing custom %1").arg(customMap.count()));
510 QString buf(" ");
511 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin();
512 cit != customMap.end(); ++cit) {
513 // qWarning(".ITEM.");
514 buf += cit.key();
515 buf += "=\"";
516 buf += Qtopia::escapeString(cit.data());
517 buf += "\" ";
518 }
519 return buf;
520}
521
522
523}
524
503QString OTodoAccessXML::toString( const OTodo& ev )const { 525QString OTodoAccessXML::toString( const OTodo& ev )const {
504 QString str; 526 QString str;
505 527
506 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; 528 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
507 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; 529 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" ";
508 str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; 530 str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
509 str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; 531 str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
510 532
511 str += "Categories=\"" + toString( ev.categories() ) + "\" "; 533 str += "Categories=\"" + toString( ev.categories() ) + "\" ";
512 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; 534 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
513 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; 535 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
514 536
515 if ( ev.hasDueDate() ) { 537 if ( ev.hasDueDate() ) {
516 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; 538 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
517 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; 539 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
518 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; 540 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
519 } 541 }
520// qWarning( "Uid %d", ev.uid() ); 542// qWarning( "Uid %d", ev.uid() );
521 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 543 str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
522 544
523// append the extra options 545// append the extra options
524 /* FIXME Qtopia::Record this is currently not 546 /* FIXME Qtopia::Record this is currently not
525 * possible you can set custom fields 547 * possible you can set custom fields
526 * but don' iterate over the list 548 * but don' iterate over the list
527 * I may do #define private protected 549 * I may do #define private protected
528 * for this case - cough --zecke 550 * for this case - cough --zecke
529 */ 551 */
530 /* 552 /*
531 QMap<QString, QString> extras = ev.extras(); 553 QMap<QString, QString> extras = ev.extras();
532 QMap<QString, QString>::Iterator extIt; 554 QMap<QString, QString>::Iterator extIt;
533 for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) 555 for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
534 str += extIt.key() + "=\"" + extIt.data() + "\" "; 556 str += extIt.key() + "=\"" + extIt.data() + "\" ";
535 */ 557 */
536 // cross refernce 558 // cross refernce
537 if ( ev.hasRecurrence() ) { 559 if ( ev.hasRecurrence() ) {
538 str += ev.recurrence().toString(); 560 str += ev.recurrence().toString();
539 } 561 }
540 if ( ev.hasStartDate() ) 562 if ( ev.hasStartDate() )
541 str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; 563 str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" ";
542 if ( ev.hasCompletedDate() ) 564 if ( ev.hasCompletedDate() )
543 str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; 565 str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" ";
544 if ( ev.hasState() ) 566 if ( ev.hasState() )
545 str += "State=\""+QString::number( ev.state().state() )+"\" "; 567 str += "State=\""+QString::number( ev.state().state() )+"\" ";
546 568
547 /* 569 /*
548 * save reminders and notifiers! 570 * save reminders and notifiers!
549 * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:.... 571 * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:....
550 */ 572 */
551 if ( ev.hasNotifiers() ) { 573 if ( ev.hasNotifiers() ) {
552 OPimNotifyManager manager = ev.notifiers(); 574 OPimNotifyManager manager = ev.notifiers();
553 OPimNotifyManager::Alarms alarms = manager.alarms(); 575 OPimNotifyManager::Alarms alarms = manager.alarms();
554 if (!alarms.isEmpty() ) { 576 if (!alarms.isEmpty() ) {
555 QStringList als; 577 QStringList als;
556 OPimNotifyManager::Alarms::Iterator it = alarms.begin(); 578 OPimNotifyManager::Alarms::Iterator it = alarms.begin();
557 for ( ; it != alarms.end(); ++it ) { 579 for ( ; it != alarms.end(); ++it ) {
558 /* only if time is valid */ 580 /* only if time is valid */
559 if ( (*it).dateTime().isValid() ) { 581 if ( (*it).dateTime().isValid() ) {
560 als << OConversion::dateTimeToString( (*it).dateTime() ) 582 als << OConversion::dateTimeToString( (*it).dateTime() )
561 + ":" + QString::number( (*it).duration() ) 583 + ":" + QString::number( (*it).duration() )
562 + ":" + QString::number( (*it).sound() ) 584 + ":" + QString::number( (*it).sound() )
563 + ":"; 585 + ":";
564 } 586 }
565 } 587 }
566 // now write the list 588 // now write the list
567 qWarning("als: %s", als.join("____________").latin1() ); 589 qWarning("als: %s", als.join("____________").latin1() );
568 str += "Alarms=\""+als.join(";") +"\" "; 590 str += "Alarms=\""+als.join(";") +"\" ";
569 } 591 }
570 592
571 /* 593 /*
572 * now the same for reminders but more easy. We just save the uid of the OEvent. 594 * now the same for reminders but more easy. We just save the uid of the OEvent.
573 */ 595 */
574 OPimNotifyManager::Reminders reminders = manager.reminders(); 596 OPimNotifyManager::Reminders reminders = manager.reminders();
575 if (!reminders.isEmpty() ) { 597 if (!reminders.isEmpty() ) {
576 OPimNotifyManager::Reminders::Iterator it = reminders.begin(); 598 OPimNotifyManager::Reminders::Iterator it = reminders.begin();
577 QStringList records; 599 QStringList records;
578 for ( ; it != reminders.end(); ++it ) { 600 for ( ; it != reminders.end(); ++it ) {
579 records << QString::number( (*it).recordUid() ); 601 records << QString::number( (*it).recordUid() );
580 } 602 }
581 str += "Reminders=\""+ records.join(";") +"\" "; 603 str += "Reminders=\""+ records.join(";") +"\" ";
582 } 604 }
583 } 605 }
606 str += customToXml( ev.toExtraMap() );
584 607
585 608
586 return str; 609 return str;
587} 610}
588QString OTodoAccessXML::toString( const QArray<int>& ints ) const { 611QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
589 return Qtopia::Record::idsToString( ints ); 612 return Qtopia::Record::idsToString( ints );
590} 613}
591 614
592/* internal class for sorting 615/* internal class for sorting
593 * 616 *
594 * Inspired by todoxmlio.cpp from TT 617 * Inspired by todoxmlio.cpp from TT
595 */ 618 */
596 619
597struct OTodoXMLContainer { 620struct OTodoXMLContainer {
598 OTodo todo; 621 OTodo todo;
599}; 622};
600 623
601namespace { 624namespace {
602 inline QString string( const OTodo& todo) { 625 inline QString string( const OTodo& todo) {
603 return todo.summary().isEmpty() ? 626 return todo.summary().isEmpty() ?
604 todo.description().left(20 ) : 627 todo.description().left(20 ) :
605 todo.summary(); 628 todo.summary();
606 } 629 }
607 inline int completed( const OTodo& todo1, const OTodo& todo2) { 630 inline int completed( const OTodo& todo1, const OTodo& todo2) {
608 int ret = 0; 631 int ret = 0;
609 if ( todo1.isCompleted() ) ret++; 632 if ( todo1.isCompleted() ) ret++;
610 if ( todo2.isCompleted() ) ret--; 633 if ( todo2.isCompleted() ) ret--;
611 return ret; 634 return ret;
612 } 635 }
613 inline int priority( const OTodo& t1, const OTodo& t2) { 636 inline int priority( const OTodo& t1, const OTodo& t2) {
614 return ( t1.priority() - t2.priority() ); 637 return ( t1.priority() - t2.priority() );
615 } 638 }
616 inline int description( const OTodo& t1, const OTodo& t2) { 639 inline int description( const OTodo& t1, const OTodo& t2) {
617 return QString::compare( string(t1), string(t2) ); 640 return QString::compare( string(t1), string(t2) );
618 } 641 }
619 inline int deadline( const OTodo& t1, const OTodo& t2) { 642 inline int deadline( const OTodo& t1, const OTodo& t2) {
620 int ret = 0; 643 int ret = 0;
621 if ( t1.hasDueDate() && 644 if ( t1.hasDueDate() &&
622 t2.hasDueDate() ) 645 t2.hasDueDate() )
623 ret = t2.dueDate().daysTo( t1.dueDate() ); 646 ret = t2.dueDate().daysTo( t1.dueDate() );
624 else if ( t1.hasDueDate() ) 647 else if ( t1.hasDueDate() )
625 ret = -1; 648 ret = -1;
626 else if ( t2.hasDueDate() ) 649 else if ( t2.hasDueDate() )
627 ret = 1; 650 ret = 1;
628 else 651 else
629 ret = 0; 652 ret = 0;
630 653
631 return ret; 654 return ret;
632 } 655 }
633 656
634}; 657};
635 658
636/* 659/*
637 * Returns: 660 * Returns:
638 * 0 if item1 == item2 661 * 0 if item1 == item2
639 * 662 *
640 * non-zero if item1 != item2 663 * non-zero if item1 != item2
641 * 664 *
642 * This function returns int rather than bool so that reimplementations 665 * This function returns int rather than bool so that reimplementations
643 * can return one of three values and use it to sort by: 666 * can return one of three values and use it to sort by:
644 * 667 *
645 * 0 if item1 == item2 668 * 0 if item1 == item2
646 * 669 *
647 * > 0 (positive integer) if item1 > item2 670 * > 0 (positive integer) if item1 > item2
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 0c9734d..2365748 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -113,64 +113,70 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) {
113 113
114 /* 114 /*
115 * now we do the X-Ref stuff 115 * now we do the X-Ref stuff
116 */ 116 */
117 OPimXRef xref; 117 OPimXRef xref;
118 stream >> UInt; 118 stream >> UInt;
119 for ( uint i = 0; i < UInt; i++ ) { 119 for ( uint i = 0; i < UInt; i++ ) {
120 xref.setPartner( OPimXRef::One, partner( stream ) ); 120 xref.setPartner( OPimXRef::One, partner( stream ) );
121 xref.setPartner( OPimXRef::Two, partner( stream ) ); 121 xref.setPartner( OPimXRef::Two, partner( stream ) );
122 m_xrefman.add( xref ); 122 m_xrefman.add( xref );
123 } 123 }
124 124
125 return true; 125 return true;
126} 126}
127bool OPimRecord::saveToStream( QDataStream& stream )const { 127bool OPimRecord::saveToStream( QDataStream& stream )const {
128 /** UIDs */ 128 /** UIDs */
129 129
130 stream << uid(); 130 stream << uid();
131 131
132 /** Categories */ 132 /** Categories */
133 stream << categories().count(); 133 stream << categories().count();
134 for ( uint i = 0; i < categories().count(); i++ ) { 134 for ( uint i = 0; i < categories().count(); i++ ) {
135 stream << categories()[i]; 135 stream << categories()[i];
136 } 136 }
137 137
138 /* 138 /*
139 * first the XRef count 139 * first the XRef count
140 * then the xrefs 140 * then the xrefs
141 */ 141 */
142 stream << m_xrefman.list().count(); 142 stream << m_xrefman.list().count();
143 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); 143 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
144 it != m_xrefman.list().end(); ++it ) { 144 it != m_xrefman.list().end(); ++it ) {
145 flush( (*it).partner( OPimXRef::One), stream ); 145 flush( (*it).partner( OPimXRef::One), stream );
146 flush( (*it).partner( OPimXRef::Two), stream ); 146 flush( (*it).partner( OPimXRef::Two), stream );
147 } 147 }
148 return true; 148 return true;
149} 149}
150void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ 150void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{
151 str << par.service(); 151 str << par.service();
152 str << par.uid(); 152 str << par.uid();
153 str << par.field(); 153 str << par.field();
154} 154}
155OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { 155OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
156 OPimXRefPartner par; 156 OPimXRefPartner par;
157 QString str; 157 QString str;
158 int i; 158 int i;
159 159
160 stream >> str; 160 stream >> str;
161 par.setService( str ); 161 par.setService( str );
162 162
163 stream >> i; 163 stream >> i;
164 par.setUid( i ); 164 par.setUid( i );
165 165
166 stream >> i ; 166 stream >> i ;
167 par.setField( i ); 167 par.setField( i );
168 168
169 return par; 169 return par;
170} 170}
171void OPimRecord::setLastHitField( int lastHit )const { 171void OPimRecord::setLastHitField( int lastHit )const {
172 m_lastHit = lastHit; 172 m_lastHit = lastHit;
173} 173}
174int OPimRecord::lastHitField()const{ 174int OPimRecord::lastHitField()const{
175 return m_lastHit; 175 return m_lastHit;
176} 176}
177QMap<QString, QString> OPimRecord::toExtraMap()const {
178 return customMap;
179}
180void OPimRecord::setExtraMap( const QMap<QString, QString>& map) {
181 customMap = map;
182}
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index 494c78e..563b19c 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -1,151 +1,157 @@
1#ifndef OPIE_PIM_RECORD_H 1#ifndef OPIE_PIM_RECORD_H
2#define OPIE_PIM_RECORD_H 2#define OPIE_PIM_RECORD_H
3 3
4#include <qdatastream.h> 4#include <qdatastream.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9/*
10 * we need to get customMap which is private...
11 */
12#define private protected
9#include <qpe/palmtoprecord.h> 13#include <qpe/palmtoprecord.h>
14#undef private
10 15
11#include <opie/opimxrefmanager.h> 16#include <opie/opimxrefmanager.h>
12 17
13/** 18/**
14 * This is the base class for 19 * This is the base class for
15 * all PIM Records 20 * all PIM Records
16 * 21 *
17 */ 22 */
18class OPimRecord : public Qtopia::Record { 23class OPimRecord : public Qtopia::Record {
19public: 24public:
20 /** 25 /**
21 * c'tor 26 * c'tor
22 * uid of 0 isEmpty 27 * uid of 0 isEmpty
23 * uid of 1 will be assigned a new one 28 * uid of 1 will be assigned a new one
24 */ 29 */
25 OPimRecord(int uid = 0); 30 OPimRecord(int uid = 0);
26 ~OPimRecord(); 31 ~OPimRecord();
27 32
28 /** 33 /**
29 * copy c'tor 34 * copy c'tor
30 */ 35 */
31 OPimRecord( const OPimRecord& rec ); 36 OPimRecord( const OPimRecord& rec );
32 37
33 /** 38 /**
34 * copy operator 39 * copy operator
35 */ 40 */
36 OPimRecord &operator=( const OPimRecord& ); 41 OPimRecord &operator=( const OPimRecord& );
37 42
38 /** 43 /**
39 * category names resolved 44 * category names resolved
40 */ 45 */
41 QStringList categoryNames( const QString& appname )const; 46 QStringList categoryNames( const QString& appname )const;
42 47
43 /** 48 /**
44 * set category names they will be resolved 49 * set category names they will be resolved
45 */ 50 */
46 void setCategoryNames( const QStringList& ); 51 void setCategoryNames( const QStringList& );
47 52
48 /** 53 /**
49 * addCategoryName adds a name 54 * addCategoryName adds a name
50 * to the internal category list 55 * to the internal category list
51 */ 56 */
52 void addCategoryName( const QString& ); 57 void addCategoryName( const QString& );
53 58
54 /** 59 /**
55 * if a Record isEmpty 60 * if a Record isEmpty
56 * it's empty if it's 0 61 * it's empty if it's 0
57 */ 62 */
58 virtual bool isEmpty()const; 63 virtual bool isEmpty()const;
59 64
60 /** 65 /**
61 * toRichText summary 66 * toRichText summary
62 */ 67 */
63 virtual QString toRichText()const = 0; 68 virtual QString toRichText()const = 0;
64 69
65 /** 70 /**
66 * a small one line summary 71 * a small one line summary
67 */ 72 */
68 virtual QString toShortText()const = 0; 73 virtual QString toShortText()const = 0;
69 74
70 /** 75 /**
71 * the name of the Record 76 * the name of the Record
72 */ 77 */
73 virtual QString type()const = 0; 78 virtual QString type()const = 0;
74 79
75 /** 80 /**
76 * matches the Records the regular expression? 81 * matches the Records the regular expression?
77 */ 82 */
78 virtual bool match( const QString &regexp ) const 83 virtual bool match( const QString &regexp ) const
79 {setLastHitField( -1 ); 84 {setLastHitField( -1 );
80 return Qtopia::Record::match(QRegExp(regexp));}; 85 return Qtopia::Record::match(QRegExp(regexp));};
81 86
82 /** 87 /**
83 * if implemented this function returns which item has been 88 * if implemented this function returns which item has been
84 * last hit by the match() function. 89 * last hit by the match() function.
85 * or -1 if not implemented or no hit has occured 90 * or -1 if not implemented or no hit has occured
86 */ 91 */
87 int lastHitField()const; 92 int lastHitField()const;
88 93
89 /** 94 /**
90 * converts the internal structure to a map 95 * converts the internal structure to a map
91 */ 96 */
92 virtual QMap<int, QString> toMap()const = 0; 97 virtual QMap<int, QString> toMap()const = 0;
93 98
94 /** 99 /**
95 * key value representation of extra items 100 * key value representation of extra items
96 */ 101 */
97 virtual QMap<QString, QString> toExtraMap()const = 0; 102 QMap<QString, QString> toExtraMap()const;
103 void setExtraMap( const QMap<QString, QString>& );
98 104
99 /** 105 /**
100 * the name for a recordField 106 * the name for a recordField
101 */ 107 */
102 virtual QString recordField(int)const = 0; 108 virtual QString recordField(int)const = 0;
103 109
104 /** 110 /**
105 * returns a reference of the 111 * returns a reference of the
106 * Cross Reference Manager 112 * Cross Reference Manager
107 * Partner 'One' is THIS PIM RECORD! 113 * Partner 'One' is THIS PIM RECORD!
108 * 'Two' is the Partner where we link to 114 * 'Two' is the Partner where we link to
109 */ 115 */
110 OPimXRefManager& xrefmanager(); 116 OPimXRefManager& xrefmanager();
111 117
112 /** 118 /**
113 * set the uid 119 * set the uid
114 */ 120 */
115 virtual void setUid( int uid ); 121 virtual void setUid( int uid );
116 122
117 /* 123 /*
118 * used inside the Templates for casting 124 * used inside the Templates for casting
119 * REIMPLEMENT in your .... 125 * REIMPLEMENT in your ....
120 */ 126 */
121 static int rtti(); 127 static int rtti();
122 128
123 /** 129 /**
124 * some marshalling and de marshalling code 130 * some marshalling and de marshalling code
125 * saves the OPimRecord 131 * saves the OPimRecord
126 * to and from a DataStream 132 * to and from a DataStream
127 */ 133 */
128 virtual bool loadFromStream(QDataStream& ); 134 virtual bool loadFromStream(QDataStream& );
129 virtual bool saveToStream( QDataStream& stream )const; 135 virtual bool saveToStream( QDataStream& stream )const;
130 136
131protected: 137protected:
132 // need to be const cause it is called from const methods 138 // need to be const cause it is called from const methods
133 mutable int m_lastHit; 139 mutable int m_lastHit;
134 void setLastHitField( int lastHit )const; 140 void setLastHitField( int lastHit )const;
135 Qtopia::UidGen &uidGen(); 141 Qtopia::UidGen &uidGen();
136// QString crossToString()const; 142// QString crossToString()const;
137 143
138private: 144private:
139 class OPimRecordPrivate; 145 class OPimRecordPrivate;
140 OPimRecordPrivate *d; 146 OPimRecordPrivate *d;
141 OPimXRefManager m_xrefman; 147 OPimXRefManager m_xrefman;
142 static Qtopia::UidGen m_uidGen; 148 static Qtopia::UidGen m_uidGen;
143 149
144private: 150private:
145 void flush( const OPimXRefPartner&, QDataStream& stream )const; 151 void flush( const OPimXRefPartner&, QDataStream& stream )const;
146 OPimXRefPartner partner( QDataStream& ); 152 OPimXRefPartner partner( QDataStream& );
147}; 153};
148 154
149 155
150 156
151#endif 157#endif
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index a2fb68c..be4ce0a 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -380,129 +380,129 @@ OContact::~OContact()
380 380
381/*! \fn QString OContact::nickname() const 381/*! \fn QString OContact::nickname() const
382 Returns the nickname of the contact. 382 Returns the nickname of the contact.
383*/ 383*/
384 384
385/*! \fn QString OContact::children() const 385/*! \fn QString OContact::children() const
386 Returns the children of the contact. 386 Returns the children of the contact.
387*/ 387*/
388 388
389/*! \fn QString OContact::notes() const 389/*! \fn QString OContact::notes() const
390 Returns the notes relating to the the contact. 390 Returns the notes relating to the the contact.
391*/ 391*/
392 392
393/*! \fn QString OContact::groups() const 393/*! \fn QString OContact::groups() const
394 \internal 394 \internal
395 Returns the groups for the contact. 395 Returns the groups for the contact.
396*/ 396*/
397 397
398/*! \fn QStringList OContact::groupList() const 398/*! \fn QStringList OContact::groupList() const
399 \internal 399 \internal
400*/ 400*/
401 401
402/*! \fn QString OContact::field(int) const 402/*! \fn QString OContact::field(int) const
403 \internal 403 \internal
404*/ 404*/
405 405
406/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 406/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null )
407 \internal 407 \internal
408*/ 408*/
409 409
410/*! \fn void OContact::setUid( int id ) 410/*! \fn void OContact::setUid( int id )
411 \internal 411 \internal
412 Sets the uid for this record to \a id. 412 Sets the uid for this record to \a id.
413*/ 413*/
414 414
415/*! \enum OContact::journal_action 415/*! \enum OContact::journal_action
416 \internal 416 \internal
417*/ 417*/
418 418
419/*! 419/*!
420 \internal 420 \internal
421*/ 421*/
422QMap<int, QString> OContact::toMap() const 422QMap<int, QString> OContact::toMap() const
423{ 423{
424 QMap<int, QString> map = mMap; 424 QMap<int, QString> map = mMap;
425 QString cats = idsToString( categories() ); 425 QString cats = idsToString( categories() );
426 if ( !cats.isEmpty() ) 426 if ( !cats.isEmpty() )
427 map.insert( Qtopia::AddressCategory, cats ); 427 map.insert( Qtopia::AddressCategory, cats );
428 return map; 428 return map;
429} 429}
430 430
431/*! 431/*!
432 Returns a rich text formatted QString representing the contents the contact. 432 Returns a rich text formatted QString representing the contents the contact.
433*/ 433*/
434QString OContact::toRichText() const 434QString OContact::toRichText() const
435{ 435{
436 QString text; 436 QString text;
437 QString value, comp, state; 437 QString value, comp, state;
438 QString str; 438 QString str;
439 bool marker = false; 439 bool marker = false;
440 440
441 // name, jobtitle and company 441 // name, jobtitle and company
442 if ( !(value = fullName()).isEmpty() ) 442 if ( !(value = fullName()).isEmpty() )
443 text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>"; 443 text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>";
444 444
445 if ( !(value = jobTitle()).isEmpty() ) 445 if ( !(value = jobTitle()).isEmpty() )
446 text += Qtopia::escapeString(value) + "<br>"; 446 text += Qtopia::escapeString(value) + "<br>";
447 447
448 comp = company(); 448 comp = company();
449 if ( !(value = department()).isEmpty() ) { 449 if ( !(value = department()).isEmpty() ) {
450 text += Qtopia::escapeString(value); 450 text += Qtopia::escapeString(value);
451 if ( comp ) 451 if ( comp )
452 text += ", "; 452 text += ", ";
453 else 453 else
454 text += "<br>"; 454 text += "<br>";
455 } 455 }
456 if ( !comp.isEmpty() ) 456 if ( !comp.isEmpty() )
457 text += Qtopia::escapeString(comp) + "<br>"; 457 text += Qtopia::escapeString(comp) + "<br>";
458 458
459 text += "<hr><br>"; 459 text += "<hr><br>";
460 460
461 // defailt email 461 // defailt email
462 QString defEmail = defaultEmail(); 462 QString defEmail = defaultEmail();
463 if ( !defEmail.isEmpty() ) 463 if ( !defEmail.isEmpty() )
464 text += "<b><img src=\"addressbook/email\">" + QObject::tr("Default Email: ") + "</b>" 464 text += "<b><img src=\"addressbook/email\">" + QObject::tr("Default Email: ") + "</b>"
465 + Qtopia::escapeString(defEmail) + "<br>"; 465 + Qtopia::escapeString(defEmail) + "<br>";
466 466
467 text += "<br>"; 467 text += "<br>";
468 468
469 // business address 469 // business address
470 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 470 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
471 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 471 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
472 text += QObject::tr( "<b>Work Address:</b>" ); 472 text += QObject::tr( "<b>Work Address:</b>" );
473 text += "<br>"; 473 text += "<br>";
474 marker = true; 474 marker = true;
475 } 475 }
476 476
477 if ( !(value = businessStreet()).isEmpty() ) 477 if ( !(value = businessStreet()).isEmpty() )
478 text += Qtopia::escapeString(value) + "<br>"; 478 text += Qtopia::escapeString(value) + "<br>";
479 state = businessState(); 479 state = businessState();
480 if ( !(value = businessZip()).isEmpty() ) 480 if ( !(value = businessZip()).isEmpty() )
481 text += Qtopia::escapeString(value) + " "; 481 text += Qtopia::escapeString(value) + " ";
482 if ( !(value = businessCity()).isEmpty() ) { 482 if ( !(value = businessCity()).isEmpty() ) {
483 text += Qtopia::escapeString(value); 483 text += Qtopia::escapeString(value);
484 if ( state ) 484 if ( state )
485 text += ", " + Qtopia::escapeString(state); 485 text += ", " + Qtopia::escapeString(state);
486 text += "<br>"; 486 text += "<br>";
487 } else if ( !state.isEmpty() ) 487 } else if ( !state.isEmpty() )
488 text += Qtopia::escapeString(state) + "<br>"; 488 text += Qtopia::escapeString(state) + "<br>";
489 489
490 if ( !(value = businessCountry()).isEmpty() ) 490 if ( !(value = businessCountry()).isEmpty() )
491 text += Qtopia::escapeString(value) + "<br>"; 491 text += Qtopia::escapeString(value) + "<br>";
492 492
493 // rest of Business data 493 // rest of Business data
494 str = office(); 494 str = office();
495 if ( !str.isEmpty() ){ 495 if ( !str.isEmpty() ){
496 text += "<b>" + QObject::tr("Office: ") + "</b>" 496 text += "<b>" + QObject::tr("Office: ") + "</b>"
497 + Qtopia::escapeString(str) + "<br>"; 497 + Qtopia::escapeString(str) + "<br>";
498 marker = true; 498 marker = true;
499 } 499 }
500 str = businessWebpage(); 500 str = businessWebpage();
501 if ( !str.isEmpty() ){ 501 if ( !str.isEmpty() ){
502 text += "<b><img src=\"addressbook/webpagework\">" + QObject::tr("Business Web Page: ") + "</b>" 502 text += "<b><img src=\"addressbook/webpagework\">" + QObject::tr("Business Web Page: ") + "</b>"
503 + Qtopia::escapeString(str) + "<br>"; 503 + Qtopia::escapeString(str) + "<br>";
504 marker = true; 504 marker = true;
505 } 505 }
506 str = businessPhone(); 506 str = businessPhone();
507 if ( !str.isEmpty() ){ 507 if ( !str.isEmpty() ){
508 text += "<b><img src=\"addressbook/phonework\">" + QObject::tr("Business Phone: ") + "</b>" 508 text += "<b><img src=\"addressbook/phonework\">" + QObject::tr("Business Phone: ") + "</b>"
@@ -921,135 +921,129 @@ QStringList OContact::fields()
921 list.append( "Spouse" ); 921 list.append( "Spouse" );
922 list.append( "Gender" ); 922 list.append( "Gender" );
923 list.append( "Birthday" ); 923 list.append( "Birthday" );
924 list.append( "Anniversary" ); 924 list.append( "Anniversary" );
925 list.append( "Nickname" ); 925 list.append( "Nickname" );
926 list.append( "Children" ); 926 list.append( "Children" );
927 927
928 list.append( "Notes" ); 928 list.append( "Notes" );
929 list.append( "Groups" ); 929 list.append( "Groups" );
930 930
931 return list; 931 return list;
932} 932}
933 933
934 934
935/*! 935/*!
936 Sets the list of email address for contact to those contained in \a str. 936 Sets the list of email address for contact to those contained in \a str.
937 Email address should be separated by ';'s. 937 Email address should be separated by ';'s.
938*/ 938*/
939void OContact::setEmails( const QString &str ) 939void OContact::setEmails( const QString &str )
940{ 940{
941 replace( Qtopia::Emails, str ); 941 replace( Qtopia::Emails, str );
942 if ( str.isEmpty() ) 942 if ( str.isEmpty() )
943 setDefaultEmail( QString::null ); 943 setDefaultEmail( QString::null );
944} 944}
945 945
946/*! 946/*!
947 Sets the list of children for the contact to those contained in \a str. 947 Sets the list of children for the contact to those contained in \a str.
948*/ 948*/
949void OContact::setChildren( const QString &str ) 949void OContact::setChildren( const QString &str )
950{ 950{
951 replace( Qtopia::Children, str ); 951 replace( Qtopia::Children, str );
952} 952}
953 953
954/*! 954/*!
955 \overload 955 \overload
956 Returns TRUE if the contact matches the regular expression \a regexp. 956 Returns TRUE if the contact matches the regular expression \a regexp.
957 Otherwise returns FALSE. 957 Otherwise returns FALSE.
958*/ 958*/
959bool OContact::match( const QRegExp &r ) const 959bool OContact::match( const QRegExp &r ) const
960{ 960{
961 setLastHitField( -1 ); 961 setLastHitField( -1 );
962 bool match; 962 bool match;
963 match = false; 963 match = false;
964 QMap<int, QString>::ConstIterator it; 964 QMap<int, QString>::ConstIterator it;
965 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 965 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
966 if ( (*it).find( r ) > -1 ) { 966 if ( (*it).find( r ) > -1 ) {
967 setLastHitField( it.key() ); 967 setLastHitField( it.key() );
968 match = true; 968 match = true;
969 break; 969 break;
970 } 970 }
971 } 971 }
972 return match; 972 return match;
973} 973}
974 974
975 975
976QString OContact::toShortText() const 976QString OContact::toShortText() const
977{ 977{
978 return ( fullName() ); 978 return ( fullName() );
979} 979}
980QString OContact::type() const 980QString OContact::type() const
981{ 981{
982 return QString::fromLatin1( "OContact" ); 982 return QString::fromLatin1( "OContact" );
983} 983}
984 984
985// Definition is missing ! (se) 985
986QMap<QString,QString> OContact::toExtraMap() const
987{
988 qWarning ("Function not implemented: OContact::toExtraMap()");
989 QMap <QString,QString> useless;
990 return useless;
991}
992 986
993class QString OContact::recordField( int pos ) const 987class QString OContact::recordField( int pos ) const
994{ 988{
995 QStringList SLFIELDS = fields(); // ?? why this ? (se) 989 QStringList SLFIELDS = fields(); // ?? why this ? (se)
996 return SLFIELDS[pos]; 990 return SLFIELDS[pos];
997} 991}
998 992
999// In future releases, we should store birthday and anniversary 993// In future releases, we should store birthday and anniversary
1000// internally as QDate instead of QString ! 994// internally as QDate instead of QString !
1001// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 995// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1002 996
1003/*! \fn void OContact::setBirthday( const QDate& date ) 997/*! \fn void OContact::setBirthday( const QDate& date )
1004 Sets the birthday for the contact to \a date. If date is null 998 Sets the birthday for the contact to \a date. If date is null
1005 the current stored date will be removed. 999 the current stored date will be removed.
1006*/ 1000*/
1007void OContact::setBirthday( const QDate &v ) 1001void OContact::setBirthday( const QDate &v )
1008{ 1002{
1009 if ( v.isNull() ){ 1003 if ( v.isNull() ){
1010 qWarning( "Remove Birthday"); 1004 qWarning( "Remove Birthday");
1011 replace( Qtopia::Birthday, QString::null ); 1005 replace( Qtopia::Birthday, QString::null );
1012 return; 1006 return;
1013 } 1007 }
1014 1008
1015 if ( v.isValid() ) 1009 if ( v.isValid() )
1016 replace( Qtopia::Birthday, OConversion::dateToString( v ) ); 1010 replace( Qtopia::Birthday, OConversion::dateToString( v ) );
1017 1011
1018} 1012}
1019 1013
1020 1014
1021/*! \fn void OContact::setAnniversary( const QDate &date ) 1015/*! \fn void OContact::setAnniversary( const QDate &date )
1022 Sets the anniversary of the contact to \a date. If date is 1016 Sets the anniversary of the contact to \a date. If date is
1023 null, the current stored date will be removed. 1017 null, the current stored date will be removed.
1024*/ 1018*/
1025void OContact::setAnniversary( const QDate &v ) 1019void OContact::setAnniversary( const QDate &v )
1026{ 1020{
1027 if ( v.isNull() ){ 1021 if ( v.isNull() ){
1028 qWarning( "Remove Anniversary"); 1022 qWarning( "Remove Anniversary");
1029 replace( Qtopia::Anniversary, QString::null ); 1023 replace( Qtopia::Anniversary, QString::null );
1030 return; 1024 return;
1031 } 1025 }
1032 1026
1033 if ( v.isValid() ) 1027 if ( v.isValid() )
1034 replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); 1028 replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
1035} 1029}
1036 1030
1037/*! \fn QDate OContact::birthday() const 1031/*! \fn QDate OContact::birthday() const
1038 Returns the birthday of the contact. 1032 Returns the birthday of the contact.
1039*/ 1033*/
1040QDate OContact::birthday() const 1034QDate OContact::birthday() const
1041{ 1035{
1042 QString str = find( Qtopia::Birthday ); 1036 QString str = find( Qtopia::Birthday );
1043 qWarning ("Birthday %s", str.latin1() ); 1037 qWarning ("Birthday %s", str.latin1() );
1044 if ( !str.isEmpty() ) 1038 if ( !str.isEmpty() )
1045 return OConversion::dateFromString ( str ); 1039 return OConversion::dateFromString ( str );
1046 else 1040 else
1047 return QDate(); 1041 return QDate();
1048} 1042}
1049 1043
1050 1044
1051/*! \fn QDate OContact::anniversary() const 1045/*! \fn QDate OContact::anniversary() const
1052 Returns the anniversary of the contact. 1046 Returns the anniversary of the contact.
1053*/ 1047*/
1054QDate OContact::anniversary() const 1048QDate OContact::anniversary() const
1055{ 1049{
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp
index e4f5d92..7bcf944 100644
--- a/libopie2/opiepim/oevent.cpp
+++ b/libopie2/opiepim/oevent.cpp
@@ -175,255 +175,252 @@ void OEvent::setStartDateTime( const QDateTime& dt ) {
175QDateTime OEvent::endDateTime()const { 175QDateTime OEvent::endDateTime()const {
176 /* 176 /*
177 * if all Day event the end time needs 177 * if all Day event the end time needs
178 * to be on the same day as the start 178 * to be on the same day as the start
179 */ 179 */
180 if ( data->isAllDay ) 180 if ( data->isAllDay )
181 return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); 181 return QDateTime( data->start.date(), QTime(23, 59, 59 ) );
182 return data->end; 182 return data->end;
183} 183}
184QDateTime OEvent::endDateTimeInZone()const { 184QDateTime OEvent::endDateTimeInZone()const {
185 /* if no timezone, or all day event or if the current and this timeZone match... */ 185 /* if no timezone, or all day event or if the current and this timeZone match... */
186 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); 186 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime();
187 187
188 OTimeZone zone(data->timezone ); 188 OTimeZone zone(data->timezone );
189 return zone.toDateTime( data->end, OTimeZone::current() ); 189 return zone.toDateTime( data->end, OTimeZone::current() );
190} 190}
191void OEvent::setEndDateTime( const QDateTime& dt ) { 191void OEvent::setEndDateTime( const QDateTime& dt ) {
192 changeOrModify(); 192 changeOrModify();
193 data->end = dt; 193 data->end = dt;
194} 194}
195bool OEvent::isMultipleDay()const { 195bool OEvent::isMultipleDay()const {
196 return data->end.date().day() - data->start.date().day(); 196 return data->end.date().day() - data->start.date().day();
197} 197}
198bool OEvent::isAllDay()const { 198bool OEvent::isAllDay()const {
199 return data->isAllDay; 199 return data->isAllDay;
200} 200}
201void OEvent::setAllDay( bool allDay ) { 201void OEvent::setAllDay( bool allDay ) {
202 changeOrModify(); 202 changeOrModify();
203 data->isAllDay = allDay; 203 data->isAllDay = allDay;
204 if (allDay ) data->timezone = "UTC"; 204 if (allDay ) data->timezone = "UTC";
205} 205}
206void OEvent::setTimeZone( const QString& tz ) { 206void OEvent::setTimeZone( const QString& tz ) {
207 changeOrModify(); 207 changeOrModify();
208 data->timezone = tz; 208 data->timezone = tz;
209} 209}
210QString OEvent::timeZone()const { 210QString OEvent::timeZone()const {
211 if (data->isAllDay ) return QString::fromLatin1("UTC"); 211 if (data->isAllDay ) return QString::fromLatin1("UTC");
212 return data->timezone; 212 return data->timezone;
213} 213}
214bool OEvent::match( const QRegExp& re )const { 214bool OEvent::match( const QRegExp& re )const {
215 if ( re.match( data->description ) != -1 ){ 215 if ( re.match( data->description ) != -1 ){
216 setLastHitField( Qtopia::DatebookDescription ); 216 setLastHitField( Qtopia::DatebookDescription );
217 return true; 217 return true;
218 } 218 }
219 if ( re.match( data->note ) != -1 ){ 219 if ( re.match( data->note ) != -1 ){
220 setLastHitField( Qtopia::Note ); 220 setLastHitField( Qtopia::Note );
221 return true; 221 return true;
222 } 222 }
223 if ( re.match( data->location ) != -1 ){ 223 if ( re.match( data->location ) != -1 ){
224 setLastHitField( Qtopia::Location ); 224 setLastHitField( Qtopia::Location );
225 return true; 225 return true;
226 } 226 }
227 if ( re.match( data->start.toString() ) != -1 ){ 227 if ( re.match( data->start.toString() ) != -1 ){
228 setLastHitField( Qtopia::StartDateTime ); 228 setLastHitField( Qtopia::StartDateTime );
229 return true; 229 return true;
230 } 230 }
231 if ( re.match( data->end.toString() ) != -1 ){ 231 if ( re.match( data->end.toString() ) != -1 ){
232 setLastHitField( Qtopia::EndDateTime ); 232 setLastHitField( Qtopia::EndDateTime );
233 return true; 233 return true;
234 } 234 }
235 return false; 235 return false;
236} 236}
237QString OEvent::toRichText()const { 237QString OEvent::toRichText()const {
238 QString text, value; 238 QString text, value;
239 239
240 // description 240 // description
241 text += "<b><h3><img src=\"datebook/DateBook\">"; 241 text += "<b><h3><img src=\"datebook/DateBook\">";
242 if ( !description().isEmpty() ) { 242 if ( !description().isEmpty() ) {
243 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" ); 243 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" );
244 } 244 }
245 text += "</h3></b><br><hr><br>"; 245 text += "</h3></b><br><hr><br>";
246 246
247 // location 247 // location
248 if ( !(value = location()).isEmpty() ) { 248 if ( !(value = location()).isEmpty() ) {
249 text += "<b>" + QObject::tr( "Location:" ) + "</b> "; 249 text += "<b>" + QObject::tr( "Location:" ) + "</b> ";
250 text += Qtopia::escapeString(value) + "<br>"; 250 text += Qtopia::escapeString(value) + "<br>";
251 } 251 }
252 252
253 // all day event 253 // all day event
254 if ( isAllDay() ) { 254 if ( isAllDay() ) {
255 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; 255 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>";
256 } 256 }
257 // multiple day event 257 // multiple day event
258 else if ( isMultipleDay () ) { 258 else if ( isMultipleDay () ) {
259 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; 259 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>";
260 } 260 }
261 // start & end times 261 // start & end times
262 else { 262 else {
263 // start time 263 // start time
264 if ( startDateTime().isValid() ) { 264 if ( startDateTime().isValid() ) {
265 text += "<b>" + QObject::tr( "Start:") + "</b> "; 265 text += "<b>" + QObject::tr( "Start:") + "</b> ";
266 text += Qtopia::escapeString(startDateTime().toString() ). 266 text += Qtopia::escapeString(startDateTime().toString() ).
267 replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 267 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
268 } 268 }
269 269
270 // end time 270 // end time
271 if ( endDateTime().isValid() ) { 271 if ( endDateTime().isValid() ) {
272 text += "<b>" + QObject::tr( "End:") + "</b> "; 272 text += "<b>" + QObject::tr( "End:") + "</b> ";
273 text += Qtopia::escapeString(endDateTime().toString() ). 273 text += Qtopia::escapeString(endDateTime().toString() ).
274 replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 274 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
275 } 275 }
276 } 276 }
277 277
278 // categories 278 // categories
279 if ( categoryNames("Calendar").count() ){ 279 if ( categoryNames("Calendar").count() ){
280 text += "<b>" + QObject::tr( "Category:") + "</b> "; 280 text += "<b>" + QObject::tr( "Category:") + "</b> ";
281 text += categoryNames("Calendar").join(", "); 281 text += categoryNames("Calendar").join(", ");
282 text += "<br>"; 282 text += "<br>";
283 } 283 }
284 284
285 //notes 285 //notes
286 if ( !note().isEmpty() ) { 286 if ( !note().isEmpty() ) {
287 text += "<b>" + QObject::tr( "Note:") + "</b><br>"; 287 text += "<b>" + QObject::tr( "Note:") + "</b><br>";
288 text += note(); 288 text += note();
289// text += Qtopia::escapeString(note() ). 289// text += Qtopia::escapeString(note() ).
290// replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 290// replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
291 } 291 }
292 return text; 292 return text;
293} 293}
294QString OEvent::toShortText()const { 294QString OEvent::toShortText()const {
295 QString text; 295 QString text;
296 text += QString::number( startDateTime().date().day() ); 296 text += QString::number( startDateTime().date().day() );
297 text += "."; 297 text += ".";
298 text += QString::number( startDateTime().date().month() ); 298 text += QString::number( startDateTime().date().month() );
299 text += "."; 299 text += ".";
300 text += QString::number( startDateTime().date().year() ); 300 text += QString::number( startDateTime().date().year() );
301 text += " "; 301 text += " ";
302 text += QString::number( startDateTime().time().hour() ); 302 text += QString::number( startDateTime().time().hour() );
303 text += ":"; 303 text += ":";
304 text += QString::number( startDateTime().time().minute() ); 304 text += QString::number( startDateTime().time().minute() );
305 text += " - "; 305 text += " - ";
306 text += description(); 306 text += description();
307 return text; 307 return text;
308} 308}
309QString OEvent::type()const { 309QString OEvent::type()const {
310 return QString::fromLatin1("OEvent"); 310 return QString::fromLatin1("OEvent");
311} 311}
312QString OEvent::recordField( int /*id */ )const { 312QString OEvent::recordField( int /*id */ )const {
313 return QString::null; 313 return QString::null;
314} 314}
315int OEvent::rtti() { 315int OEvent::rtti() {
316 return OPimResolver::DateBook; 316 return OPimResolver::DateBook;
317} 317}
318bool OEvent::loadFromStream( QDataStream& ) { 318bool OEvent::loadFromStream( QDataStream& ) {
319 return true; 319 return true;
320} 320}
321bool OEvent::saveToStream( QDataStream& )const { 321bool OEvent::saveToStream( QDataStream& )const {
322 return true; 322 return true;
323} 323}
324void OEvent::changeOrModify() { 324void OEvent::changeOrModify() {
325 if ( data->count != 1 ) { 325 if ( data->count != 1 ) {
326 data->deref(); 326 data->deref();
327 Data* d2 = new Data; 327 Data* d2 = new Data;
328 d2->description = data->description; 328 d2->description = data->description;
329 d2->location = data->location; 329 d2->location = data->location;
330 330
331 if (data->manager ) 331 if (data->manager )
332 d2->manager = new OPimNotifyManager( *data->manager ); 332 d2->manager = new OPimNotifyManager( *data->manager );
333 333
334 if ( data->recur ) 334 if ( data->recur )
335 d2->recur = new ORecur( *data->recur ); 335 d2->recur = new ORecur( *data->recur );
336 336
337 d2->note = data->note; 337 d2->note = data->note;
338 d2->created = data->created; 338 d2->created = data->created;
339 d2->start = data->start; 339 d2->start = data->start;
340 d2->end = data->end; 340 d2->end = data->end;
341 d2->isAllDay = data->isAllDay; 341 d2->isAllDay = data->isAllDay;
342 d2->timezone = data->timezone; 342 d2->timezone = data->timezone;
343 d2->parent = data->parent; 343 d2->parent = data->parent;
344 344
345 if ( data->child ) { 345 if ( data->child ) {
346 d2->child = new QArray<int>( *data->child ); 346 d2->child = new QArray<int>( *data->child );
347 d2->child->detach(); 347 d2->child->detach();
348 } 348 }
349 349
350 data = d2; 350 data = d2;
351 } 351 }
352} 352}
353void OEvent::deref() { 353void OEvent::deref() {
354 if ( data->deref() ) { 354 if ( data->deref() ) {
355 delete data; 355 delete data;
356 data = 0; 356 data = 0;
357 } 357 }
358} 358}
359// FIXME 359// FIXME
360QMap<int, QString> OEvent::toMap()const { 360QMap<int, QString> OEvent::toMap()const {
361 return QMap<int, QString>(); 361 return QMap<int, QString>();
362} 362}
363QMap<QString, QString> OEvent::toExtraMap()const {
364 return QMap<QString, QString>();
365}
366int OEvent::parent()const { 363int OEvent::parent()const {
367 return data->parent; 364 return data->parent;
368} 365}
369void OEvent::setParent( int uid ) { 366void OEvent::setParent( int uid ) {
370 changeOrModify(); 367 changeOrModify();
371 data->parent = uid; 368 data->parent = uid;
372} 369}
373QArray<int> OEvent::children() const{ 370QArray<int> OEvent::children() const{
374 if (!data->child) return QArray<int>(); 371 if (!data->child) return QArray<int>();
375 else 372 else
376 return data->child->copy(); 373 return data->child->copy();
377} 374}
378void OEvent::setChildren( const QArray<int>& arr ) { 375void OEvent::setChildren( const QArray<int>& arr ) {
379 changeOrModify(); 376 changeOrModify();
380 if (data->child) delete data->child; 377 if (data->child) delete data->child;
381 378
382 data->child = new QArray<int>( arr ); 379 data->child = new QArray<int>( arr );
383 data->child->detach(); 380 data->child->detach();
384} 381}
385void OEvent::addChild( int uid ) { 382void OEvent::addChild( int uid ) {
386 changeOrModify(); 383 changeOrModify();
387 if (!data->child ) { 384 if (!data->child ) {
388 data->child = new QArray<int>(1); 385 data->child = new QArray<int>(1);
389 (*data->child)[0] = uid; 386 (*data->child)[0] = uid;
390 }else{ 387 }else{
391 int count = data->child->count(); 388 int count = data->child->count();
392 data->child->resize( count + 1 ); 389 data->child->resize( count + 1 );
393 (*data->child)[count] = uid; 390 (*data->child)[count] = uid;
394 } 391 }
395} 392}
396void OEvent::removeChild( int uid ) { 393void OEvent::removeChild( int uid ) {
397 if (!data->child || !data->child->contains( uid ) ) return; 394 if (!data->child || !data->child->contains( uid ) ) return;
398 changeOrModify(); 395 changeOrModify();
399 QArray<int> newAr( data->child->count() - 1 ); 396 QArray<int> newAr( data->child->count() - 1 );
400 int j = 0; 397 int j = 0;
401 uint count = data->child->count(); 398 uint count = data->child->count();
402 for ( uint i = 0; i < count; i++ ) { 399 for ( uint i = 0; i < count; i++ ) {
403 if ( (*data->child)[i] != uid ) { 400 if ( (*data->child)[i] != uid ) {
404 newAr[j] = (*data->child)[i]; 401 newAr[j] = (*data->child)[i];
405 j++; 402 j++;
406 } 403 }
407 } 404 }
408 (*data->child) = newAr; 405 (*data->child) = newAr;
409} 406}
410struct OEffectiveEvent::Data : public QShared { 407struct OEffectiveEvent::Data : public QShared {
411 Data() : QShared() { 408 Data() : QShared() {
412 } 409 }
413 OEvent event; 410 OEvent event;
414 QDate date; 411 QDate date;
415 QTime start, end; 412 QTime start, end;
416 QDate startDate, endDate; 413 QDate startDate, endDate;
417 bool dates : 1; 414 bool dates : 1;
418}; 415};
419 416
420OEffectiveEvent::OEffectiveEvent() { 417OEffectiveEvent::OEffectiveEvent() {
421 data = new Data; 418 data = new Data;
422 data->date = QDate::currentDate(); 419 data->date = QDate::currentDate();
423 data->start = data->end = QTime::currentTime(); 420 data->start = data->end = QTime::currentTime();
424 data->dates = false; 421 data->dates = false;
425} 422}
426OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, 423OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate,
427 Position pos ) { 424 Position pos ) {
428 data = new Data; 425 data = new Data;
429 data->event = ev; 426 data->event = ev;
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h
index b696d81..30f442e 100644
--- a/libopie2/opiepim/oevent.h
+++ b/libopie2/opiepim/oevent.h
@@ -71,129 +71,128 @@ public:
71 OEvent &operator=( const OEvent& ); 71 OEvent &operator=( const OEvent& );
72 72
73 QString description()const; 73 QString description()const;
74 void setDescription( const QString& description ); 74 void setDescription( const QString& description );
75 75
76 QString location()const; 76 QString location()const;
77 void setLocation( const QString& loc ); 77 void setLocation( const QString& loc );
78 78
79 bool hasNotifiers()const; 79 bool hasNotifiers()const;
80 OPimNotifyManager &notifiers()const; 80 OPimNotifyManager &notifiers()const;
81 81
82 ORecur recurrence()const; 82 ORecur recurrence()const;
83 void setRecurrence( const ORecur& ); 83 void setRecurrence( const ORecur& );
84 bool hasRecurrence()const; 84 bool hasRecurrence()const;
85 85
86 QString note()const; 86 QString note()const;
87 void setNote( const QString& note ); 87 void setNote( const QString& note );
88 88
89 89
90 QDateTime createdDateTime()const; 90 QDateTime createdDateTime()const;
91 void setCreatedDateTime( const QDateTime& dt); 91 void setCreatedDateTime( const QDateTime& dt);
92 92
93 /** set the date to dt. dt is the QDateTime in localtime */ 93 /** set the date to dt. dt is the QDateTime in localtime */
94 void setStartDateTime( const QDateTime& ); 94 void setStartDateTime( const QDateTime& );
95 /** returns the datetime in the local timeZone */ 95 /** returns the datetime in the local timeZone */
96 QDateTime startDateTime()const; 96 QDateTime startDateTime()const;
97 97
98 /** returns the start datetime in the current zone */ 98 /** returns the start datetime in the current zone */
99 QDateTime startDateTimeInZone()const; 99 QDateTime startDateTimeInZone()const;
100 100
101 /** in current timezone */ 101 /** in current timezone */
102 void setEndDateTime( const QDateTime& ); 102 void setEndDateTime( const QDateTime& );
103 /** in current timezone */ 103 /** in current timezone */
104 QDateTime endDateTime()const; 104 QDateTime endDateTime()const;
105 QDateTime endDateTimeInZone()const; 105 QDateTime endDateTimeInZone()const;
106 106
107 bool isMultipleDay()const; 107 bool isMultipleDay()const;
108 bool isAllDay()const; 108 bool isAllDay()const;
109 void setAllDay( bool isAllDay ); 109 void setAllDay( bool isAllDay );
110 110
111 /* pin this event to a timezone! FIXME */ 111 /* pin this event to a timezone! FIXME */
112 void setTimeZone( const QString& timeZone ); 112 void setTimeZone( const QString& timeZone );
113 QString timeZone()const; 113 QString timeZone()const;
114 114
115 115
116 virtual bool match( const QRegExp& )const; 116 virtual bool match( const QRegExp& )const;
117 117
118 /** For exception to recurrence here is a list of children... */ 118 /** For exception to recurrence here is a list of children... */
119 QArray<int> children()const; 119 QArray<int> children()const;
120 void setChildren( const QArray<int>& ); 120 void setChildren( const QArray<int>& );
121 void addChild( int uid ); 121 void addChild( int uid );
122 void removeChild( int uid ); 122 void removeChild( int uid );
123 123
124 /** return the parent OEvent */ 124 /** return the parent OEvent */
125 int parent()const; 125 int parent()const;
126 void setParent( int uid ); 126 void setParent( int uid );
127 127
128 128
129 /* needed reimp */ 129 /* needed reimp */
130 QString toRichText()const; 130 QString toRichText()const;
131 QString toShortText()const; 131 QString toShortText()const;
132 QString type()const; 132 QString type()const;
133 133
134 QMap<int, QString> toMap()const; 134 QMap<int, QString> toMap()const;
135 QMap<QString, QString> toExtraMap()const;
136 QString recordField(int )const; 135 QString recordField(int )const;
137 136
138 static int rtti(); 137 static int rtti();
139 138
140 bool loadFromStream( QDataStream& ); 139 bool loadFromStream( QDataStream& );
141 bool saveToStream( QDataStream& )const; 140 bool saveToStream( QDataStream& )const;
142 141
143/* bool operator==( const OEvent& ); 142/* bool operator==( const OEvent& );
144 bool operator!=( const OEvent& ); 143 bool operator!=( const OEvent& );
145 bool operator<( const OEvent& ); 144 bool operator<( const OEvent& );
146 bool operator<=( const OEvent& ); 145 bool operator<=( const OEvent& );
147 bool operator>( const OEvent& ); 146 bool operator>( const OEvent& );
148 bool operator>=(const OEvent& ); 147 bool operator>=(const OEvent& );
149*/ 148*/
150private: 149private:
151 inline void changeOrModify(); 150 inline void changeOrModify();
152 void deref(); 151 void deref();
153 struct Data; 152 struct Data;
154 Data* data; 153 Data* data;
155 class Private; 154 class Private;
156 Private* priv; 155 Private* priv;
157 156
158}; 157};
159 158
160/** 159/**
161 * AN Event can span through multiple days. We split up a multiday eve 160 * AN Event can span through multiple days. We split up a multiday eve
162 */ 161 */
163class OEffectiveEvent { 162class OEffectiveEvent {
164public: 163public:
165 typedef QValueList<OEffectiveEvent> ValueList; 164 typedef QValueList<OEffectiveEvent> ValueList;
166 enum Position { MidWay, Start, End, StartEnd }; 165 enum Position { MidWay, Start, End, StartEnd };
167 // If we calculate the effective event of a multi-day event 166 // If we calculate the effective event of a multi-day event
168 // we have to figure out whether we are at the first day, 167 // we have to figure out whether we are at the first day,
169 // at the end, or anywhere else ("middle"). This is important 168 // at the end, or anywhere else ("middle"). This is important
170 // for the start/end times (00:00/23:59) 169 // for the start/end times (00:00/23:59)
171 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- 170 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi-
172 // day event 171 // day event
173 // Start: start time -> 23:59 172 // Start: start time -> 23:59
174 // End: 00:00 -> end time 173 // End: 00:00 -> end time
175 // Start | End == StartEnd: for single-day events (default) 174 // Start | End == StartEnd: for single-day events (default)
176 // here we draw start time -> end time 175 // here we draw start time -> end time
177 OEffectiveEvent(); 176 OEffectiveEvent();
178 OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); 177 OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd );
179 OEffectiveEvent( const OEffectiveEvent& ); 178 OEffectiveEvent( const OEffectiveEvent& );
180 OEffectiveEvent &operator=(const OEffectiveEvent& ); 179 OEffectiveEvent &operator=(const OEffectiveEvent& );
181 ~OEffectiveEvent(); 180 ~OEffectiveEvent();
182 181
183 void setStartTime( const QTime& ); 182 void setStartTime( const QTime& );
184 void setEndTime( const QTime& ); 183 void setEndTime( const QTime& );
185 void setEvent( const OEvent& ); 184 void setEvent( const OEvent& );
186 void setDate( const QDate& ); 185 void setDate( const QDate& );
187 186
188 void setEffectiveDates( const QDate& from, const QDate& to ); 187 void setEffectiveDates( const QDate& from, const QDate& to );
189 188
190 QString description()const; 189 QString description()const;
191 QString location()const; 190 QString location()const;
192 QString note()const; 191 QString note()const;
193 OEvent event()const; 192 OEvent event()const;
194 QTime startTime()const; 193 QTime startTime()const;
195 QTime endTime()const; 194 QTime endTime()const;
196 QDate date()const; 195 QDate date()const;
197 196
198 /* return the length in hours */ 197 /* return the length in hours */
199 int length()const; 198 int length()const;
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index c84eeeb..38b93f7 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -218,176 +218,176 @@ void OTodo::setPriority(int prio )
218} 218}
219void OTodo::setDueDate( const QDate& date ) 219void OTodo::setDueDate( const QDate& date )
220{ 220{
221 changeOrModify(); 221 changeOrModify();
222 data->date = date; 222 data->date = date;
223} 223}
224void OTodo::setStartDate( const QDate& date ) { 224void OTodo::setStartDate( const QDate& date ) {
225 changeOrModify(); 225 changeOrModify();
226 data->start = date; 226 data->start = date;
227} 227}
228void OTodo::setCompletedDate( const QDate& date ) { 228void OTodo::setCompletedDate( const QDate& date ) {
229 changeOrModify(); 229 changeOrModify();
230 data->completed = date; 230 data->completed = date;
231} 231}
232void OTodo::setState( const OPimState& state ) { 232void OTodo::setState( const OPimState& state ) {
233 changeOrModify(); 233 changeOrModify();
234 if (data->state ) 234 if (data->state )
235 (*data->state) = state; 235 (*data->state) = state;
236 else 236 else
237 data->state = new OPimState( state ); 237 data->state = new OPimState( state );
238} 238}
239void OTodo::setRecurrence( const ORecur& rec) { 239void OTodo::setRecurrence( const ORecur& rec) {
240 changeOrModify(); 240 changeOrModify();
241 if (data->recur ) 241 if (data->recur )
242 (*data->recur) = rec; 242 (*data->recur) = rec;
243 else 243 else
244 data->recur = new ORecur( rec ); 244 data->recur = new ORecur( rec );
245} 245}
246void OTodo::setMaintainer( const OPimMaintainer& pim ) { 246void OTodo::setMaintainer( const OPimMaintainer& pim ) {
247 changeOrModify(); 247 changeOrModify();
248 248
249 if (data->maintainer ) 249 if (data->maintainer )
250 (*data->maintainer) = pim; 250 (*data->maintainer) = pim;
251 else 251 else
252 data->maintainer = new OPimMaintainer( pim ); 252 data->maintainer = new OPimMaintainer( pim );
253} 253}
254bool OTodo::isOverdue( ) 254bool OTodo::isOverdue( )
255{ 255{
256 if( data->hasDate && !data->isCompleted) 256 if( data->hasDate && !data->isCompleted)
257 return QDate::currentDate() > data->date; 257 return QDate::currentDate() > data->date;
258 return false; 258 return false;
259} 259}
260void OTodo::setProgress(ushort progress ) 260void OTodo::setProgress(ushort progress )
261{ 261{
262 changeOrModify(); 262 changeOrModify();
263 data->prog = progress; 263 data->prog = progress;
264} 264}
265QString OTodo::toShortText() const { 265QString OTodo::toShortText() const {
266 return summary(); 266 return summary();
267} 267}
268/*! 268/*!
269 Returns a richt text string 269 Returns a richt text string
270*/ 270*/
271QString OTodo::toRichText() const 271QString OTodo::toRichText() const
272{ 272{
273 QString text; 273 QString text;
274 QStringList catlist; 274 QStringList catlist;
275 275
276 // summary 276 // summary
277 text += "<b><h3><img src=\"todo/TodoList\">"; 277 text += "<b><h3><img src=\"todo/TodoList\">";
278 if ( !summary().isEmpty() ) { 278 if ( !summary().isEmpty() ) {
279 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); 279 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" );
280 } 280 }
281 text += "</h3></b><br><hr><br>"; 281 text += "</h3></b><br><hr><br>";
282 282
283 // description 283 // description
284 if( !description().isEmpty() ){ 284 if( !description().isEmpty() ){
285 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 285 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
286 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 286 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
287 } 287 }
288 288
289 // priority 289 // priority
290 int priorityval = priority(); 290 int priorityval = priority();
291 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + 291 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" +
292 QString::number( priorityval ) + "\">"; 292 QString::number( priorityval ) + "\">";
293// text += "<b>" + QObject::tr( "Priority:") +"</b><img src=\"todo/priority" + 293// text += "<b>" + QObject::tr( "Priority:") +"</b><img src=\"todo/priority" +
294// QString::number( priority() ) + "\"><br>"; 294// QString::number( priority() ) + "\"><br>";
295 switch ( priorityval ) 295 switch ( priorityval )
296 { 296 {
297 case 1 : text += QObject::tr( "Very high" ); 297 case 1 : text += QObject::tr( "Very high" );
298 break; 298 break;
299 case 2 : text += QObject::tr( "High" ); 299 case 2 : text += QObject::tr( "High" );
300 break; 300 break;
301 case 3 : text += QObject::tr( "Normal" ); 301 case 3 : text += QObject::tr( "Normal" );
302 break; 302 break;
303 case 4 : text += QObject::tr( "Low" ); 303 case 4 : text += QObject::tr( "Low" );
304 break; 304 break;
305 case 5 : text += QObject::tr( "Very low" ); 305 case 5 : text += QObject::tr( "Very low" );
306 break; 306 break;
307 }; 307 };
308 text += "<br>"; 308 text += "<br>";
309 309
310 // progress 310 // progress
311 text += "<b>" + QObject::tr( "Progress:") + " </b>" 311 text += "<b>" + QObject::tr( "Progress:") + " </b>"
312 + QString::number( progress() ) + " %<br>"; 312 + QString::number( progress() ) + " %<br>";
313 313
314 // due date 314 // due date
315 if (hasDueDate() ){ 315 if (hasDueDate() ){
316 QDate dd = dueDate(); 316 QDate dd = dueDate();
317 int off = QDate::currentDate().daysTo( dd ); 317 int off = QDate::currentDate().daysTo( dd );
318 318
319 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; 319 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\"";
320 if ( off < 0 ) 320 if ( off < 0 )
321 text += "#FF0000"; 321 text += "#FF0000";
322 else if ( off == 0 ) 322 else if ( off == 0 )
323 text += "#FFFF00"; 323 text += "#FFFF00";
324 else if ( off > 0 ) 324 else if ( off > 0 )
325 text += "#00FF00"; 325 text += "#00FF00";
326 326
327 text += "\">" + dd.toString() + "</font><br>"; 327 text += "\">" + dd.toString() + "</font><br>";
328 } 328 }
329 329
330 // categories 330 // categories
331 text += "<b>" + QObject::tr( "Category:") + "</b> "; 331 text += "<b>" + QObject::tr( "Category:") + "</b> ";
332 text += categoryNames( "Todo List" ).join(", "); 332 text += categoryNames( "Todo List" ).join(", ");
333 text += "<br>"; 333 text += "<br>";
334 334
335 return text; 335 return text;
336} 336}
337bool OTodo::hasNotifiers()const { 337bool OTodo::hasNotifiers()const {
338 if (!data->notifiers) return false; 338 if (!data->notifiers) return false;
339 return !data->notifiers->isEmpty(); 339 return !data->notifiers->isEmpty();
340} 340}
341OPimNotifyManager& OTodo::notifiers() { 341OPimNotifyManager& OTodo::notifiers() {
342 if (!data->notifiers ) 342 if (!data->notifiers )
343 data->notifiers = new OPimNotifyManager; 343 data->notifiers = new OPimNotifyManager;
344 return (*data->notifiers); 344 return (*data->notifiers);
345} 345}
346const OPimNotifyManager& OTodo::notifiers()const{ 346const OPimNotifyManager& OTodo::notifiers()const{
347 if (!data->notifiers ) 347 if (!data->notifiers )
348 data->notifiers = new OPimNotifyManager; 348 data->notifiers = new OPimNotifyManager;
349 349
350 return (*data->notifiers); 350 return (*data->notifiers);
351} 351}
352 352
353bool OTodo::operator<( const OTodo &toDoEvent )const{ 353bool OTodo::operator<( const OTodo &toDoEvent )const{
354 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 354 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
355 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 355 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
356 if( hasDueDate() && toDoEvent.hasDueDate() ){ 356 if( hasDueDate() && toDoEvent.hasDueDate() ){
357 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 357 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
358 return priority() < toDoEvent.priority(); 358 return priority() < toDoEvent.priority();
359 }else{ 359 }else{
360 return dueDate() < toDoEvent.dueDate(); 360 return dueDate() < toDoEvent.dueDate();
361 } 361 }
362 } 362 }
363 return false; 363 return false;
364} 364}
365bool OTodo::operator<=(const OTodo &toDoEvent )const 365bool OTodo::operator<=(const OTodo &toDoEvent )const
366{ 366{
367 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 367 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
368 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 368 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
369 if( hasDueDate() && toDoEvent.hasDueDate() ){ 369 if( hasDueDate() && toDoEvent.hasDueDate() ){
370 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 370 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
371 return priority() <= toDoEvent.priority(); 371 return priority() <= toDoEvent.priority();
372 }else{ 372 }else{
373 return dueDate() <= toDoEvent.dueDate(); 373 return dueDate() <= toDoEvent.dueDate();
374 } 374 }
375 } 375 }
376 return true; 376 return true;
377} 377}
378bool OTodo::operator>(const OTodo &toDoEvent )const 378bool OTodo::operator>(const OTodo &toDoEvent )const
379{ 379{
380 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 380 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
381 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 381 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
382 if( hasDueDate() && toDoEvent.hasDueDate() ){ 382 if( hasDueDate() && toDoEvent.hasDueDate() ){
383 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 383 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
384 return priority() > toDoEvent.priority(); 384 return priority() > toDoEvent.priority();
385 }else{ 385 }else{
386 return dueDate() > toDoEvent.dueDate(); 386 return dueDate() > toDoEvent.dueDate();
387 } 387 }
388 } 388 }
389 return false; 389 return false;
390} 390}
391bool OTodo::operator>=(const OTodo &toDoEvent )const 391bool OTodo::operator>=(const OTodo &toDoEvent )const
392{ 392{
393 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 393 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
@@ -399,121 +399,118 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
399 return dueDate() > toDoEvent.dueDate(); 399 return dueDate() > toDoEvent.dueDate();
400 } 400 }
401 } 401 }
402 return true; 402 return true;
403} 403}
404bool OTodo::operator==(const OTodo &toDoEvent )const 404bool OTodo::operator==(const OTodo &toDoEvent )const
405{ 405{
406 if ( data->priority != toDoEvent.data->priority ) return false; 406 if ( data->priority != toDoEvent.data->priority ) return false;
407 if ( data->priority != toDoEvent.data->prog ) return false; 407 if ( data->priority != toDoEvent.data->prog ) return false;
408 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 408 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
409 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 409 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
410 if ( data->date != toDoEvent.data->date ) return false; 410 if ( data->date != toDoEvent.data->date ) return false;
411 if ( data->sum != toDoEvent.data->sum ) return false; 411 if ( data->sum != toDoEvent.data->sum ) return false;
412 if ( data->desc != toDoEvent.data->desc ) return false; 412 if ( data->desc != toDoEvent.data->desc ) return false;
413 if ( data->maintainer != toDoEvent.data->maintainer ) 413 if ( data->maintainer != toDoEvent.data->maintainer )
414 return false; 414 return false;
415 415
416 return OPimRecord::operator==( toDoEvent ); 416 return OPimRecord::operator==( toDoEvent );
417} 417}
418void OTodo::deref() { 418void OTodo::deref() {
419 419
420// qWarning("deref in ToDoEvent"); 420// qWarning("deref in ToDoEvent");
421 if ( data->deref() ) { 421 if ( data->deref() ) {
422// qWarning("deleting"); 422// qWarning("deleting");
423 delete data; 423 delete data;
424 data= 0; 424 data= 0;
425 } 425 }
426} 426}
427OTodo &OTodo::operator=(const OTodo &item ) 427OTodo &OTodo::operator=(const OTodo &item )
428{ 428{
429 if ( this == &item ) return *this; 429 if ( this == &item ) return *this;
430 430
431 OPimRecord::operator=( item ); 431 OPimRecord::operator=( item );
432 //qWarning("operator= ref "); 432 //qWarning("operator= ref ");
433 item.data->ref(); 433 item.data->ref();
434 deref(); 434 deref();
435 data = item.data; 435 data = item.data;
436 436
437 return *this; 437 return *this;
438} 438}
439 439
440QMap<int, QString> OTodo::toMap() const { 440QMap<int, QString> OTodo::toMap() const {
441 QMap<int, QString> map; 441 QMap<int, QString> map;
442 442
443 map.insert( Uid, QString::number( uid() ) ); 443 map.insert( Uid, QString::number( uid() ) );
444 map.insert( Category, idsToString( categories() ) ); 444 map.insert( Category, idsToString( categories() ) );
445 map.insert( HasDate, QString::number( data->hasDate ) ); 445 map.insert( HasDate, QString::number( data->hasDate ) );
446 map.insert( Completed, QString::number( data->isCompleted ) ); 446 map.insert( Completed, QString::number( data->isCompleted ) );
447 map.insert( Description, data->desc ); 447 map.insert( Description, data->desc );
448 map.insert( Summary, data->sum ); 448 map.insert( Summary, data->sum );
449 map.insert( Priority, QString::number( data->priority ) ); 449 map.insert( Priority, QString::number( data->priority ) );
450 map.insert( DateDay, QString::number( data->date.day() ) ); 450 map.insert( DateDay, QString::number( data->date.day() ) );
451 map.insert( DateMonth, QString::number( data->date.month() ) ); 451 map.insert( DateMonth, QString::number( data->date.month() ) );
452 map.insert( DateYear, QString::number( data->date.year() ) ); 452 map.insert( DateYear, QString::number( data->date.year() ) );
453 map.insert( Progress, QString::number( data->prog ) ); 453 map.insert( Progress, QString::number( data->prog ) );
454// map.insert( CrossReference, crossToString() ); 454// map.insert( CrossReference, crossToString() );
455 /* FIXME!!! map.insert( State, ); 455 /* FIXME!!! map.insert( State, );
456 map.insert( Recurrence, ); 456 map.insert( Recurrence, );
457 map.insert( Reminders, ); 457 map.insert( Reminders, );
458 map. 458 map.
459 */ 459 */
460 return map; 460 return map;
461} 461}
462 462
463QMap<QString, QString> OTodo::toExtraMap()const {
464 return data->extra;
465}
466/** 463/**
467 * change or modify looks at the ref count and either 464 * change or modify looks at the ref count and either
468 * creates a new QShared Object or it can modify it 465 * creates a new QShared Object or it can modify it
469 * right in place 466 * right in place
470 */ 467 */
471void OTodo::changeOrModify() { 468void OTodo::changeOrModify() {
472 if ( data->count != 1 ) { 469 if ( data->count != 1 ) {
473 qWarning("changeOrModify"); 470 qWarning("changeOrModify");
474 data->deref(); 471 data->deref();
475 OTodoData* d2 = new OTodoData(); 472 OTodoData* d2 = new OTodoData();
476 copy(data, d2 ); 473 copy(data, d2 );
477 data = d2; 474 data = d2;
478 } 475 }
479} 476}
480// WATCHOUT 477// WATCHOUT
481/* 478/*
482 * if you add something to the Data struct 479 * if you add something to the Data struct
483 * be sure to copy it here 480 * be sure to copy it here
484 */ 481 */
485void OTodo::copy( OTodoData* src, OTodoData* dest ) { 482void OTodo::copy( OTodoData* src, OTodoData* dest ) {
486 dest->date = src->date; 483 dest->date = src->date;
487 dest->isCompleted = src->isCompleted; 484 dest->isCompleted = src->isCompleted;
488 dest->hasDate = src->hasDate; 485 dest->hasDate = src->hasDate;
489 dest->priority = src->priority; 486 dest->priority = src->priority;
490 dest->desc = src->desc; 487 dest->desc = src->desc;
491 dest->sum = src->sum; 488 dest->sum = src->sum;
492 dest->extra = src->extra; 489 dest->extra = src->extra;
493 dest->prog = src->prog; 490 dest->prog = src->prog;
494 491
495 if (src->state ) 492 if (src->state )
496 dest->state = new OPimState( *src->state ); 493 dest->state = new OPimState( *src->state );
497 494
498 if (src->recur ) 495 if (src->recur )
499 dest->recur = new ORecur( *src->recur ); 496 dest->recur = new ORecur( *src->recur );
500 497
501 if (src->maintainer ) 498 if (src->maintainer )
502 dest->maintainer = new OPimMaintainer( *src->maintainer ) 499 dest->maintainer = new OPimMaintainer( *src->maintainer )
503 ; 500 ;
504 dest->start = src->start; 501 dest->start = src->start;
505 dest->completed = src->completed; 502 dest->completed = src->completed;
506 503
507 if (src->notifiers ) 504 if (src->notifiers )
508 dest->notifiers = new OPimNotifyManager( *src->notifiers ); 505 dest->notifiers = new OPimNotifyManager( *src->notifiers );
509} 506}
510QString OTodo::type() const { 507QString OTodo::type() const {
511 return QString::fromLatin1("OTodo"); 508 return QString::fromLatin1("OTodo");
512} 509}
513QString OTodo::recordField(int /*id*/ )const { 510QString OTodo::recordField(int /*id*/ )const {
514 return QString::null; 511 return QString::null;
515} 512}
516 513
517int OTodo::rtti(){ 514int OTodo::rtti(){
518 return OPimResolver::TodoList; 515 return OPimResolver::TodoList;
519} 516}
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index 4d5ee36..f9a345a 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -132,129 +132,128 @@ public:
132 */ 132 */
133 bool hasState()const; 133 bool hasState()const;
134 134
135 /** 135 /**
136 * What is the state of this OTodo? 136 * What is the state of this OTodo?
137 */ 137 */
138 OPimState state()const; 138 OPimState state()const;
139 139
140 /** 140 /**
141 * has recurrence? 141 * has recurrence?
142 */ 142 */
143 bool hasRecurrence()const; 143 bool hasRecurrence()const;
144 144
145 /** 145 /**
146 * the recurrance of this 146 * the recurrance of this
147 */ 147 */
148 ORecur recurrence()const; 148 ORecur recurrence()const;
149 149
150 /** 150 /**
151 * does this OTodo have a maintainer? 151 * does this OTodo have a maintainer?
152 */ 152 */
153 bool hasMaintainer()const; 153 bool hasMaintainer()const;
154 154
155 /** 155 /**
156 * the Maintainer of this OTodo 156 * the Maintainer of this OTodo
157 */ 157 */
158 OPimMaintainer maintainer()const; 158 OPimMaintainer maintainer()const;
159 159
160 /** 160 /**
161 * The description of the todo 161 * The description of the todo
162 */ 162 */
163 QString description()const; 163 QString description()const;
164 164
165 /** 165 /**
166 * A small summary of the todo 166 * A small summary of the todo
167 */ 167 */
168 QString summary() const; 168 QString summary() const;
169 169
170 /** 170 /**
171 * @reimplemented 171 * @reimplemented
172 * Return this todoevent in a RichText formatted QString 172 * Return this todoevent in a RichText formatted QString
173 */ 173 */
174 QString toRichText() const; 174 QString toRichText() const;
175 175
176 bool hasNotifiers()const; 176 bool hasNotifiers()const;
177 /* 177 /*
178 * FIXME check if the sharing is still fine!! -zecke 178 * FIXME check if the sharing is still fine!! -zecke
179 * ### CHECK If API is fine 179 * ### CHECK If API is fine
180 */ 180 */
181 /** 181 /**
182 * return a reference to our notifiers... 182 * return a reference to our notifiers...
183 */ 183 */
184 OPimNotifyManager &notifiers(); 184 OPimNotifyManager &notifiers();
185 185
186 /** 186 /**
187 * 187 *
188 */ 188 */
189 const OPimNotifyManager &notifiers()const; 189 const OPimNotifyManager &notifiers()const;
190 190
191 /** 191 /**
192 * reimplementations 192 * reimplementations
193 */ 193 */
194 QString type()const; 194 QString type()const;
195 QString toShortText()const; 195 QString toShortText()const;
196 QMap<QString, QString> toExtraMap()const;
197 QString recordField(int id )const; 196 QString recordField(int id )const;
198 197
199 /** 198 /**
200 * toMap puts all data into the map. int relates 199 * toMap puts all data into the map. int relates
201 * to ToDoEvent RecordFields enum 200 * to ToDoEvent RecordFields enum
202 */ 201 */
203 QMap<int, QString> toMap()const; 202 QMap<int, QString> toMap()const;
204 203
205 /** 204 /**
206 * Set if this Todo is completed 205 * Set if this Todo is completed
207 */ 206 */
208 void setCompleted(bool completed ); 207 void setCompleted(bool completed );
209 208
210 /** 209 /**
211 * set if this todo got an end data 210 * set if this todo got an end data
212 */ 211 */
213 void setHasDueDate( bool hasDate ); 212 void setHasDueDate( bool hasDate );
214 // FIXME we do not have these for start, completed 213 // FIXME we do not have these for start, completed
215 // cause we'll use the isNull() of QDate for figuring 214 // cause we'll use the isNull() of QDate for figuring
216 // out if it's has a date... 215 // out if it's has a date...
217 // decide what to do here? -zecke 216 // decide what to do here? -zecke
218 217
219 /** 218 /**
220 * Set the priority of the Todo 219 * Set the priority of the Todo
221 */ 220 */
222 void setPriority(int priority ); 221 void setPriority(int priority );
223 222
224 /** 223 /**
225 * Set the progress. 224 * Set the progress.
226 */ 225 */
227 void setProgress( ushort progress ); 226 void setProgress( ushort progress );
228 227
229 /** 228 /**
230 * set the end date 229 * set the end date
231 */ 230 */
232 void setDueDate( const QDate& date ); 231 void setDueDate( const QDate& date );
233 232
234 /** 233 /**
235 * set the start date 234 * set the start date
236 */ 235 */
237 void setStartDate( const QDate& date ); 236 void setStartDate( const QDate& date );
238 237
239 /** 238 /**
240 * set the completed date 239 * set the completed date
241 */ 240 */
242 void setCompletedDate( const QDate& date ); 241 void setCompletedDate( const QDate& date );
243 242
244 void setRecurrence( const ORecur& ); 243 void setRecurrence( const ORecur& );
245 /** 244 /**
246 * set the alarm time 245 * set the alarm time
247 */ 246 */
248 void setAlarmDateTime ( const QDateTime& alarm ); 247 void setAlarmDateTime ( const QDateTime& alarm );
249 248
250 void setDescription(const QString& ); 249 void setDescription(const QString& );
251 void setSummary(const QString& ); 250 void setSummary(const QString& );
252 251
253 /** 252 /**
254 * set the state of a Todo 253 * set the state of a Todo
255 * @param state State what the todo should take 254 * @param state State what the todo should take
256 */ 255 */
257 void setState( const OPimState& state); 256 void setState( const OPimState& state);
258 257
259 /** 258 /**
260 * set the Maintainer Mode 259 * set the Maintainer Mode