summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimtodo.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimtodo.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimtodo.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp
index 47433e0..27b36a6 100644
--- a/libopie2/opiepim/core/opimtodo.cpp
+++ b/libopie2/opiepim/core/opimtodo.cpp
@@ -26,24 +26,26 @@
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimtodo.h" 30#include "opimtodo.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimstate.h> 33#include <opie2/opimstate.h>
34#include <opie2/opimrecurrence.h> 34#include <opie2/opimrecurrence.h>
35#include <opie2/opimmaintainer.h> 35#include <opie2/opimmaintainer.h>
36#include <opie2/opimnotifymanager.h> 36#include <opie2/opimnotifymanager.h>
37#include <opie2/opimresolver.h> 37#include <opie2/opimresolver.h>
38#include <opie2/odebug.h>
39
38#include <qpe/palmtopuidgen.h> 40#include <qpe/palmtopuidgen.h>
39#include <qpe/palmtoprecord.h> 41#include <qpe/palmtoprecord.h>
40#include <qpe/categories.h> 42#include <qpe/categories.h>
41#include <qpe/categoryselect.h> 43#include <qpe/categoryselect.h>
42#include <qpe/stringutil.h> 44#include <qpe/stringutil.h>
43 45
44/* QT */ 46/* QT */
45#include <qobject.h> 47#include <qobject.h>
46#include <qshared.h> 48#include <qshared.h>
47 49
48namespace Opie 50namespace Opie
49{ 51{
@@ -76,73 +78,73 @@ struct OPimTodo::OPimTodoData : public QShared
76 OPimRecurrence *recur; 78 OPimRecurrence *recur;
77 OPimMaintainer *maintainer; 79 OPimMaintainer *maintainer;
78 QDate start; 80 QDate start;
79 QDate completed; 81 QDate completed;
80 OPimNotifyManager *notifiers; 82 OPimNotifyManager *notifiers;
81}; 83};
82 84
83 85
84OPimTodo::OPimTodo( const OPimTodo &event ) 86OPimTodo::OPimTodo( const OPimTodo &event )
85 : OPimRecord( event ), data( event.data ) 87 : OPimRecord( event ), data( event.data )
86{ 88{
87 data->ref(); 89 data->ref();
88 // qWarning("ref up"); 90 // owarn << "ref up" << oendl;
89} 91}
90 92
91 93
92OPimTodo::~OPimTodo() 94OPimTodo::~OPimTodo()
93{ 95{
94 96
95 // qWarning("~OPimTodo " ); 97 // owarn << "~OPimTodo " << oendl;
96 if ( data->deref() ) 98 if ( data->deref() )
97 { 99 {
98 // qWarning("OPimTodo::dereffing"); 100 // owarn << "OPimTodo::dereffing" << oendl;
99 delete data; 101 delete data;
100 data = 0l; 102 data = 0l;
101 } 103 }
102} 104}
103 105
104 106
105OPimTodo::OPimTodo( bool completed, int priority, 107OPimTodo::OPimTodo( bool completed, int priority,
106 const QArray<int> &category, 108 const QArray<int> &category,
107 const QString& summary, 109 const QString& summary,
108 const QString &description, 110 const QString &description,
109 ushort progress, 111 ushort progress,
110 bool hasDate, QDate date, int uid ) 112 bool hasDate, QDate date, int uid )
111 : OPimRecord( uid ) 113 : OPimRecord( uid )
112{ 114{
113 // qWarning("OPimTodoData " + summary); 115 // owarn << "OPimTodoData " + summary << oendl;
114 setCategories( category ); 116 setCategories( category );
115 117
116 data = new OPimTodoData; 118 data = new OPimTodoData;
117 119
118 data->date = date; 120 data->date = date;
119 data->isCompleted = completed; 121 data->isCompleted = completed;
120 data->hasDate = hasDate; 122 data->hasDate = hasDate;
121 data->priority = priority; 123 data->priority = priority;
122 data->sum = summary; 124 data->sum = summary;
123 data->prog = progress; 125 data->prog = progress;
124 data->desc = Qtopia::simplifyMultiLineSpace( description ); 126 data->desc = Qtopia::simplifyMultiLineSpace( description );
125} 127}
126 128
127 129
128OPimTodo::OPimTodo( bool completed, int priority, 130OPimTodo::OPimTodo( bool completed, int priority,
129 const QStringList &category, 131 const QStringList &category,
130 const QString& summary, 132 const QString& summary,
131 const QString &description, 133 const QString &description,
132 ushort progress, 134 ushort progress,
133 bool hasDate, QDate date, int uid ) 135 bool hasDate, QDate date, int uid )
134 : OPimRecord( uid ) 136 : OPimRecord( uid )
135{ 137{
136 // qWarning("OPimTodoData" + summary); 138 // owarn << "OPimTodoData" + summary << oendl;
137 setCategories( idsFromString( category.join( ";" ) ) ); 139 setCategories( idsFromString( category.join( ";" ) ) );
138 140
139 data = new OPimTodoData; 141 data = new OPimTodoData;
140 142
141 data->date = date; 143 data->date = date;
142 data->isCompleted = completed; 144 data->isCompleted = completed;
143 data->hasDate = hasDate; 145 data->hasDate = hasDate;
144 data->priority = priority; 146 data->priority = priority;
145 data->sum = summary; 147 data->sum = summary;
146 data->prog = progress; 148 data->prog = progress;
147 data->desc = Qtopia::simplifyMultiLineSpace( description ); 149 data->desc = Qtopia::simplifyMultiLineSpace( description );
148} 150}
@@ -297,25 +299,25 @@ void OPimTodo::setCompleted( bool completed )
297} 299}
298 300
299 301
300void OPimTodo::setHasDueDate( bool hasDate ) 302void OPimTodo::setHasDueDate( bool hasDate )
301{ 303{
302 changeOrModify(); 304 changeOrModify();
303 data->hasDate = hasDate; 305 data->hasDate = hasDate;
304} 306}
305 307
306 308
307void OPimTodo::setDescription( const QString &desc ) 309void OPimTodo::setDescription( const QString &desc )
308{ 310{
309 // qWarning( "desc " + desc ); 311 // owarn << "desc " + desc << oendl;
310 changeOrModify(); 312 changeOrModify();
311 data->desc = Qtopia::simplifyMultiLineSpace( desc ); 313 data->desc = Qtopia::simplifyMultiLineSpace( desc );
312} 314}
313 315
314 316
315void OPimTodo::setSummary( const QString& sum ) 317void OPimTodo::setSummary( const QString& sum )
316{ 318{
317 changeOrModify(); 319 changeOrModify();
318 data->sum = sum; 320 data->sum = sum;
319} 321}
320 322
321 323
@@ -582,40 +584,40 @@ bool OPimTodo::operator==( const OPimTodo &toDoEvent ) const
582 if ( data->sum != toDoEvent.data->sum ) return false; 584 if ( data->sum != toDoEvent.data->sum ) return false;
583 if ( data->desc != toDoEvent.data->desc ) return false; 585 if ( data->desc != toDoEvent.data->desc ) return false;
584 if ( data->maintainer != toDoEvent.data->maintainer ) 586 if ( data->maintainer != toDoEvent.data->maintainer )
585 return false; 587 return false;
586 588
587 return OPimRecord::operator==( toDoEvent ); 589 return OPimRecord::operator==( toDoEvent );
588} 590}
589 591
590 592
591void OPimTodo::deref() 593void OPimTodo::deref()
592{ 594{
593 595
594 // qWarning("deref in ToDoEvent"); 596 // owarn << "deref in ToDoEvent" << oendl;
595 if ( data->deref() ) 597 if ( data->deref() )
596 { 598 {
597 // qWarning("deleting"); 599 // owarn << "deleting" << oendl;
598 delete data; 600 delete data;
599 data = 0; 601 data = 0;
600 } 602 }
601} 603}
602 604
603 605
604OPimTodo &OPimTodo::operator=( const OPimTodo &item ) 606OPimTodo &OPimTodo::operator=( const OPimTodo &item )
605{ 607{
606 if ( this == &item ) return * this; 608 if ( this == &item ) return * this;
607 609
608 OPimRecord::operator=( item ); 610 OPimRecord::operator=( item );
609 //qWarning("operator= ref "); 611 //owarn << "operator= ref " << oendl;
610 item.data->ref(); 612 item.data->ref();
611 deref(); 613 deref();
612 data = item.data; 614 data = item.data;
613 615
614 return *this; 616 return *this;
615} 617}
616 618
617 619
618QMap<int, QString> OPimTodo::toMap() const 620QMap<int, QString> OPimTodo::toMap() const
619{ 621{
620 QMap<int, QString> map; 622 QMap<int, QString> map;
621 623
@@ -640,25 +642,25 @@ QMap<int, QString> OPimTodo::toMap() const
640} 642}
641 643
642 644
643/** 645/**
644 * change or modify looks at the ref count and either 646 * change or modify looks at the ref count and either
645 * creates a new QShared Object or it can modify it 647 * creates a new QShared Object or it can modify it
646 * right in place 648 * right in place
647 */ 649 */
648void OPimTodo::changeOrModify() 650void OPimTodo::changeOrModify()
649{ 651{
650 if ( data->count != 1 ) 652 if ( data->count != 1 )
651 { 653 {
652 qWarning( "changeOrModify" ); 654 owarn << "changeOrModify" << oendl;
653 data->deref(); 655 data->deref();
654 OPimTodoData* d2 = new OPimTodoData(); 656 OPimTodoData* d2 = new OPimTodoData();
655 copy( data, d2 ); 657 copy( data, d2 );
656 data = d2; 658 data = d2;
657 } 659 }
658} 660}
659 661
660 662
661// WATCHOUT 663// WATCHOUT
662/* 664/*
663 * if you add something to the Data struct 665 * if you add something to the Data struct
664 * be sure to copy it here 666 * be sure to copy it here