summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodo.cpp81
-rw-r--r--libopie/pim/otodo.h16
2 files changed, 82 insertions, 15 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
@@ -20,28 +20,32 @@
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();
@@ -148,20 +152,42 @@ QDate 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}
@@ -198,21 +224,31 @@ void OTodo::setStartDate( const QDate& date ) {
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;
@@ -257,14 +293,20 @@ QString OTodo::toRichText() const
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() ){
@@ -402,18 +444,27 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
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;
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
@@ -125,22 +125,37 @@ public:
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
@@ -155,12 +170,13 @@ public:
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 */