summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodo.cpp81
-rw-r--r--libopie/pim/otodo.h16
-rw-r--r--libopie2/opiepim/otodo.cpp81
-rw-r--r--libopie2/opiepim/otodo.h16
4 files changed, 164 insertions, 30 deletions
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index ea66d39..f3df119 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -10,48 +10,52 @@
10#include <qpe/stringutil.h> 10#include <qpe/stringutil.h>
11#include <qpe/categories.h> 11#include <qpe/categories.h>
12#include <qpe/categoryselect.h> 12#include <qpe/categoryselect.h>
13 13
14 14
15#include "opimstate.h" 15#include "opimstate.h"
16#include "orecur.h" 16#include "orecur.h"
17#include "opimmaintainer.h" 17#include "opimmaintainer.h"
18#include "opimnotifymanager.h" 18#include "opimnotifymanager.h"
19#include "opimresolver.h" 19#include "opimresolver.h"
20 20
21#include "otodo.h" 21#include "otodo.h"
22 22
23 23
24struct OTodo::OTodoData : public QShared { 24struct OTodo::OTodoData : public QShared {
25 OTodoData() : QShared() { 25 OTodoData() : QShared() {
26 recur = 0;
27 state = 0;
28 maintainer = 0;
29 notifiers = 0;
26 }; 30 };
27 31
28 QDate date; 32 QDate date;
29 bool isCompleted:1; 33 bool isCompleted:1;
30 bool hasDate:1; 34 bool hasDate:1;
31 int priority; 35 int priority;
32 QString desc; 36 QString desc;
33 QString sum; 37 QString sum;
34 QMap<QString, QString> extra; 38 QMap<QString, QString> extra;
35 ushort prog; 39 ushort prog;
36 OPimState state; 40 OPimState *state;
37 ORecur recur; 41 ORecur *recur;
38 OPimMaintainer maintainer; 42 OPimMaintainer *maintainer;
39 QDate start; 43 QDate start;
40 QDate completed; 44 QDate completed;
41 OPimNotifyManager notifiers; 45 OPimNotifyManager *notifiers;
42}; 46};
43 47
44OTodo::OTodo(const OTodo &event ) 48OTodo::OTodo(const OTodo &event )
45 : OPimRecord( event ), data( event.data ) 49 : OPimRecord( event ), data( event.data )
46{ 50{
47 data->ref(); 51 data->ref();
48// qWarning("ref up"); 52// qWarning("ref up");
49} 53}
50OTodo::~OTodo() { 54OTodo::~OTodo() {
51 55
52// qWarning("~OTodo " ); 56// qWarning("~OTodo " );
53 if ( data->deref() ) { 57 if ( data->deref() ) {
54// qWarning("OTodo::dereffing"); 58// qWarning("OTodo::dereffing");
55 delete data; 59 delete data;
56 data = 0l; 60 data = 0l;
57 } 61 }
@@ -138,40 +142,62 @@ ushort OTodo::progress() const
138 return data->prog; 142 return data->prog;
139} 143}
140QDate OTodo::dueDate()const 144QDate OTodo::dueDate()const
141{ 145{
142 return data->date; 146 return data->date;
143} 147}
144QDate OTodo::startDate()const { 148QDate OTodo::startDate()const {
145 return data->start; 149 return data->start;
146} 150}
147QDate OTodo::completedDate()const { 151QDate OTodo::completedDate()const {
148 return data->completed; 152 return data->completed;
149} 153}
150QString OTodo::description()const 154QString OTodo::description()const
151{ 155{
152 return data->desc; 156 return data->desc;
153} 157}
158bool OTodo::hasState() const{
159 if (!data->state ) return false;
160 return ( data->state->state() != OPimState::Undefined );
161}
154OPimState OTodo::state()const { 162OPimState OTodo::state()const {
155 return data->state; 163 if (!data->state ) {
164 OPimState state;
165 return state;
166 }
167
168 return (*data->state);
169}
170bool OTodo::hasRecurrence()const {
171 if (!data->recur) return false;
172 return data->recur->doesRecur();
156} 173}
157ORecur OTodo::recurrence()const { 174ORecur OTodo::recurrence()const {
158 return data->recur; 175 if (!data->recur) return ORecur();
176
177 return (*data->recur);
178}
179bool OTodo::hasMaintainer()const {
180 if (!data->maintainer) return false;
181
182 return (data->maintainer->mode() != OPimMaintainer::Undefined );
159} 183}
160OPimMaintainer OTodo::maintainer()const { 184OPimMaintainer OTodo::maintainer()const {
161 return data->maintainer; 185 if (!data->maintainer) return OPimMaintainer();
186
187 return (*data->maintainer);
162} 188}
163void OTodo::setCompleted( bool completed ) 189void OTodo::setCompleted( bool completed )
164{ 190{
165 changeOrModify(); 191 changeOrModify();
166 data->isCompleted = completed; 192 data->isCompleted = completed;
167} 193}
168void OTodo::setHasDueDate( bool hasDate ) 194void OTodo::setHasDueDate( bool hasDate )
169{ 195{
170 changeOrModify(); 196 changeOrModify();
171 data->hasDate = hasDate; 197 data->hasDate = hasDate;
172} 198}
173void OTodo::setDescription(const QString &desc ) 199void OTodo::setDescription(const QString &desc )
174{ 200{
175// qWarning( "desc " + desc ); 201// qWarning( "desc " + desc );
176 changeOrModify(); 202 changeOrModify();
177 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 203 data->desc = Qtopia::simplifyMultiLineSpace(desc );
@@ -188,41 +214,51 @@ void OTodo::setPriority(int prio )
188} 214}
189void OTodo::setDueDate( const QDate& date ) 215void OTodo::setDueDate( const QDate& date )
190{ 216{
191 changeOrModify(); 217 changeOrModify();
192 data->date = date; 218 data->date = date;
193} 219}
194void OTodo::setStartDate( const QDate& date ) { 220void OTodo::setStartDate( const QDate& date ) {
195 changeOrModify(); 221 changeOrModify();
196 data->start = date; 222 data->start = date;
197} 223}
198void OTodo::setCompletedDate( const QDate& date ) { 224void OTodo::setCompletedDate( const QDate& date ) {
199 changeOrModify(); 225 changeOrModify();
200 data->completed = date; 226 data->completed = date;
201} 227}
202void OTodo::setState( const OPimState& state ) { 228void OTodo::setState( const OPimState& state ) {
203 changeOrModify(); 229 changeOrModify();
204 data->state = state; 230 if (data->state )
231 (*data->state) = state;
232 else
233 data->state = new OPimState( state );
205} 234}
206void OTodo::setRecurrence( const ORecur& rec) { 235void OTodo::setRecurrence( const ORecur& rec) {
207 changeOrModify(); 236 changeOrModify();
208 data->recur = rec; 237 if (data->recur )
238 (*data->recur) = rec;
239 else
240 data->recur = new ORecur( rec );
209} 241}
210void OTodo::setMaintainer( const OPimMaintainer& pim ) { 242void OTodo::setMaintainer( const OPimMaintainer& pim ) {
211 changeOrModify(); 243 changeOrModify();
212 data->maintainer = pim; 244
245 if (data->maintainer )
246 (*data->maintainer) = pim;
247 else
248 data->maintainer = new OPimMaintainer( pim );
213} 249}
214bool OTodo::isOverdue( ) 250bool OTodo::isOverdue( )
215{ 251{
216 if( data->hasDate && !data->isCompleted) 252 if( data->hasDate && !data->isCompleted)
217 return QDate::currentDate() > data->date; 253 return QDate::currentDate() > data->date;
218 return false; 254 return false;
219} 255}
220void OTodo::setProgress(ushort progress ) 256void OTodo::setProgress(ushort progress )
221{ 257{
222 changeOrModify(); 258 changeOrModify();
223 data->prog = progress; 259 data->prog = progress;
224} 260}
225QString OTodo::toShortText() const { 261QString OTodo::toShortText() const {
226 return summary(); 262 return summary();
227} 263}
228/*! 264/*!
@@ -247,34 +283,40 @@ QString OTodo::toRichText() const
247 text += "<b>" + QObject::tr( "Priority:") +" </b>" 283 text += "<b>" + QObject::tr( "Priority:") +" </b>"
248 + QString::number( priority() ) + " <br>"; 284 + QString::number( priority() ) + " <br>";
249 text += "<b>" + QObject::tr( "Progress:") + " </b>" 285 text += "<b>" + QObject::tr( "Progress:") + " </b>"
250 + QString::number( progress() ) + " %<br>"; 286 + QString::number( progress() ) + " %<br>";
251 if (hasDueDate() ){ 287 if (hasDueDate() ){
252 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 288 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
253 text += dueDate().toString(); 289 text += dueDate().toString();
254 text += "<br>"; 290 text += "<br>";
255 } 291 }
256 292
257 text += "<b>" + QObject::tr( "Category:") + "</b> "; 293 text += "<b>" + QObject::tr( "Category:") + "</b> ";
258 text += categoryNames( "Todo List" ).join(", "); 294 text += categoryNames( "Todo List" ).join(", ");
259 text += "<br>"; 295 text += "<br>";
260 296
261 return text; 297 return text;
262} 298}
299bool OTodo::hasNotifiers()const {
300 if (!data->notifiers) return false;
301 return data->notifiers->isEmpty();
302}
263OPimNotifyManager& OTodo::notifiers() { 303OPimNotifyManager& OTodo::notifiers() {
264 return data->notifiers; 304 if (!data->notifiers )
305 data->notifiers = new OPimNotifyManager;
306 return (*data->notifiers);
265} 307}
266 308
267bool OTodo::operator<( const OTodo &toDoEvent )const{ 309bool OTodo::operator<( const OTodo &toDoEvent )const{
268 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 310 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
269 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 311 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
270 if( hasDueDate() && toDoEvent.hasDueDate() ){ 312 if( hasDueDate() && toDoEvent.hasDueDate() ){
271 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 313 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
272 return priority() < toDoEvent.priority(); 314 return priority() < toDoEvent.priority();
273 }else{ 315 }else{
274 return dueDate() < toDoEvent.dueDate(); 316 return dueDate() < toDoEvent.dueDate();
275 } 317 }
276 } 318 }
277 return false; 319 return false;
278} 320}
279bool OTodo::operator<=(const OTodo &toDoEvent )const 321bool OTodo::operator<=(const OTodo &toDoEvent )const
280{ 322{
@@ -392,33 +434,42 @@ void OTodo::changeOrModify() {
392 } 434 }
393} 435}
394// WATCHOUT 436// WATCHOUT
395/* 437/*
396 * if you add something to the Data struct 438 * if you add something to the Data struct
397 * be sure to copy it here 439 * be sure to copy it here
398 */ 440 */
399void OTodo::copy( OTodoData* src, OTodoData* dest ) { 441void OTodo::copy( OTodoData* src, OTodoData* dest ) {
400 dest->date = src->date; 442 dest->date = src->date;
401 dest->isCompleted = src->isCompleted; 443 dest->isCompleted = src->isCompleted;
402 dest->hasDate = src->hasDate; 444 dest->hasDate = src->hasDate;
403 dest->priority = src->priority; 445 dest->priority = src->priority;
404 dest->desc = src->desc; 446 dest->desc = src->desc;
405 dest->sum = src->sum; 447 dest->sum = src->sum;
406 dest->extra = src->extra; 448 dest->extra = src->extra;
407 dest->prog = src->prog; 449 dest->prog = src->prog;
408 dest->state = src->state; 450
409 dest->recur = src->recur; 451 if (src->state )
410 dest->maintainer = src->maintainer; 452 dest->state = new OPimState( *src->state );
453
454 if (src->recur )
455 dest->recur = new ORecur( *src->recur );
456
457 if (src->maintainer )
458 dest->maintainer = new OPimMaintainer( *src->maintainer )
459 ;
411 dest->start = src->start; 460 dest->start = src->start;
412 dest->completed = src->completed; 461 dest->completed = src->completed;
413 dest->notifiers = src->notifiers; 462
463 if (src->notifiers )
464 dest->notifiers = new OPimNotifyManager( *src->notifiers );
414} 465}
415QString OTodo::type() const { 466QString OTodo::type() const {
416 return QString::fromLatin1("OTodo"); 467 return QString::fromLatin1("OTodo");
417} 468}
418QString OTodo::recordField(int /*id*/ )const { 469QString OTodo::recordField(int /*id*/ )const {
419 return QString::null; 470 return QString::null;
420} 471}
421 472
422int OTodo::rtti(){ 473int OTodo::rtti(){
423 return OPimResolver::TodoList; 474 return OPimResolver::TodoList;
424} 475}
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index 2f66f55..a58d9aa 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -115,62 +115,78 @@ public:
115 /** 115 /**
116 * The due Date 116 * The due Date
117 */ 117 */
118 QDate dueDate()const; 118 QDate dueDate()const;
119 119
120 /** 120 /**
121 * When did it start? 121 * When did it start?
122 */ 122 */
123 QDate startDate()const; 123 QDate startDate()const;
124 124
125 /** 125 /**
126 * When was it completed? 126 * When was it completed?
127 */ 127 */
128 QDate completedDate()const; 128 QDate completedDate()const;
129 129
130 /** 130 /**
131 * does it have a state?
132 */
133 bool hasState()const;
134
135 /**
131 * What is the state of this OTodo? 136 * What is the state of this OTodo?
132 */ 137 */
133 OPimState state()const; 138 OPimState state()const;
134 139
135 /** 140 /**
141 * has recurrence?
142 */
143 bool hasRecurrence()const;
144
145 /**
136 * the recurrance of this 146 * the recurrance of this
137 */ 147 */
138 ORecur recurrence()const; 148 ORecur recurrence()const;
139 149
140 /** 150 /**
151 * does this OTodo have a maintainer?
152 */
153 bool hasMaintainer()const;
154
155 /**
141 * the Maintainer of this OTodo 156 * the Maintainer of this OTodo
142 */ 157 */
143 OPimMaintainer maintainer()const; 158 OPimMaintainer maintainer()const;
144 159
145 /** 160 /**
146 * The description of the todo 161 * The description of the todo
147 */ 162 */
148 QString description()const; 163 QString description()const;
149 164
150 /** 165 /**
151 * A small summary of the todo 166 * A small summary of the todo
152 */ 167 */
153 QString summary() const; 168 QString summary() const;
154 169
155 /** 170 /**
156 * @reimplemented 171 * @reimplemented
157 * Return this todoevent in a RichText formatted QString 172 * Return this todoevent in a RichText formatted QString
158 */ 173 */
159 QString toRichText() const; 174 QString toRichText() const;
160 175
176 bool hasNotifiers()const;
161 /* 177 /*
162 * check if the sharing is still fine!! -zecke 178 * check if the sharing is still fine!! -zecke
163 */ 179 */
164 /** 180 /**
165 * return a reference to our notifiers... 181 * return a reference to our notifiers...
166 */ 182 */
167 OPimNotifyManager &notifiers(); 183 OPimNotifyManager &notifiers();
168 184
169 /** 185 /**
170 * reimplementations 186 * reimplementations
171 */ 187 */
172 QString type()const; 188 QString type()const;
173 QString toShortText()const; 189 QString toShortText()const;
174 QMap<QString, QString> toExtraMap()const; 190 QMap<QString, QString> toExtraMap()const;
175 QString recordField(int id )const; 191 QString recordField(int id )const;
176 192
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index ea66d39..f3df119 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -10,48 +10,52 @@
10#include <qpe/stringutil.h> 10#include <qpe/stringutil.h>
11#include <qpe/categories.h> 11#include <qpe/categories.h>
12#include <qpe/categoryselect.h> 12#include <qpe/categoryselect.h>
13 13
14 14
15#include "opimstate.h" 15#include "opimstate.h"
16#include "orecur.h" 16#include "orecur.h"
17#include "opimmaintainer.h" 17#include "opimmaintainer.h"
18#include "opimnotifymanager.h" 18#include "opimnotifymanager.h"
19#include "opimresolver.h" 19#include "opimresolver.h"
20 20
21#include "otodo.h" 21#include "otodo.h"
22 22
23 23
24struct OTodo::OTodoData : public QShared { 24struct OTodo::OTodoData : public QShared {
25 OTodoData() : QShared() { 25 OTodoData() : QShared() {
26 recur = 0;
27 state = 0;
28 maintainer = 0;
29 notifiers = 0;
26 }; 30 };
27 31
28 QDate date; 32 QDate date;
29 bool isCompleted:1; 33 bool isCompleted:1;
30 bool hasDate:1; 34 bool hasDate:1;
31 int priority; 35 int priority;
32 QString desc; 36 QString desc;
33 QString sum; 37 QString sum;
34 QMap<QString, QString> extra; 38 QMap<QString, QString> extra;
35 ushort prog; 39 ushort prog;
36 OPimState state; 40 OPimState *state;
37 ORecur recur; 41 ORecur *recur;
38 OPimMaintainer maintainer; 42 OPimMaintainer *maintainer;
39 QDate start; 43 QDate start;
40 QDate completed; 44 QDate completed;
41 OPimNotifyManager notifiers; 45 OPimNotifyManager *notifiers;
42}; 46};
43 47
44OTodo::OTodo(const OTodo &event ) 48OTodo::OTodo(const OTodo &event )
45 : OPimRecord( event ), data( event.data ) 49 : OPimRecord( event ), data( event.data )
46{ 50{
47 data->ref(); 51 data->ref();
48// qWarning("ref up"); 52// qWarning("ref up");
49} 53}
50OTodo::~OTodo() { 54OTodo::~OTodo() {
51 55
52// qWarning("~OTodo " ); 56// qWarning("~OTodo " );
53 if ( data->deref() ) { 57 if ( data->deref() ) {
54// qWarning("OTodo::dereffing"); 58// qWarning("OTodo::dereffing");
55 delete data; 59 delete data;
56 data = 0l; 60 data = 0l;
57 } 61 }
@@ -138,40 +142,62 @@ ushort OTodo::progress() const
138 return data->prog; 142 return data->prog;
139} 143}
140QDate OTodo::dueDate()const 144QDate OTodo::dueDate()const
141{ 145{
142 return data->date; 146 return data->date;
143} 147}
144QDate OTodo::startDate()const { 148QDate OTodo::startDate()const {
145 return data->start; 149 return data->start;
146} 150}
147QDate OTodo::completedDate()const { 151QDate OTodo::completedDate()const {
148 return data->completed; 152 return data->completed;
149} 153}
150QString OTodo::description()const 154QString OTodo::description()const
151{ 155{
152 return data->desc; 156 return data->desc;
153} 157}
158bool OTodo::hasState() const{
159 if (!data->state ) return false;
160 return ( data->state->state() != OPimState::Undefined );
161}
154OPimState OTodo::state()const { 162OPimState OTodo::state()const {
155 return data->state; 163 if (!data->state ) {
164 OPimState state;
165 return state;
166 }
167
168 return (*data->state);
169}
170bool OTodo::hasRecurrence()const {
171 if (!data->recur) return false;
172 return data->recur->doesRecur();
156} 173}
157ORecur OTodo::recurrence()const { 174ORecur OTodo::recurrence()const {
158 return data->recur; 175 if (!data->recur) return ORecur();
176
177 return (*data->recur);
178}
179bool OTodo::hasMaintainer()const {
180 if (!data->maintainer) return false;
181
182 return (data->maintainer->mode() != OPimMaintainer::Undefined );
159} 183}
160OPimMaintainer OTodo::maintainer()const { 184OPimMaintainer OTodo::maintainer()const {
161 return data->maintainer; 185 if (!data->maintainer) return OPimMaintainer();
186
187 return (*data->maintainer);
162} 188}
163void OTodo::setCompleted( bool completed ) 189void OTodo::setCompleted( bool completed )
164{ 190{
165 changeOrModify(); 191 changeOrModify();
166 data->isCompleted = completed; 192 data->isCompleted = completed;
167} 193}
168void OTodo::setHasDueDate( bool hasDate ) 194void OTodo::setHasDueDate( bool hasDate )
169{ 195{
170 changeOrModify(); 196 changeOrModify();
171 data->hasDate = hasDate; 197 data->hasDate = hasDate;
172} 198}
173void OTodo::setDescription(const QString &desc ) 199void OTodo::setDescription(const QString &desc )
174{ 200{
175// qWarning( "desc " + desc ); 201// qWarning( "desc " + desc );
176 changeOrModify(); 202 changeOrModify();
177 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 203 data->desc = Qtopia::simplifyMultiLineSpace(desc );
@@ -188,41 +214,51 @@ void OTodo::setPriority(int prio )
188} 214}
189void OTodo::setDueDate( const QDate& date ) 215void OTodo::setDueDate( const QDate& date )
190{ 216{
191 changeOrModify(); 217 changeOrModify();
192 data->date = date; 218 data->date = date;
193} 219}
194void OTodo::setStartDate( const QDate& date ) { 220void OTodo::setStartDate( const QDate& date ) {
195 changeOrModify(); 221 changeOrModify();
196 data->start = date; 222 data->start = date;
197} 223}
198void OTodo::setCompletedDate( const QDate& date ) { 224void OTodo::setCompletedDate( const QDate& date ) {
199 changeOrModify(); 225 changeOrModify();
200 data->completed = date; 226 data->completed = date;
201} 227}
202void OTodo::setState( const OPimState& state ) { 228void OTodo::setState( const OPimState& state ) {
203 changeOrModify(); 229 changeOrModify();
204 data->state = state; 230 if (data->state )
231 (*data->state) = state;
232 else
233 data->state = new OPimState( state );
205} 234}
206void OTodo::setRecurrence( const ORecur& rec) { 235void OTodo::setRecurrence( const ORecur& rec) {
207 changeOrModify(); 236 changeOrModify();
208 data->recur = rec; 237 if (data->recur )
238 (*data->recur) = rec;
239 else
240 data->recur = new ORecur( rec );
209} 241}
210void OTodo::setMaintainer( const OPimMaintainer& pim ) { 242void OTodo::setMaintainer( const OPimMaintainer& pim ) {
211 changeOrModify(); 243 changeOrModify();
212 data->maintainer = pim; 244
245 if (data->maintainer )
246 (*data->maintainer) = pim;
247 else
248 data->maintainer = new OPimMaintainer( pim );
213} 249}
214bool OTodo::isOverdue( ) 250bool OTodo::isOverdue( )
215{ 251{
216 if( data->hasDate && !data->isCompleted) 252 if( data->hasDate && !data->isCompleted)
217 return QDate::currentDate() > data->date; 253 return QDate::currentDate() > data->date;
218 return false; 254 return false;
219} 255}
220void OTodo::setProgress(ushort progress ) 256void OTodo::setProgress(ushort progress )
221{ 257{
222 changeOrModify(); 258 changeOrModify();
223 data->prog = progress; 259 data->prog = progress;
224} 260}
225QString OTodo::toShortText() const { 261QString OTodo::toShortText() const {
226 return summary(); 262 return summary();
227} 263}
228/*! 264/*!
@@ -247,34 +283,40 @@ QString OTodo::toRichText() const
247 text += "<b>" + QObject::tr( "Priority:") +" </b>" 283 text += "<b>" + QObject::tr( "Priority:") +" </b>"
248 + QString::number( priority() ) + " <br>"; 284 + QString::number( priority() ) + " <br>";
249 text += "<b>" + QObject::tr( "Progress:") + " </b>" 285 text += "<b>" + QObject::tr( "Progress:") + " </b>"
250 + QString::number( progress() ) + " %<br>"; 286 + QString::number( progress() ) + " %<br>";
251 if (hasDueDate() ){ 287 if (hasDueDate() ){
252 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 288 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
253 text += dueDate().toString(); 289 text += dueDate().toString();
254 text += "<br>"; 290 text += "<br>";
255 } 291 }
256 292
257 text += "<b>" + QObject::tr( "Category:") + "</b> "; 293 text += "<b>" + QObject::tr( "Category:") + "</b> ";
258 text += categoryNames( "Todo List" ).join(", "); 294 text += categoryNames( "Todo List" ).join(", ");
259 text += "<br>"; 295 text += "<br>";
260 296
261 return text; 297 return text;
262} 298}
299bool OTodo::hasNotifiers()const {
300 if (!data->notifiers) return false;
301 return data->notifiers->isEmpty();
302}
263OPimNotifyManager& OTodo::notifiers() { 303OPimNotifyManager& OTodo::notifiers() {
264 return data->notifiers; 304 if (!data->notifiers )
305 data->notifiers = new OPimNotifyManager;
306 return (*data->notifiers);
265} 307}
266 308
267bool OTodo::operator<( const OTodo &toDoEvent )const{ 309bool OTodo::operator<( const OTodo &toDoEvent )const{
268 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 310 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
269 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 311 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
270 if( hasDueDate() && toDoEvent.hasDueDate() ){ 312 if( hasDueDate() && toDoEvent.hasDueDate() ){
271 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 313 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
272 return priority() < toDoEvent.priority(); 314 return priority() < toDoEvent.priority();
273 }else{ 315 }else{
274 return dueDate() < toDoEvent.dueDate(); 316 return dueDate() < toDoEvent.dueDate();
275 } 317 }
276 } 318 }
277 return false; 319 return false;
278} 320}
279bool OTodo::operator<=(const OTodo &toDoEvent )const 321bool OTodo::operator<=(const OTodo &toDoEvent )const
280{ 322{
@@ -392,33 +434,42 @@ void OTodo::changeOrModify() {
392 } 434 }
393} 435}
394// WATCHOUT 436// WATCHOUT
395/* 437/*
396 * if you add something to the Data struct 438 * if you add something to the Data struct
397 * be sure to copy it here 439 * be sure to copy it here
398 */ 440 */
399void OTodo::copy( OTodoData* src, OTodoData* dest ) { 441void OTodo::copy( OTodoData* src, OTodoData* dest ) {
400 dest->date = src->date; 442 dest->date = src->date;
401 dest->isCompleted = src->isCompleted; 443 dest->isCompleted = src->isCompleted;
402 dest->hasDate = src->hasDate; 444 dest->hasDate = src->hasDate;
403 dest->priority = src->priority; 445 dest->priority = src->priority;
404 dest->desc = src->desc; 446 dest->desc = src->desc;
405 dest->sum = src->sum; 447 dest->sum = src->sum;
406 dest->extra = src->extra; 448 dest->extra = src->extra;
407 dest->prog = src->prog; 449 dest->prog = src->prog;
408 dest->state = src->state; 450
409 dest->recur = src->recur; 451 if (src->state )
410 dest->maintainer = src->maintainer; 452 dest->state = new OPimState( *src->state );
453
454 if (src->recur )
455 dest->recur = new ORecur( *src->recur );
456
457 if (src->maintainer )
458 dest->maintainer = new OPimMaintainer( *src->maintainer )
459 ;
411 dest->start = src->start; 460 dest->start = src->start;
412 dest->completed = src->completed; 461 dest->completed = src->completed;
413 dest->notifiers = src->notifiers; 462
463 if (src->notifiers )
464 dest->notifiers = new OPimNotifyManager( *src->notifiers );
414} 465}
415QString OTodo::type() const { 466QString OTodo::type() const {
416 return QString::fromLatin1("OTodo"); 467 return QString::fromLatin1("OTodo");
417} 468}
418QString OTodo::recordField(int /*id*/ )const { 469QString OTodo::recordField(int /*id*/ )const {
419 return QString::null; 470 return QString::null;
420} 471}
421 472
422int OTodo::rtti(){ 473int OTodo::rtti(){
423 return OPimResolver::TodoList; 474 return OPimResolver::TodoList;
424} 475}
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index 2f66f55..a58d9aa 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -115,62 +115,78 @@ public:
115 /** 115 /**
116 * The due Date 116 * The due Date
117 */ 117 */
118 QDate dueDate()const; 118 QDate dueDate()const;
119 119
120 /** 120 /**
121 * When did it start? 121 * When did it start?
122 */ 122 */
123 QDate startDate()const; 123 QDate startDate()const;
124 124
125 /** 125 /**
126 * When was it completed? 126 * When was it completed?
127 */ 127 */
128 QDate completedDate()const; 128 QDate completedDate()const;
129 129
130 /** 130 /**
131 * does it have a state?
132 */
133 bool hasState()const;
134
135 /**
131 * What is the state of this OTodo? 136 * What is the state of this OTodo?
132 */ 137 */
133 OPimState state()const; 138 OPimState state()const;
134 139
135 /** 140 /**
141 * has recurrence?
142 */
143 bool hasRecurrence()const;
144
145 /**
136 * the recurrance of this 146 * the recurrance of this
137 */ 147 */
138 ORecur recurrence()const; 148 ORecur recurrence()const;
139 149
140 /** 150 /**
151 * does this OTodo have a maintainer?
152 */
153 bool hasMaintainer()const;
154
155 /**
141 * the Maintainer of this OTodo 156 * the Maintainer of this OTodo
142 */ 157 */
143 OPimMaintainer maintainer()const; 158 OPimMaintainer maintainer()const;
144 159
145 /** 160 /**
146 * The description of the todo 161 * The description of the todo
147 */ 162 */
148 QString description()const; 163 QString description()const;
149 164
150 /** 165 /**
151 * A small summary of the todo 166 * A small summary of the todo
152 */ 167 */
153 QString summary() const; 168 QString summary() const;
154 169
155 /** 170 /**
156 * @reimplemented 171 * @reimplemented
157 * Return this todoevent in a RichText formatted QString 172 * Return this todoevent in a RichText formatted QString
158 */ 173 */
159 QString toRichText() const; 174 QString toRichText() const;
160 175
176 bool hasNotifiers()const;
161 /* 177 /*
162 * check if the sharing is still fine!! -zecke 178 * check if the sharing is still fine!! -zecke
163 */ 179 */
164 /** 180 /**
165 * return a reference to our notifiers... 181 * return a reference to our notifiers...
166 */ 182 */
167 OPimNotifyManager &notifiers(); 183 OPimNotifyManager &notifiers();
168 184
169 /** 185 /**
170 * reimplementations 186 * reimplementations
171 */ 187 */
172 QString type()const; 188 QString type()const;
173 QString toShortText()const; 189 QString toShortText()const;
174 QMap<QString, QString> toExtraMap()const; 190 QMap<QString, QString> toExtraMap()const;
175 QString recordField(int id )const; 191 QString recordField(int id )const;
176 192