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
@@ -1,424 +1,475 @@
1 1
2#include <qobject.h> 2#include <qobject.h>
3#include <qshared.h> 3#include <qshared.h>
4 4
5 5
6 6
7#include <qpe/palmtopuidgen.h> 7#include <qpe/palmtopuidgen.h>
8#include <qpe/stringutil.h> 8#include <qpe/stringutil.h>
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
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 }
58} 62}
59OTodo::OTodo(bool completed, int priority, 63OTodo::OTodo(bool completed, int priority,
60 const QArray<int> &category, 64 const QArray<int> &category,
61 const QString& summary, 65 const QString& summary,
62 const QString &description, 66 const QString &description,
63 ushort progress, 67 ushort progress,
64 bool hasDate, QDate date, int uid ) 68 bool hasDate, QDate date, int uid )
65 : OPimRecord( uid ) 69 : OPimRecord( uid )
66{ 70{
67// qWarning("OTodoData " + summary); 71// qWarning("OTodoData " + summary);
68 setCategories( category ); 72 setCategories( category );
69 73
70 data = new OTodoData; 74 data = new OTodoData;
71 75
72 data->date = date; 76 data->date = date;
73 data->isCompleted = completed; 77 data->isCompleted = completed;
74 data->hasDate = hasDate; 78 data->hasDate = hasDate;
75 data->priority = priority; 79 data->priority = priority;
76 data->sum = summary; 80 data->sum = summary;
77 data->prog = progress; 81 data->prog = progress;
78 data->desc = Qtopia::simplifyMultiLineSpace(description ); 82 data->desc = Qtopia::simplifyMultiLineSpace(description );
79} 83}
80OTodo::OTodo(bool completed, int priority, 84OTodo::OTodo(bool completed, int priority,
81 const QStringList &category, 85 const QStringList &category,
82 const QString& summary, 86 const QString& summary,
83 const QString &description, 87 const QString &description,
84 ushort progress, 88 ushort progress,
85 bool hasDate, QDate date, int uid ) 89 bool hasDate, QDate date, int uid )
86 : OPimRecord( uid ) 90 : OPimRecord( uid )
87{ 91{
88// qWarning("OTodoData" + summary); 92// qWarning("OTodoData" + summary);
89 setCategories( idsFromString( category.join(";") ) ); 93 setCategories( idsFromString( category.join(";") ) );
90 94
91 data = new OTodoData; 95 data = new OTodoData;
92 96
93 data->date = date; 97 data->date = date;
94 data->isCompleted = completed; 98 data->isCompleted = completed;
95 data->hasDate = hasDate; 99 data->hasDate = hasDate;
96 data->priority = priority; 100 data->priority = priority;
97 data->sum = summary; 101 data->sum = summary;
98 data->prog = progress; 102 data->prog = progress;
99 data->desc = Qtopia::simplifyMultiLineSpace(description ); 103 data->desc = Qtopia::simplifyMultiLineSpace(description );
100} 104}
101bool OTodo::match( const QRegExp &regExp )const 105bool OTodo::match( const QRegExp &regExp )const
102{ 106{
103 if( QString::number( data->priority ).find( regExp ) != -1 ){ 107 if( QString::number( data->priority ).find( regExp ) != -1 ){
104 return true; 108 return true;
105 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 109 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
106 return true; 110 return true;
107 }else if(data->desc.find( regExp ) != -1 ){ 111 }else if(data->desc.find( regExp ) != -1 ){
108 return true; 112 return true;
109 }else if(data->sum.find( regExp ) != -1 ) { 113 }else if(data->sum.find( regExp ) != -1 ) {
110 return true; 114 return true;
111 } 115 }
112 return false; 116 return false;
113} 117}
114bool OTodo::isCompleted() const 118bool OTodo::isCompleted() const
115{ 119{
116 return data->isCompleted; 120 return data->isCompleted;
117} 121}
118bool OTodo::hasDueDate() const 122bool OTodo::hasDueDate() const
119{ 123{
120 return data->hasDate; 124 return data->hasDate;
121} 125}
122bool OTodo::hasStartDate()const { 126bool OTodo::hasStartDate()const {
123 return data->start.isValid(); 127 return data->start.isValid();
124} 128}
125bool OTodo::hasCompletedDate()const { 129bool OTodo::hasCompletedDate()const {
126 return data->completed.isValid(); 130 return data->completed.isValid();
127} 131}
128int OTodo::priority()const 132int OTodo::priority()const
129{ 133{
130 return data->priority; 134 return data->priority;
131} 135}
132QString OTodo::summary() const 136QString OTodo::summary() const
133{ 137{
134 return data->sum; 138 return data->sum;
135} 139}
136ushort OTodo::progress() const 140ushort OTodo::progress() const
137{ 141{
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 );
178} 204}
179void OTodo::setSummary( const QString& sum ) 205void OTodo::setSummary( const QString& sum )
180{ 206{
181 changeOrModify(); 207 changeOrModify();
182 data->sum = sum; 208 data->sum = sum;
183} 209}
184void OTodo::setPriority(int prio ) 210void OTodo::setPriority(int prio )
185{ 211{
186 changeOrModify(); 212 changeOrModify();
187 data->priority = prio; 213 data->priority = 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/*!
229 Returns a richt text string 265 Returns a richt text string
230*/ 266*/
231QString OTodo::toRichText() const 267QString OTodo::toRichText() const
232{ 268{
233 QString text; 269 QString text;
234 QStringList catlist; 270 QStringList catlist;
235 271
236 // Description of the todo 272 // Description of the todo
237 if ( !summary().isEmpty() ) { 273 if ( !summary().isEmpty() ) {
238 text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; 274 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
239 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 275 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
240 } 276 }
241 if( !description().isEmpty() ){ 277 if( !description().isEmpty() ){
242 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 278 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
243 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 279 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
244 } 280 }
245 text += "<br><br><br>"; 281 text += "<br><br><br>";
246 282
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{
281 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 323 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
282 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 324 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
283 if( hasDueDate() && toDoEvent.hasDueDate() ){ 325 if( hasDueDate() && toDoEvent.hasDueDate() ){
284 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 326 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
285 return priority() <= toDoEvent.priority(); 327 return priority() <= toDoEvent.priority();
286 }else{ 328 }else{
287 return dueDate() <= toDoEvent.dueDate(); 329 return dueDate() <= toDoEvent.dueDate();
288 } 330 }
289 } 331 }
290 return true; 332 return true;
291} 333}
292bool OTodo::operator>(const OTodo &toDoEvent )const 334bool OTodo::operator>(const OTodo &toDoEvent )const
293{ 335{
294 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 336 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
295 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 337 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
296 if( hasDueDate() && toDoEvent.hasDueDate() ){ 338 if( hasDueDate() && toDoEvent.hasDueDate() ){
297 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 339 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
298 return priority() > toDoEvent.priority(); 340 return priority() > toDoEvent.priority();
299 }else{ 341 }else{
300 return dueDate() > toDoEvent.dueDate(); 342 return dueDate() > toDoEvent.dueDate();
301 } 343 }
302 } 344 }
303 return false; 345 return false;
304} 346}
305bool OTodo::operator>=(const OTodo &toDoEvent )const 347bool OTodo::operator>=(const OTodo &toDoEvent )const
306{ 348{
307 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 349 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
308 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 350 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
309 if( hasDueDate() && toDoEvent.hasDueDate() ){ 351 if( hasDueDate() && toDoEvent.hasDueDate() ){
310 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 352 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
311 return priority() > toDoEvent.priority(); 353 return priority() > toDoEvent.priority();
312 }else{ 354 }else{
313 return dueDate() > toDoEvent.dueDate(); 355 return dueDate() > toDoEvent.dueDate();
314 } 356 }
315 } 357 }
316 return true; 358 return true;
317} 359}
318bool OTodo::operator==(const OTodo &toDoEvent )const 360bool OTodo::operator==(const OTodo &toDoEvent )const
319{ 361{
320 if ( data->priority != toDoEvent.data->priority ) return false; 362 if ( data->priority != toDoEvent.data->priority ) return false;
321 if ( data->priority != toDoEvent.data->prog ) return false; 363 if ( data->priority != toDoEvent.data->prog ) return false;
322 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 364 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
323 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 365 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
324 if ( data->date != toDoEvent.data->date ) return false; 366 if ( data->date != toDoEvent.data->date ) return false;
325 if ( data->sum != toDoEvent.data->sum ) return false; 367 if ( data->sum != toDoEvent.data->sum ) return false;
326 if ( data->desc != toDoEvent.data->desc ) return false; 368 if ( data->desc != toDoEvent.data->desc ) return false;
327 if ( data->maintainer != toDoEvent.data->maintainer ) 369 if ( data->maintainer != toDoEvent.data->maintainer )
328 return false; 370 return false;
329 371
330 return OPimRecord::operator==( toDoEvent ); 372 return OPimRecord::operator==( toDoEvent );
331} 373}
332void OTodo::deref() { 374void OTodo::deref() {
333 375
334// qWarning("deref in ToDoEvent"); 376// qWarning("deref in ToDoEvent");
335 if ( data->deref() ) { 377 if ( data->deref() ) {
336// qWarning("deleting"); 378// qWarning("deleting");
337 delete data; 379 delete data;
338 data= 0; 380 data= 0;
339 } 381 }
340} 382}
341OTodo &OTodo::operator=(const OTodo &item ) 383OTodo &OTodo::operator=(const OTodo &item )
342{ 384{
343 if ( this == &item ) return *this; 385 if ( this == &item ) return *this;
344 386
345 OPimRecord::operator=( item ); 387 OPimRecord::operator=( item );
346 //qWarning("operator= ref "); 388 //qWarning("operator= ref ");
347 item.data->ref(); 389 item.data->ref();
348 deref(); 390 deref();
349 data = item.data; 391 data = item.data;
350 392
351 return *this; 393 return *this;
352} 394}
353 395
354QMap<int, QString> OTodo::toMap() const { 396QMap<int, QString> OTodo::toMap() const {
355 QMap<int, QString> map; 397 QMap<int, QString> map;
356 398
357 map.insert( Uid, QString::number( uid() ) ); 399 map.insert( Uid, QString::number( uid() ) );
358 map.insert( Category, idsToString( categories() ) ); 400 map.insert( Category, idsToString( categories() ) );
359 map.insert( HasDate, QString::number( data->hasDate ) ); 401 map.insert( HasDate, QString::number( data->hasDate ) );
360 map.insert( Completed, QString::number( data->isCompleted ) ); 402 map.insert( Completed, QString::number( data->isCompleted ) );
361 map.insert( Description, data->desc ); 403 map.insert( Description, data->desc );
362 map.insert( Summary, data->sum ); 404 map.insert( Summary, data->sum );
363 map.insert( Priority, QString::number( data->priority ) ); 405 map.insert( Priority, QString::number( data->priority ) );
364 map.insert( DateDay, QString::number( data->date.day() ) ); 406 map.insert( DateDay, QString::number( data->date.day() ) );
365 map.insert( DateMonth, QString::number( data->date.month() ) ); 407 map.insert( DateMonth, QString::number( data->date.month() ) );
366 map.insert( DateYear, QString::number( data->date.year() ) ); 408 map.insert( DateYear, QString::number( data->date.year() ) );
367 map.insert( Progress, QString::number( data->prog ) ); 409 map.insert( Progress, QString::number( data->prog ) );
368// map.insert( CrossReference, crossToString() ); 410// map.insert( CrossReference, crossToString() );
369 /* FIXME!!! map.insert( State, ); 411 /* FIXME!!! map.insert( State, );
370 map.insert( Recurrence, ); 412 map.insert( Recurrence, );
371 map.insert( Reminders, ); 413 map.insert( Reminders, );
372 map. 414 map.
373 */ 415 */
374 return map; 416 return map;
375} 417}
376 418
377QMap<QString, QString> OTodo::toExtraMap()const { 419QMap<QString, QString> OTodo::toExtraMap()const {
378 return data->extra; 420 return data->extra;
379} 421}
380/** 422/**
381 * change or modify looks at the ref count and either 423 * change or modify looks at the ref count and either
382 * creates a new QShared Object or it can modify it 424 * creates a new QShared Object or it can modify it
383 * right in place 425 * right in place
384 */ 426 */
385void OTodo::changeOrModify() { 427void OTodo::changeOrModify() {
386 if ( data->count != 1 ) { 428 if ( data->count != 1 ) {
387 qWarning("changeOrModify"); 429 qWarning("changeOrModify");
388 data->deref(); 430 data->deref();
389 OTodoData* d2 = new OTodoData(); 431 OTodoData* d2 = new OTodoData();
390 copy(data, d2 ); 432 copy(data, d2 );
391 data = d2; 433 data = d2;
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
@@ -1,273 +1,289 @@
1 1
2#ifndef OPIE_TODO_EVENT_H 2#ifndef OPIE_TODO_EVENT_H
3#define OPIE_TODO_EVENT_H 3#define OPIE_TODO_EVENT_H
4 4
5 5
6#include <qarray.h> 6#include <qarray.h>
7#include <qmap.h> 7#include <qmap.h>
8#include <qregexp.h> 8#include <qregexp.h>
9#include <qstringlist.h> 9#include <qstringlist.h>
10#include <qdatetime.h> 10#include <qdatetime.h>
11#include <qvaluelist.h> 11#include <qvaluelist.h>
12 12
13#include <qpe/recordfields.h> 13#include <qpe/recordfields.h>
14#include <qpe/palmtopuidgen.h> 14#include <qpe/palmtopuidgen.h>
15 15
16#include <opie/opimrecord.h> 16#include <opie/opimrecord.h>
17 17
18 18
19class OPimState; 19class OPimState;
20class ORecur; 20class ORecur;
21class OPimMaintainer; 21class OPimMaintainer;
22class OPimNotifyManager; 22class OPimNotifyManager;
23class OTodo : public OPimRecord { 23class OTodo : public OPimRecord {
24public: 24public:
25 typedef QValueList<OTodo> ValueList; 25 typedef QValueList<OTodo> ValueList;
26 enum RecordFields { 26 enum RecordFields {
27 Uid = Qtopia::UID_ID, 27 Uid = Qtopia::UID_ID,
28 Category = Qtopia::CATEGORY_ID, 28 Category = Qtopia::CATEGORY_ID,
29 HasDate, 29 HasDate,
30 Completed, 30 Completed,
31 Description, 31 Description,
32 Summary, 32 Summary,
33 Priority, 33 Priority,
34 DateDay, 34 DateDay,
35 DateMonth, 35 DateMonth,
36 DateYear, 36 DateYear,
37 Progress, 37 Progress,
38 CrossReference, 38 CrossReference,
39 State, 39 State,
40 Recurrence, 40 Recurrence,
41 Alarms, 41 Alarms,
42 Reminders, 42 Reminders,
43 Notifiers, 43 Notifiers,
44 Maintainer, 44 Maintainer,
45 StartDate, 45 StartDate,
46 CompletedDate 46 CompletedDate
47 }; 47 };
48 public: 48 public:
49 // priorities from Very low to very high 49 // priorities from Very low to very high
50 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; 50 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
51 51
52 /* Constructs a new ToDoEvent 52 /* Constructs a new ToDoEvent
53 @param completed Is the TodoEvent completed 53 @param completed Is the TodoEvent completed
54 @param priority What is the priority of this ToDoEvent 54 @param priority What is the priority of this ToDoEvent
55 @param category Which category does it belong( uid ) 55 @param category Which category does it belong( uid )
56 @param summary A small summary of the todo 56 @param summary A small summary of the todo
57 @param description What is this ToDoEvent about 57 @param description What is this ToDoEvent about
58 @param hasDate Does this Event got a deadline 58 @param hasDate Does this Event got a deadline
59 @param date what is the deadline? 59 @param date what is the deadline?
60 @param uid what is the UUID of this Event 60 @param uid what is the UUID of this Event
61 **/ 61 **/
62 OTodo( bool completed = false, int priority = Normal, 62 OTodo( bool completed = false, int priority = Normal,
63 const QStringList &category = QStringList(), 63 const QStringList &category = QStringList(),
64 const QString &summary = QString::null , 64 const QString &summary = QString::null ,
65 const QString &description = QString::null, 65 const QString &description = QString::null,
66 ushort progress = 0, 66 ushort progress = 0,
67 bool hasDate = false, QDate date = QDate::currentDate(), 67 bool hasDate = false, QDate date = QDate::currentDate(),
68 int uid = 0 /*empty*/ ); 68 int uid = 0 /*empty*/ );
69 69
70 OTodo( bool completed, int priority, 70 OTodo( bool completed, int priority,
71 const QArray<int>& category, 71 const QArray<int>& category,
72 const QString& summary = QString::null, 72 const QString& summary = QString::null,
73 const QString& description = QString::null, 73 const QString& description = QString::null,
74 ushort progress = 0, 74 ushort progress = 0,
75 bool hasDate = false, QDate date = QDate::currentDate(), 75 bool hasDate = false, QDate date = QDate::currentDate(),
76 int uid = 0 /* empty */ ); 76 int uid = 0 /* empty */ );
77 77
78 /** Copy c'tor 78 /** Copy c'tor
79 * 79 *
80 */ 80 */
81 OTodo(const OTodo & ); 81 OTodo(const OTodo & );
82 82
83 /** 83 /**
84 *destructor 84 *destructor
85 */ 85 */
86 ~OTodo(); 86 ~OTodo();
87 87
88 /** 88 /**
89 * Is this event completed? 89 * Is this event completed?
90 */ 90 */
91 bool isCompleted() const; 91 bool isCompleted() const;
92 92
93 /** 93 /**
94 * Does this Event have a deadline 94 * Does this Event have a deadline
95 */ 95 */
96 bool hasDueDate() const; 96 bool hasDueDate() const;
97 bool hasStartDate()const; 97 bool hasStartDate()const;
98 bool hasCompletedDate()const; 98 bool hasCompletedDate()const;
99 99
100 /** 100 /**
101 * Does this Event has an alarm time ? 101 * Does this Event has an alarm time ?
102 */ 102 */
103 bool hasAlarmDateTime() const; 103 bool hasAlarmDateTime() const;
104 104
105 /** 105 /**
106 * What is the priority? 106 * What is the priority?
107 */ 107 */
108 int priority()const ; 108 int priority()const ;
109 109
110 /** 110 /**
111 * progress as ushort 0, 20, 40, 60, 80 or 100% 111 * progress as ushort 0, 20, 40, 60, 80 or 100%
112 */ 112 */
113 ushort progress() const; 113 ushort progress() const;
114 114
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
177 /** 193 /**
178 * toMap puts all data into the map. int relates 194 * toMap puts all data into the map. int relates
179 * to ToDoEvent RecordFields enum 195 * to ToDoEvent RecordFields enum
180 */ 196 */
181 QMap<int, QString> toMap()const; 197 QMap<int, QString> toMap()const;
182 198
183 /** 199 /**
184 * Set if this Todo is completed 200 * Set if this Todo is completed
185 */ 201 */
186 void setCompleted(bool completed ); 202 void setCompleted(bool completed );
187 203
188 /** 204 /**
189 * set if this todo got an end data 205 * set if this todo got an end data
190 */ 206 */
191 void setHasDueDate( bool hasDate ); 207 void setHasDueDate( bool hasDate );
192 // FIXME we do not have these for start, completed 208 // FIXME we do not have these for start, completed
193 // cause we'll use the isNull() of QDate for figuring 209 // cause we'll use the isNull() of QDate for figuring
194 // out if it's has a date... 210 // out if it's has a date...
195 // decide what to do here? -zecke 211 // decide what to do here? -zecke
196 212
197 /** 213 /**
198 * Set the priority of the Todo 214 * Set the priority of the Todo
199 */ 215 */
200 void setPriority(int priority ); 216 void setPriority(int priority );
201 217
202 /** 218 /**
203 * Set the progress. 219 * Set the progress.
204 */ 220 */
205 void setProgress( ushort progress ); 221 void setProgress( ushort progress );
206 222
207 /** 223 /**
208 * set the end date 224 * set the end date
209 */ 225 */
210 void setDueDate( const QDate& date ); 226 void setDueDate( const QDate& date );
211 227
212 /** 228 /**
213 * set the start date 229 * set the start date
214 */ 230 */
215 void setStartDate( const QDate& date ); 231 void setStartDate( const QDate& date );
216 232
217 /** 233 /**
218 * set the completed date 234 * set the completed date
219 */ 235 */
220 void setCompletedDate( const QDate& date ); 236 void setCompletedDate( const QDate& date );
221 237
222 void setRecurrence( const ORecur& ); 238 void setRecurrence( const ORecur& );
223 /** 239 /**
224 * set the alarm time 240 * set the alarm time
225 */ 241 */
226 void setAlarmDateTime ( const QDateTime& alarm ); 242 void setAlarmDateTime ( const QDateTime& alarm );
227 243
228 void setDescription(const QString& ); 244 void setDescription(const QString& );
229 void setSummary(const QString& ); 245 void setSummary(const QString& );
230 246
231 /** 247 /**
232 * set the state of a Todo 248 * set the state of a Todo
233 * @param state State what the todo should take 249 * @param state State what the todo should take
234 */ 250 */
235 void setState( const OPimState& state); 251 void setState( const OPimState& state);
236 252
237 /** 253 /**
238 * set the Maintainer Mode 254 * set the Maintainer Mode
239 */ 255 */
240 void setMaintainer( const OPimMaintainer& ); 256 void setMaintainer( const OPimMaintainer& );
241 257
242 bool isOverdue(); 258 bool isOverdue();
243 259
244 260
245 bool match( const QRegExp &r )const; 261 bool match( const QRegExp &r )const;
246 262
247 bool operator<(const OTodo &toDoEvent )const; 263 bool operator<(const OTodo &toDoEvent )const;
248 bool operator<=(const OTodo &toDoEvent )const; 264 bool operator<=(const OTodo &toDoEvent )const;
249 bool operator!=(const OTodo &toDoEvent )const; 265 bool operator!=(const OTodo &toDoEvent )const;
250 bool operator>(const OTodo &toDoEvent )const; 266 bool operator>(const OTodo &toDoEvent )const;
251 bool operator>=(const OTodo &toDoEvent)const; 267 bool operator>=(const OTodo &toDoEvent)const;
252 bool operator==(const OTodo &toDoEvent )const; 268 bool operator==(const OTodo &toDoEvent )const;
253 OTodo &operator=(const OTodo &toDoEvent ); 269 OTodo &operator=(const OTodo &toDoEvent );
254 270
255 static int rtti(); 271 static int rtti();
256 272
257 private: 273 private:
258 class OTodoPrivate; 274 class OTodoPrivate;
259 struct OTodoData; 275 struct OTodoData;
260 276
261 void deref(); 277 void deref();
262 inline void changeOrModify(); 278 inline void changeOrModify();
263 void copy( OTodoData* src, OTodoData* dest ); 279 void copy( OTodoData* src, OTodoData* dest );
264 OTodoPrivate *d; 280 OTodoPrivate *d;
265 OTodoData *data; 281 OTodoData *data;
266 282
267}; 283};
268inline bool OTodo::operator!=(const OTodo &toDoEvent )const { 284inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
269 return !(*this == toDoEvent); 285 return !(*this == toDoEvent);
270} 286}
271 287
272 288
273#endif 289#endif
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
@@ -1,424 +1,475 @@
1 1
2#include <qobject.h> 2#include <qobject.h>
3#include <qshared.h> 3#include <qshared.h>
4 4
5 5
6 6
7#include <qpe/palmtopuidgen.h> 7#include <qpe/palmtopuidgen.h>
8#include <qpe/stringutil.h> 8#include <qpe/stringutil.h>
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
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 }
58} 62}
59OTodo::OTodo(bool completed, int priority, 63OTodo::OTodo(bool completed, int priority,
60 const QArray<int> &category, 64 const QArray<int> &category,
61 const QString& summary, 65 const QString& summary,
62 const QString &description, 66 const QString &description,
63 ushort progress, 67 ushort progress,
64 bool hasDate, QDate date, int uid ) 68 bool hasDate, QDate date, int uid )
65 : OPimRecord( uid ) 69 : OPimRecord( uid )
66{ 70{
67// qWarning("OTodoData " + summary); 71// qWarning("OTodoData " + summary);
68 setCategories( category ); 72 setCategories( category );
69 73
70 data = new OTodoData; 74 data = new OTodoData;
71 75
72 data->date = date; 76 data->date = date;
73 data->isCompleted = completed; 77 data->isCompleted = completed;
74 data->hasDate = hasDate; 78 data->hasDate = hasDate;
75 data->priority = priority; 79 data->priority = priority;
76 data->sum = summary; 80 data->sum = summary;
77 data->prog = progress; 81 data->prog = progress;
78 data->desc = Qtopia::simplifyMultiLineSpace(description ); 82 data->desc = Qtopia::simplifyMultiLineSpace(description );
79} 83}
80OTodo::OTodo(bool completed, int priority, 84OTodo::OTodo(bool completed, int priority,
81 const QStringList &category, 85 const QStringList &category,
82 const QString& summary, 86 const QString& summary,
83 const QString &description, 87 const QString &description,
84 ushort progress, 88 ushort progress,
85 bool hasDate, QDate date, int uid ) 89 bool hasDate, QDate date, int uid )
86 : OPimRecord( uid ) 90 : OPimRecord( uid )
87{ 91{
88// qWarning("OTodoData" + summary); 92// qWarning("OTodoData" + summary);
89 setCategories( idsFromString( category.join(";") ) ); 93 setCategories( idsFromString( category.join(";") ) );
90 94
91 data = new OTodoData; 95 data = new OTodoData;
92 96
93 data->date = date; 97 data->date = date;
94 data->isCompleted = completed; 98 data->isCompleted = completed;
95 data->hasDate = hasDate; 99 data->hasDate = hasDate;
96 data->priority = priority; 100 data->priority = priority;
97 data->sum = summary; 101 data->sum = summary;
98 data->prog = progress; 102 data->prog = progress;
99 data->desc = Qtopia::simplifyMultiLineSpace(description ); 103 data->desc = Qtopia::simplifyMultiLineSpace(description );
100} 104}
101bool OTodo::match( const QRegExp &regExp )const 105bool OTodo::match( const QRegExp &regExp )const
102{ 106{
103 if( QString::number( data->priority ).find( regExp ) != -1 ){ 107 if( QString::number( data->priority ).find( regExp ) != -1 ){
104 return true; 108 return true;
105 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 109 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
106 return true; 110 return true;
107 }else if(data->desc.find( regExp ) != -1 ){ 111 }else if(data->desc.find( regExp ) != -1 ){
108 return true; 112 return true;
109 }else if(data->sum.find( regExp ) != -1 ) { 113 }else if(data->sum.find( regExp ) != -1 ) {
110 return true; 114 return true;
111 } 115 }
112 return false; 116 return false;
113} 117}
114bool OTodo::isCompleted() const 118bool OTodo::isCompleted() const
115{ 119{
116 return data->isCompleted; 120 return data->isCompleted;
117} 121}
118bool OTodo::hasDueDate() const 122bool OTodo::hasDueDate() const
119{ 123{
120 return data->hasDate; 124 return data->hasDate;
121} 125}
122bool OTodo::hasStartDate()const { 126bool OTodo::hasStartDate()const {
123 return data->start.isValid(); 127 return data->start.isValid();
124} 128}
125bool OTodo::hasCompletedDate()const { 129bool OTodo::hasCompletedDate()const {
126 return data->completed.isValid(); 130 return data->completed.isValid();
127} 131}
128int OTodo::priority()const 132int OTodo::priority()const
129{ 133{
130 return data->priority; 134 return data->priority;
131} 135}
132QString OTodo::summary() const 136QString OTodo::summary() const
133{ 137{
134 return data->sum; 138 return data->sum;
135} 139}
136ushort OTodo::progress() const 140ushort OTodo::progress() const
137{ 141{
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 );
178} 204}
179void OTodo::setSummary( const QString& sum ) 205void OTodo::setSummary( const QString& sum )
180{ 206{
181 changeOrModify(); 207 changeOrModify();
182 data->sum = sum; 208 data->sum = sum;
183} 209}
184void OTodo::setPriority(int prio ) 210void OTodo::setPriority(int prio )
185{ 211{
186 changeOrModify(); 212 changeOrModify();
187 data->priority = prio; 213 data->priority = 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/*!
229 Returns a richt text string 265 Returns a richt text string
230*/ 266*/
231QString OTodo::toRichText() const 267QString OTodo::toRichText() const
232{ 268{
233 QString text; 269 QString text;
234 QStringList catlist; 270 QStringList catlist;
235 271
236 // Description of the todo 272 // Description of the todo
237 if ( !summary().isEmpty() ) { 273 if ( !summary().isEmpty() ) {
238 text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; 274 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
239 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 275 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
240 } 276 }
241 if( !description().isEmpty() ){ 277 if( !description().isEmpty() ){
242 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 278 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
243 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 279 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
244 } 280 }
245 text += "<br><br><br>"; 281 text += "<br><br><br>";
246 282
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{
281 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 323 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
282 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 324 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
283 if( hasDueDate() && toDoEvent.hasDueDate() ){ 325 if( hasDueDate() && toDoEvent.hasDueDate() ){
284 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 326 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
285 return priority() <= toDoEvent.priority(); 327 return priority() <= toDoEvent.priority();
286 }else{ 328 }else{
287 return dueDate() <= toDoEvent.dueDate(); 329 return dueDate() <= toDoEvent.dueDate();
288 } 330 }
289 } 331 }
290 return true; 332 return true;
291} 333}
292bool OTodo::operator>(const OTodo &toDoEvent )const 334bool OTodo::operator>(const OTodo &toDoEvent )const
293{ 335{
294 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 336 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
295 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 337 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
296 if( hasDueDate() && toDoEvent.hasDueDate() ){ 338 if( hasDueDate() && toDoEvent.hasDueDate() ){
297 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 339 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
298 return priority() > toDoEvent.priority(); 340 return priority() > toDoEvent.priority();
299 }else{ 341 }else{
300 return dueDate() > toDoEvent.dueDate(); 342 return dueDate() > toDoEvent.dueDate();
301 } 343 }
302 } 344 }
303 return false; 345 return false;
304} 346}
305bool OTodo::operator>=(const OTodo &toDoEvent )const 347bool OTodo::operator>=(const OTodo &toDoEvent )const
306{ 348{
307 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 349 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
308 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 350 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
309 if( hasDueDate() && toDoEvent.hasDueDate() ){ 351 if( hasDueDate() && toDoEvent.hasDueDate() ){
310 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 352 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
311 return priority() > toDoEvent.priority(); 353 return priority() > toDoEvent.priority();
312 }else{ 354 }else{
313 return dueDate() > toDoEvent.dueDate(); 355 return dueDate() > toDoEvent.dueDate();
314 } 356 }
315 } 357 }
316 return true; 358 return true;
317} 359}
318bool OTodo::operator==(const OTodo &toDoEvent )const 360bool OTodo::operator==(const OTodo &toDoEvent )const
319{ 361{
320 if ( data->priority != toDoEvent.data->priority ) return false; 362 if ( data->priority != toDoEvent.data->priority ) return false;
321 if ( data->priority != toDoEvent.data->prog ) return false; 363 if ( data->priority != toDoEvent.data->prog ) return false;
322 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 364 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
323 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 365 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
324 if ( data->date != toDoEvent.data->date ) return false; 366 if ( data->date != toDoEvent.data->date ) return false;
325 if ( data->sum != toDoEvent.data->sum ) return false; 367 if ( data->sum != toDoEvent.data->sum ) return false;
326 if ( data->desc != toDoEvent.data->desc ) return false; 368 if ( data->desc != toDoEvent.data->desc ) return false;
327 if ( data->maintainer != toDoEvent.data->maintainer ) 369 if ( data->maintainer != toDoEvent.data->maintainer )
328 return false; 370 return false;
329 371
330 return OPimRecord::operator==( toDoEvent ); 372 return OPimRecord::operator==( toDoEvent );
331} 373}
332void OTodo::deref() { 374void OTodo::deref() {
333 375
334// qWarning("deref in ToDoEvent"); 376// qWarning("deref in ToDoEvent");
335 if ( data->deref() ) { 377 if ( data->deref() ) {
336// qWarning("deleting"); 378// qWarning("deleting");
337 delete data; 379 delete data;
338 data= 0; 380 data= 0;
339 } 381 }
340} 382}
341OTodo &OTodo::operator=(const OTodo &item ) 383OTodo &OTodo::operator=(const OTodo &item )
342{ 384{
343 if ( this == &item ) return *this; 385 if ( this == &item ) return *this;
344 386
345 OPimRecord::operator=( item ); 387 OPimRecord::operator=( item );
346 //qWarning("operator= ref "); 388 //qWarning("operator= ref ");
347 item.data->ref(); 389 item.data->ref();
348 deref(); 390 deref();
349 data = item.data; 391 data = item.data;
350 392
351 return *this; 393 return *this;
352} 394}
353 395
354QMap<int, QString> OTodo::toMap() const { 396QMap<int, QString> OTodo::toMap() const {
355 QMap<int, QString> map; 397 QMap<int, QString> map;
356 398
357 map.insert( Uid, QString::number( uid() ) ); 399 map.insert( Uid, QString::number( uid() ) );
358 map.insert( Category, idsToString( categories() ) ); 400 map.insert( Category, idsToString( categories() ) );
359 map.insert( HasDate, QString::number( data->hasDate ) ); 401 map.insert( HasDate, QString::number( data->hasDate ) );
360 map.insert( Completed, QString::number( data->isCompleted ) ); 402 map.insert( Completed, QString::number( data->isCompleted ) );
361 map.insert( Description, data->desc ); 403 map.insert( Description, data->desc );
362 map.insert( Summary, data->sum ); 404 map.insert( Summary, data->sum );
363 map.insert( Priority, QString::number( data->priority ) ); 405 map.insert( Priority, QString::number( data->priority ) );
364 map.insert( DateDay, QString::number( data->date.day() ) ); 406 map.insert( DateDay, QString::number( data->date.day() ) );
365 map.insert( DateMonth, QString::number( data->date.month() ) ); 407 map.insert( DateMonth, QString::number( data->date.month() ) );
366 map.insert( DateYear, QString::number( data->date.year() ) ); 408 map.insert( DateYear, QString::number( data->date.year() ) );
367 map.insert( Progress, QString::number( data->prog ) ); 409 map.insert( Progress, QString::number( data->prog ) );
368// map.insert( CrossReference, crossToString() ); 410// map.insert( CrossReference, crossToString() );
369 /* FIXME!!! map.insert( State, ); 411 /* FIXME!!! map.insert( State, );
370 map.insert( Recurrence, ); 412 map.insert( Recurrence, );
371 map.insert( Reminders, ); 413 map.insert( Reminders, );
372 map. 414 map.
373 */ 415 */
374 return map; 416 return map;
375} 417}
376 418
377QMap<QString, QString> OTodo::toExtraMap()const { 419QMap<QString, QString> OTodo::toExtraMap()const {
378 return data->extra; 420 return data->extra;
379} 421}
380/** 422/**
381 * change or modify looks at the ref count and either 423 * change or modify looks at the ref count and either
382 * creates a new QShared Object or it can modify it 424 * creates a new QShared Object or it can modify it
383 * right in place 425 * right in place
384 */ 426 */
385void OTodo::changeOrModify() { 427void OTodo::changeOrModify() {
386 if ( data->count != 1 ) { 428 if ( data->count != 1 ) {
387 qWarning("changeOrModify"); 429 qWarning("changeOrModify");
388 data->deref(); 430 data->deref();
389 OTodoData* d2 = new OTodoData(); 431 OTodoData* d2 = new OTodoData();
390 copy(data, d2 ); 432 copy(data, d2 );
391 data = d2; 433 data = d2;
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
@@ -1,273 +1,289 @@
1 1
2#ifndef OPIE_TODO_EVENT_H 2#ifndef OPIE_TODO_EVENT_H
3#define OPIE_TODO_EVENT_H 3#define OPIE_TODO_EVENT_H
4 4
5 5
6#include <qarray.h> 6#include <qarray.h>
7#include <qmap.h> 7#include <qmap.h>
8#include <qregexp.h> 8#include <qregexp.h>
9#include <qstringlist.h> 9#include <qstringlist.h>
10#include <qdatetime.h> 10#include <qdatetime.h>
11#include <qvaluelist.h> 11#include <qvaluelist.h>
12 12
13#include <qpe/recordfields.h> 13#include <qpe/recordfields.h>
14#include <qpe/palmtopuidgen.h> 14#include <qpe/palmtopuidgen.h>
15 15
16#include <opie/opimrecord.h> 16#include <opie/opimrecord.h>
17 17
18 18
19class OPimState; 19class OPimState;
20class ORecur; 20class ORecur;
21class OPimMaintainer; 21class OPimMaintainer;
22class OPimNotifyManager; 22class OPimNotifyManager;
23class OTodo : public OPimRecord { 23class OTodo : public OPimRecord {
24public: 24public:
25 typedef QValueList<OTodo> ValueList; 25 typedef QValueList<OTodo> ValueList;
26 enum RecordFields { 26 enum RecordFields {
27 Uid = Qtopia::UID_ID, 27 Uid = Qtopia::UID_ID,
28 Category = Qtopia::CATEGORY_ID, 28 Category = Qtopia::CATEGORY_ID,
29 HasDate, 29 HasDate,
30 Completed, 30 Completed,
31 Description, 31 Description,
32 Summary, 32 Summary,
33 Priority, 33 Priority,
34 DateDay, 34 DateDay,
35 DateMonth, 35 DateMonth,
36 DateYear, 36 DateYear,
37 Progress, 37 Progress,
38 CrossReference, 38 CrossReference,
39 State, 39 State,
40 Recurrence, 40 Recurrence,
41 Alarms, 41 Alarms,
42 Reminders, 42 Reminders,
43 Notifiers, 43 Notifiers,
44 Maintainer, 44 Maintainer,
45 StartDate, 45 StartDate,
46 CompletedDate 46 CompletedDate
47 }; 47 };
48 public: 48 public:
49 // priorities from Very low to very high 49 // priorities from Very low to very high
50 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; 50 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
51 51
52 /* Constructs a new ToDoEvent 52 /* Constructs a new ToDoEvent
53 @param completed Is the TodoEvent completed 53 @param completed Is the TodoEvent completed
54 @param priority What is the priority of this ToDoEvent 54 @param priority What is the priority of this ToDoEvent
55 @param category Which category does it belong( uid ) 55 @param category Which category does it belong( uid )
56 @param summary A small summary of the todo 56 @param summary A small summary of the todo
57 @param description What is this ToDoEvent about 57 @param description What is this ToDoEvent about
58 @param hasDate Does this Event got a deadline 58 @param hasDate Does this Event got a deadline
59 @param date what is the deadline? 59 @param date what is the deadline?
60 @param uid what is the UUID of this Event 60 @param uid what is the UUID of this Event
61 **/ 61 **/
62 OTodo( bool completed = false, int priority = Normal, 62 OTodo( bool completed = false, int priority = Normal,
63 const QStringList &category = QStringList(), 63 const QStringList &category = QStringList(),
64 const QString &summary = QString::null , 64 const QString &summary = QString::null ,
65 const QString &description = QString::null, 65 const QString &description = QString::null,
66 ushort progress = 0, 66 ushort progress = 0,
67 bool hasDate = false, QDate date = QDate::currentDate(), 67 bool hasDate = false, QDate date = QDate::currentDate(),
68 int uid = 0 /*empty*/ ); 68 int uid = 0 /*empty*/ );
69 69
70 OTodo( bool completed, int priority, 70 OTodo( bool completed, int priority,
71 const QArray<int>& category, 71 const QArray<int>& category,
72 const QString& summary = QString::null, 72 const QString& summary = QString::null,
73 const QString& description = QString::null, 73 const QString& description = QString::null,
74 ushort progress = 0, 74 ushort progress = 0,
75 bool hasDate = false, QDate date = QDate::currentDate(), 75 bool hasDate = false, QDate date = QDate::currentDate(),
76 int uid = 0 /* empty */ ); 76 int uid = 0 /* empty */ );
77 77
78 /** Copy c'tor 78 /** Copy c'tor
79 * 79 *
80 */ 80 */
81 OTodo(const OTodo & ); 81 OTodo(const OTodo & );
82 82
83 /** 83 /**
84 *destructor 84 *destructor
85 */ 85 */
86 ~OTodo(); 86 ~OTodo();
87 87
88 /** 88 /**
89 * Is this event completed? 89 * Is this event completed?
90 */ 90 */
91 bool isCompleted() const; 91 bool isCompleted() const;
92 92
93 /** 93 /**
94 * Does this Event have a deadline 94 * Does this Event have a deadline
95 */ 95 */
96 bool hasDueDate() const; 96 bool hasDueDate() const;
97 bool hasStartDate()const; 97 bool hasStartDate()const;
98 bool hasCompletedDate()const; 98 bool hasCompletedDate()const;
99 99
100 /** 100 /**
101 * Does this Event has an alarm time ? 101 * Does this Event has an alarm time ?
102 */ 102 */
103 bool hasAlarmDateTime() const; 103 bool hasAlarmDateTime() const;
104 104
105 /** 105 /**
106 * What is the priority? 106 * What is the priority?
107 */ 107 */
108 int priority()const ; 108 int priority()const ;
109 109
110 /** 110 /**
111 * progress as ushort 0, 20, 40, 60, 80 or 100% 111 * progress as ushort 0, 20, 40, 60, 80 or 100%
112 */ 112 */
113 ushort progress() const; 113 ushort progress() const;
114 114
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
177 /** 193 /**
178 * toMap puts all data into the map. int relates 194 * toMap puts all data into the map. int relates
179 * to ToDoEvent RecordFields enum 195 * to ToDoEvent RecordFields enum
180 */ 196 */
181 QMap<int, QString> toMap()const; 197 QMap<int, QString> toMap()const;
182 198
183 /** 199 /**
184 * Set if this Todo is completed 200 * Set if this Todo is completed
185 */ 201 */
186 void setCompleted(bool completed ); 202 void setCompleted(bool completed );
187 203
188 /** 204 /**
189 * set if this todo got an end data 205 * set if this todo got an end data
190 */ 206 */
191 void setHasDueDate( bool hasDate ); 207 void setHasDueDate( bool hasDate );
192 // FIXME we do not have these for start, completed 208 // FIXME we do not have these for start, completed
193 // cause we'll use the isNull() of QDate for figuring 209 // cause we'll use the isNull() of QDate for figuring
194 // out if it's has a date... 210 // out if it's has a date...
195 // decide what to do here? -zecke 211 // decide what to do here? -zecke
196 212
197 /** 213 /**
198 * Set the priority of the Todo 214 * Set the priority of the Todo
199 */ 215 */
200 void setPriority(int priority ); 216 void setPriority(int priority );
201 217
202 /** 218 /**
203 * Set the progress. 219 * Set the progress.
204 */ 220 */
205 void setProgress( ushort progress ); 221 void setProgress( ushort progress );
206 222
207 /** 223 /**
208 * set the end date 224 * set the end date
209 */ 225 */
210 void setDueDate( const QDate& date ); 226 void setDueDate( const QDate& date );
211 227
212 /** 228 /**
213 * set the start date 229 * set the start date
214 */ 230 */
215 void setStartDate( const QDate& date ); 231 void setStartDate( const QDate& date );
216 232
217 /** 233 /**
218 * set the completed date 234 * set the completed date
219 */ 235 */
220 void setCompletedDate( const QDate& date ); 236 void setCompletedDate( const QDate& date );
221 237
222 void setRecurrence( const ORecur& ); 238 void setRecurrence( const ORecur& );
223 /** 239 /**
224 * set the alarm time 240 * set the alarm time
225 */ 241 */
226 void setAlarmDateTime ( const QDateTime& alarm ); 242 void setAlarmDateTime ( const QDateTime& alarm );
227 243
228 void setDescription(const QString& ); 244 void setDescription(const QString& );
229 void setSummary(const QString& ); 245 void setSummary(const QString& );
230 246
231 /** 247 /**
232 * set the state of a Todo 248 * set the state of a Todo
233 * @param state State what the todo should take 249 * @param state State what the todo should take
234 */ 250 */
235 void setState( const OPimState& state); 251 void setState( const OPimState& state);
236 252
237 /** 253 /**
238 * set the Maintainer Mode 254 * set the Maintainer Mode
239 */ 255 */
240 void setMaintainer( const OPimMaintainer& ); 256 void setMaintainer( const OPimMaintainer& );
241 257
242 bool isOverdue(); 258 bool isOverdue();
243 259
244 260
245 bool match( const QRegExp &r )const; 261 bool match( const QRegExp &r )const;
246 262
247 bool operator<(const OTodo &toDoEvent )const; 263 bool operator<(const OTodo &toDoEvent )const;
248 bool operator<=(const OTodo &toDoEvent )const; 264 bool operator<=(const OTodo &toDoEvent )const;
249 bool operator!=(const OTodo &toDoEvent )const; 265 bool operator!=(const OTodo &toDoEvent )const;
250 bool operator>(const OTodo &toDoEvent )const; 266 bool operator>(const OTodo &toDoEvent )const;
251 bool operator>=(const OTodo &toDoEvent)const; 267 bool operator>=(const OTodo &toDoEvent)const;
252 bool operator==(const OTodo &toDoEvent )const; 268 bool operator==(const OTodo &toDoEvent )const;
253 OTodo &operator=(const OTodo &toDoEvent ); 269 OTodo &operator=(const OTodo &toDoEvent );
254 270
255 static int rtti(); 271 static int rtti();
256 272
257 private: 273 private:
258 class OTodoPrivate; 274 class OTodoPrivate;
259 struct OTodoData; 275 struct OTodoData;
260 276
261 void deref(); 277 void deref();
262 inline void changeOrModify(); 278 inline void changeOrModify();
263 void copy( OTodoData* src, OTodoData* dest ); 279 void copy( OTodoData* src, OTodoData* dest );
264 OTodoPrivate *d; 280 OTodoPrivate *d;
265 OTodoData *data; 281 OTodoData *data;
266 282
267}; 283};
268inline bool OTodo::operator!=(const OTodo &toDoEvent )const { 284inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
269 return !(*this == toDoEvent); 285 return !(*this == toDoEvent);
270} 286}
271 287
272 288
273#endif 289#endif