summaryrefslogtreecommitdiff
path: root/libopie/pim/otodo.cpp
Unidiff
Diffstat (limited to 'libopie/pim/otodo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodo.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 38b93f7..5a18c37 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -1,78 +1,83 @@
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; 26 recur = 0;
27 state = 0; 27 state = 0;
28 maintainer = 0; 28 maintainer = 0;
29 notifiers = 0; 29 notifiers = 0;
30 }; 30 };
31 ~OTodoData() {
32 delete recur;
33 delete maintainer;
34 delete notifiers;
35 }
31 36
32 QDate date; 37 QDate date;
33 bool isCompleted:1; 38 bool isCompleted:1;
34 bool hasDate:1; 39 bool hasDate:1;
35 int priority; 40 int priority;
36 QString desc; 41 QString desc;
37 QString sum; 42 QString sum;
38 QMap<QString, QString> extra; 43 QMap<QString, QString> extra;
39 ushort prog; 44 ushort prog;
40 OPimState *state; 45 OPimState *state;
41 ORecur *recur; 46 ORecur *recur;
42 OPimMaintainer *maintainer; 47 OPimMaintainer *maintainer;
43 QDate start; 48 QDate start;
44 QDate completed; 49 QDate completed;
45 OPimNotifyManager *notifiers; 50 OPimNotifyManager *notifiers;
46}; 51};
47 52
48OTodo::OTodo(const OTodo &event ) 53OTodo::OTodo(const OTodo &event )
49 : OPimRecord( event ), data( event.data ) 54 : OPimRecord( event ), data( event.data )
50{ 55{
51 data->ref(); 56 data->ref();
52// qWarning("ref up"); 57// qWarning("ref up");
53} 58}
54OTodo::~OTodo() { 59OTodo::~OTodo() {
55 60
56// qWarning("~OTodo " ); 61// qWarning("~OTodo " );
57 if ( data->deref() ) { 62 if ( data->deref() ) {
58// qWarning("OTodo::dereffing"); 63// qWarning("OTodo::dereffing");
59 delete data; 64 delete data;
60 data = 0l; 65 data = 0l;
61 } 66 }
62} 67}
63OTodo::OTodo(bool completed, int priority, 68OTodo::OTodo(bool completed, int priority,
64 const QArray<int> &category, 69 const QArray<int> &category,
65 const QString& summary, 70 const QString& summary,
66 const QString &description, 71 const QString &description,
67 ushort progress, 72 ushort progress,
68 bool hasDate, QDate date, int uid ) 73 bool hasDate, QDate date, int uid )
69 : OPimRecord( uid ) 74 : OPimRecord( uid )
70{ 75{
71// qWarning("OTodoData " + summary); 76// qWarning("OTodoData " + summary);
72 setCategories( category ); 77 setCategories( category );
73 78
74 data = new OTodoData; 79 data = new OTodoData;
75 80
76 data->date = date; 81 data->date = date;
77 data->isCompleted = completed; 82 data->isCompleted = completed;
78 data->hasDate = hasDate; 83 data->hasDate = hasDate;
@@ -229,114 +234,113 @@ void OTodo::setCompletedDate( const QDate& date ) {
229 changeOrModify(); 234 changeOrModify();
230 data->completed = date; 235 data->completed = date;
231} 236}
232void OTodo::setState( const OPimState& state ) { 237void OTodo::setState( const OPimState& state ) {
233 changeOrModify(); 238 changeOrModify();
234 if (data->state ) 239 if (data->state )
235 (*data->state) = state; 240 (*data->state) = state;
236 else 241 else
237 data->state = new OPimState( state ); 242 data->state = new OPimState( state );
238} 243}
239void OTodo::setRecurrence( const ORecur& rec) { 244void OTodo::setRecurrence( const ORecur& rec) {
240 changeOrModify(); 245 changeOrModify();
241 if (data->recur ) 246 if (data->recur )
242 (*data->recur) = rec; 247 (*data->recur) = rec;
243 else 248 else
244 data->recur = new ORecur( rec ); 249 data->recur = new ORecur( rec );
245} 250}
246void OTodo::setMaintainer( const OPimMaintainer& pim ) { 251void OTodo::setMaintainer( const OPimMaintainer& pim ) {
247 changeOrModify(); 252 changeOrModify();
248 253
249 if (data->maintainer ) 254 if (data->maintainer )
250 (*data->maintainer) = pim; 255 (*data->maintainer) = pim;
251 else 256 else
252 data->maintainer = new OPimMaintainer( pim ); 257 data->maintainer = new OPimMaintainer( pim );
253} 258}
254bool OTodo::isOverdue( ) 259bool OTodo::isOverdue( )
255{ 260{
256 if( data->hasDate && !data->isCompleted) 261 if( data->hasDate && !data->isCompleted)
257 return QDate::currentDate() > data->date; 262 return QDate::currentDate() > data->date;
258 return false; 263 return false;
259} 264}
260void OTodo::setProgress(ushort progress ) 265void OTodo::setProgress(ushort progress )
261{ 266{
262 changeOrModify(); 267 changeOrModify();
263 data->prog = progress; 268 data->prog = progress;
264} 269}
265QString OTodo::toShortText() const { 270QString OTodo::toShortText() const {
266 return summary(); 271 return summary();
267} 272}
268/*! 273/*!
269 Returns a richt text string 274 Returns a richt text string
270*/ 275*/
271QString OTodo::toRichText() const 276QString OTodo::toRichText() const
272{ 277{
273 QString text; 278 QString text;
274 QStringList catlist; 279 QStringList catlist;
275 280
276 // summary 281 // summary
277 text += "<b><h3><img src=\"todo/TodoList\">"; 282 text += "<b><h3><img src=\"todo/TodoList\"> ";
278 if ( !summary().isEmpty() ) { 283 if ( !summary().isEmpty() ) {
279 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); 284 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" );
280 } 285 }
281 text += "</h3></b><br><hr><br>"; 286 text += "</h3></b><br><hr><br>";
282 287
283 // description 288 // description
284 if( !description().isEmpty() ){ 289 if( !description().isEmpty() ){
285 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 290 text += "<b>" + QObject::tr( "Notes:" ) + "</b><br>";
286 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 291 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
287 } 292 }
288 293
289 // priority 294 // priority
290 int priorityval = priority(); 295 int priorityval = priority();
291 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + 296 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" +
292 QString::number( priorityval ) + "\">"; 297 QString::number( priorityval ) + "\"> ";
293// text += "<b>" + QObject::tr( "Priority:") +"</b><img src=\"todo/priority" + 298
294// QString::number( priority() ) + "\"><br>";
295 switch ( priorityval ) 299 switch ( priorityval )
296 { 300 {
297 case 1 : text += QObject::tr( "Very high" ); 301 case 1 : text += QObject::tr( "Very high" );
298 break; 302 break;
299 case 2 : text += QObject::tr( "High" ); 303 case 2 : text += QObject::tr( "High" );
300 break; 304 break;
301 case 3 : text += QObject::tr( "Normal" ); 305 case 3 : text += QObject::tr( "Normal" );
302 break; 306 break;
303 case 4 : text += QObject::tr( "Low" ); 307 case 4 : text += QObject::tr( "Low" );
304 break; 308 break;
305 case 5 : text += QObject::tr( "Very low" ); 309 case 5 : text += QObject::tr( "Very low" );
306 break; 310 break;
307 }; 311 };
308 text += "<br>"; 312 text += "<br>";
309 313
310 // progress 314 // progress
311 text += "<b>" + QObject::tr( "Progress:") + " </b>" 315 text += "<b>" + QObject::tr( "Progress:") + " </b>"
312 + QString::number( progress() ) + " %<br>"; 316 + QString::number( progress() ) + " %<br>";
313 317
314 // due date 318 // due date
315 if (hasDueDate() ){ 319 if (hasDueDate() ){
316 QDate dd = dueDate(); 320 QDate dd = dueDate();
317 int off = QDate::currentDate().daysTo( dd ); 321 int off = QDate::currentDate().daysTo( dd );
318 322
319 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; 323 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\"";
320 if ( off < 0 ) 324 if ( off < 0 )
321 text += "#FF0000"; 325 text += "#FF0000";
322 else if ( off == 0 ) 326 else if ( off == 0 )
323 text += "#FFFF00"; 327 text += "#FFFF00";
324 else if ( off > 0 ) 328 else if ( off > 0 )
325 text += "#00FF00"; 329 text += "#00FF00";
326 330
327 text += "\">" + dd.toString() + "</font><br>"; 331 text += "\">" + dd.toString() + "</font><br>";
328 } 332 }
329 333
330 // categories 334 // categories
331 text += "<b>" + QObject::tr( "Category:") + "</b> "; 335 text += "<b>" + QObject::tr( "Category:") + "</b> ";
332 text += categoryNames( "Todo List" ).join(", "); 336 text += categoryNames( "Todo List" ).join(", ");
333 text += "<br>"; 337 text += "<br>";
334 338
335 return text; 339 return text;
336} 340}
337bool OTodo::hasNotifiers()const { 341bool OTodo::hasNotifiers()const {
338 if (!data->notifiers) return false; 342 if (!data->notifiers) return false;
339 return !data->notifiers->isEmpty(); 343 return !data->notifiers->isEmpty();
340} 344}
341OPimNotifyManager& OTodo::notifiers() { 345OPimNotifyManager& OTodo::notifiers() {
342 if (!data->notifiers ) 346 if (!data->notifiers )