-rw-r--r-- | libopie/pim/otodo.cpp | 81 | ||||
-rw-r--r-- | libopie/pim/otodo.h | 16 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 81 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.h | 16 |
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,89 +1,93 @@ | |||
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 | ||
24 | struct OTodo::OTodoData : public QShared { | 24 | struct 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 | ||
44 | OTodo::OTodo(const OTodo &event ) | 48 | OTodo::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 | } |
50 | OTodo::~OTodo() { | 54 | OTodo::~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 | } |
59 | OTodo::OTodo(bool completed, int priority, | 63 | OTodo::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 | } |
80 | OTodo::OTodo(bool completed, int priority, | 84 | OTodo::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(";") ) ); |
@@ -106,207 +110,245 @@ bool OTodo::match( const QRegExp ®Exp )const | |||
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 | } |
114 | bool OTodo::isCompleted() const | 118 | bool OTodo::isCompleted() const |
115 | { | 119 | { |
116 | return data->isCompleted; | 120 | return data->isCompleted; |
117 | } | 121 | } |
118 | bool OTodo::hasDueDate() const | 122 | bool OTodo::hasDueDate() const |
119 | { | 123 | { |
120 | return data->hasDate; | 124 | return data->hasDate; |
121 | } | 125 | } |
122 | bool OTodo::hasStartDate()const { | 126 | bool OTodo::hasStartDate()const { |
123 | return data->start.isValid(); | 127 | return data->start.isValid(); |
124 | } | 128 | } |
125 | bool OTodo::hasCompletedDate()const { | 129 | bool OTodo::hasCompletedDate()const { |
126 | return data->completed.isValid(); | 130 | return data->completed.isValid(); |
127 | } | 131 | } |
128 | int OTodo::priority()const | 132 | int OTodo::priority()const |
129 | { | 133 | { |
130 | return data->priority; | 134 | return data->priority; |
131 | } | 135 | } |
132 | QString OTodo::summary() const | 136 | QString OTodo::summary() const |
133 | { | 137 | { |
134 | return data->sum; | 138 | return data->sum; |
135 | } | 139 | } |
136 | ushort OTodo::progress() const | 140 | ushort OTodo::progress() const |
137 | { | 141 | { |
138 | return data->prog; | 142 | return data->prog; |
139 | } | 143 | } |
140 | QDate OTodo::dueDate()const | 144 | QDate OTodo::dueDate()const |
141 | { | 145 | { |
142 | return data->date; | 146 | return data->date; |
143 | } | 147 | } |
144 | QDate OTodo::startDate()const { | 148 | QDate OTodo::startDate()const { |
145 | return data->start; | 149 | return data->start; |
146 | } | 150 | } |
147 | QDate OTodo::completedDate()const { | 151 | QDate OTodo::completedDate()const { |
148 | return data->completed; | 152 | return data->completed; |
149 | } | 153 | } |
150 | QString OTodo::description()const | 154 | QString OTodo::description()const |
151 | { | 155 | { |
152 | return data->desc; | 156 | return data->desc; |
153 | } | 157 | } |
158 | bool OTodo::hasState() const{ | ||
159 | if (!data->state ) return false; | ||
160 | return ( data->state->state() != OPimState::Undefined ); | ||
161 | } | ||
154 | OPimState OTodo::state()const { | 162 | OPimState OTodo::state()const { |
155 | return data->state; | 163 | if (!data->state ) { |
164 | OPimState state; | ||
165 | return state; | ||
166 | } | ||
167 | |||
168 | return (*data->state); | ||
169 | } | ||
170 | bool OTodo::hasRecurrence()const { | ||
171 | if (!data->recur) return false; | ||
172 | return data->recur->doesRecur(); | ||
156 | } | 173 | } |
157 | ORecur OTodo::recurrence()const { | 174 | ORecur OTodo::recurrence()const { |
158 | return data->recur; | 175 | if (!data->recur) return ORecur(); |
176 | |||
177 | return (*data->recur); | ||
178 | } | ||
179 | bool OTodo::hasMaintainer()const { | ||
180 | if (!data->maintainer) return false; | ||
181 | |||
182 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); | ||
159 | } | 183 | } |
160 | OPimMaintainer OTodo::maintainer()const { | 184 | OPimMaintainer OTodo::maintainer()const { |
161 | return data->maintainer; | 185 | if (!data->maintainer) return OPimMaintainer(); |
186 | |||
187 | return (*data->maintainer); | ||
162 | } | 188 | } |
163 | void OTodo::setCompleted( bool completed ) | 189 | void OTodo::setCompleted( bool completed ) |
164 | { | 190 | { |
165 | changeOrModify(); | 191 | changeOrModify(); |
166 | data->isCompleted = completed; | 192 | data->isCompleted = completed; |
167 | } | 193 | } |
168 | void OTodo::setHasDueDate( bool hasDate ) | 194 | void OTodo::setHasDueDate( bool hasDate ) |
169 | { | 195 | { |
170 | changeOrModify(); | 196 | changeOrModify(); |
171 | data->hasDate = hasDate; | 197 | data->hasDate = hasDate; |
172 | } | 198 | } |
173 | void OTodo::setDescription(const QString &desc ) | 199 | void 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 | } |
179 | void OTodo::setSummary( const QString& sum ) | 205 | void OTodo::setSummary( const QString& sum ) |
180 | { | 206 | { |
181 | changeOrModify(); | 207 | changeOrModify(); |
182 | data->sum = sum; | 208 | data->sum = sum; |
183 | } | 209 | } |
184 | void OTodo::setPriority(int prio ) | 210 | void OTodo::setPriority(int prio ) |
185 | { | 211 | { |
186 | changeOrModify(); | 212 | changeOrModify(); |
187 | data->priority = prio; | 213 | data->priority = prio; |
188 | } | 214 | } |
189 | void OTodo::setDueDate( const QDate& date ) | 215 | void OTodo::setDueDate( const QDate& date ) |
190 | { | 216 | { |
191 | changeOrModify(); | 217 | changeOrModify(); |
192 | data->date = date; | 218 | data->date = date; |
193 | } | 219 | } |
194 | void OTodo::setStartDate( const QDate& date ) { | 220 | void OTodo::setStartDate( const QDate& date ) { |
195 | changeOrModify(); | 221 | changeOrModify(); |
196 | data->start = date; | 222 | data->start = date; |
197 | } | 223 | } |
198 | void OTodo::setCompletedDate( const QDate& date ) { | 224 | void OTodo::setCompletedDate( const QDate& date ) { |
199 | changeOrModify(); | 225 | changeOrModify(); |
200 | data->completed = date; | 226 | data->completed = date; |
201 | } | 227 | } |
202 | void OTodo::setState( const OPimState& state ) { | 228 | void 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 | } |
206 | void OTodo::setRecurrence( const ORecur& rec) { | 235 | void 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 | } |
210 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 242 | void 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 | } |
214 | bool OTodo::isOverdue( ) | 250 | bool 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 | } |
220 | void OTodo::setProgress(ushort progress ) | 256 | void OTodo::setProgress(ushort progress ) |
221 | { | 257 | { |
222 | changeOrModify(); | 258 | changeOrModify(); |
223 | data->prog = progress; | 259 | data->prog = progress; |
224 | } | 260 | } |
225 | QString OTodo::toShortText() const { | 261 | QString 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 | */ |
231 | QString OTodo::toRichText() const | 267 | QString 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 | } |
299 | bool OTodo::hasNotifiers()const { | ||
300 | if (!data->notifiers) return false; | ||
301 | return data->notifiers->isEmpty(); | ||
302 | } | ||
263 | OPimNotifyManager& OTodo::notifiers() { | 303 | OPimNotifyManager& OTodo::notifiers() { |
264 | return data->notifiers; | 304 | if (!data->notifiers ) |
305 | data->notifiers = new OPimNotifyManager; | ||
306 | return (*data->notifiers); | ||
265 | } | 307 | } |
266 | 308 | ||
267 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 309 | bool 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 | } |
279 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 321 | bool 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 | } |
292 | bool OTodo::operator>(const OTodo &toDoEvent )const | 334 | bool 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 | } |
305 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 347 | bool 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{ |
@@ -360,65 +402,74 @@ QMap<int, QString> OTodo::toMap() const { | |||
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 | ||
377 | QMap<QString, QString> OTodo::toExtraMap()const { | 419 | QMap<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 | */ |
385 | void OTodo::changeOrModify() { | 427 | void 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 | */ |
399 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 441 | void 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 | } |
415 | QString OTodo::type() const { | 466 | QString OTodo::type() const { |
416 | return QString::fromLatin1("OTodo"); | 467 | return QString::fromLatin1("OTodo"); |
417 | } | 468 | } |
418 | QString OTodo::recordField(int /*id*/ )const { | 469 | QString OTodo::recordField(int /*id*/ )const { |
419 | return QString::null; | 470 | return QString::null; |
420 | } | 471 | } |
421 | 472 | ||
422 | int OTodo::rtti(){ | 473 | int 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 | |||
@@ -83,126 +83,142 @@ public: | |||
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 ¬ifiers(); | 183 | OPimNotifyManager ¬ifiers(); |
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 |
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,89 +1,93 @@ | |||
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 | ||
24 | struct OTodo::OTodoData : public QShared { | 24 | struct 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 | ||
44 | OTodo::OTodo(const OTodo &event ) | 48 | OTodo::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 | } |
50 | OTodo::~OTodo() { | 54 | OTodo::~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 | } |
59 | OTodo::OTodo(bool completed, int priority, | 63 | OTodo::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 | } |
80 | OTodo::OTodo(bool completed, int priority, | 84 | OTodo::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(";") ) ); |
@@ -106,207 +110,245 @@ bool OTodo::match( const QRegExp ®Exp )const | |||
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 | } |
114 | bool OTodo::isCompleted() const | 118 | bool OTodo::isCompleted() const |
115 | { | 119 | { |
116 | return data->isCompleted; | 120 | return data->isCompleted; |
117 | } | 121 | } |
118 | bool OTodo::hasDueDate() const | 122 | bool OTodo::hasDueDate() const |
119 | { | 123 | { |
120 | return data->hasDate; | 124 | return data->hasDate; |
121 | } | 125 | } |
122 | bool OTodo::hasStartDate()const { | 126 | bool OTodo::hasStartDate()const { |
123 | return data->start.isValid(); | 127 | return data->start.isValid(); |
124 | } | 128 | } |
125 | bool OTodo::hasCompletedDate()const { | 129 | bool OTodo::hasCompletedDate()const { |
126 | return data->completed.isValid(); | 130 | return data->completed.isValid(); |
127 | } | 131 | } |
128 | int OTodo::priority()const | 132 | int OTodo::priority()const |
129 | { | 133 | { |
130 | return data->priority; | 134 | return data->priority; |
131 | } | 135 | } |
132 | QString OTodo::summary() const | 136 | QString OTodo::summary() const |
133 | { | 137 | { |
134 | return data->sum; | 138 | return data->sum; |
135 | } | 139 | } |
136 | ushort OTodo::progress() const | 140 | ushort OTodo::progress() const |
137 | { | 141 | { |
138 | return data->prog; | 142 | return data->prog; |
139 | } | 143 | } |
140 | QDate OTodo::dueDate()const | 144 | QDate OTodo::dueDate()const |
141 | { | 145 | { |
142 | return data->date; | 146 | return data->date; |
143 | } | 147 | } |
144 | QDate OTodo::startDate()const { | 148 | QDate OTodo::startDate()const { |
145 | return data->start; | 149 | return data->start; |
146 | } | 150 | } |
147 | QDate OTodo::completedDate()const { | 151 | QDate OTodo::completedDate()const { |
148 | return data->completed; | 152 | return data->completed; |
149 | } | 153 | } |
150 | QString OTodo::description()const | 154 | QString OTodo::description()const |
151 | { | 155 | { |
152 | return data->desc; | 156 | return data->desc; |
153 | } | 157 | } |
158 | bool OTodo::hasState() const{ | ||
159 | if (!data->state ) return false; | ||
160 | return ( data->state->state() != OPimState::Undefined ); | ||
161 | } | ||
154 | OPimState OTodo::state()const { | 162 | OPimState OTodo::state()const { |
155 | return data->state; | 163 | if (!data->state ) { |
164 | OPimState state; | ||
165 | return state; | ||
166 | } | ||
167 | |||
168 | return (*data->state); | ||
169 | } | ||
170 | bool OTodo::hasRecurrence()const { | ||
171 | if (!data->recur) return false; | ||
172 | return data->recur->doesRecur(); | ||
156 | } | 173 | } |
157 | ORecur OTodo::recurrence()const { | 174 | ORecur OTodo::recurrence()const { |
158 | return data->recur; | 175 | if (!data->recur) return ORecur(); |
176 | |||
177 | return (*data->recur); | ||
178 | } | ||
179 | bool OTodo::hasMaintainer()const { | ||
180 | if (!data->maintainer) return false; | ||
181 | |||
182 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); | ||
159 | } | 183 | } |
160 | OPimMaintainer OTodo::maintainer()const { | 184 | OPimMaintainer OTodo::maintainer()const { |
161 | return data->maintainer; | 185 | if (!data->maintainer) return OPimMaintainer(); |
186 | |||
187 | return (*data->maintainer); | ||
162 | } | 188 | } |
163 | void OTodo::setCompleted( bool completed ) | 189 | void OTodo::setCompleted( bool completed ) |
164 | { | 190 | { |
165 | changeOrModify(); | 191 | changeOrModify(); |
166 | data->isCompleted = completed; | 192 | data->isCompleted = completed; |
167 | } | 193 | } |
168 | void OTodo::setHasDueDate( bool hasDate ) | 194 | void OTodo::setHasDueDate( bool hasDate ) |
169 | { | 195 | { |
170 | changeOrModify(); | 196 | changeOrModify(); |
171 | data->hasDate = hasDate; | 197 | data->hasDate = hasDate; |
172 | } | 198 | } |
173 | void OTodo::setDescription(const QString &desc ) | 199 | void 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 | } |
179 | void OTodo::setSummary( const QString& sum ) | 205 | void OTodo::setSummary( const QString& sum ) |
180 | { | 206 | { |
181 | changeOrModify(); | 207 | changeOrModify(); |
182 | data->sum = sum; | 208 | data->sum = sum; |
183 | } | 209 | } |
184 | void OTodo::setPriority(int prio ) | 210 | void OTodo::setPriority(int prio ) |
185 | { | 211 | { |
186 | changeOrModify(); | 212 | changeOrModify(); |
187 | data->priority = prio; | 213 | data->priority = prio; |
188 | } | 214 | } |
189 | void OTodo::setDueDate( const QDate& date ) | 215 | void OTodo::setDueDate( const QDate& date ) |
190 | { | 216 | { |
191 | changeOrModify(); | 217 | changeOrModify(); |
192 | data->date = date; | 218 | data->date = date; |
193 | } | 219 | } |
194 | void OTodo::setStartDate( const QDate& date ) { | 220 | void OTodo::setStartDate( const QDate& date ) { |
195 | changeOrModify(); | 221 | changeOrModify(); |
196 | data->start = date; | 222 | data->start = date; |
197 | } | 223 | } |
198 | void OTodo::setCompletedDate( const QDate& date ) { | 224 | void OTodo::setCompletedDate( const QDate& date ) { |
199 | changeOrModify(); | 225 | changeOrModify(); |
200 | data->completed = date; | 226 | data->completed = date; |
201 | } | 227 | } |
202 | void OTodo::setState( const OPimState& state ) { | 228 | void 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 | } |
206 | void OTodo::setRecurrence( const ORecur& rec) { | 235 | void 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 | } |
210 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 242 | void 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 | } |
214 | bool OTodo::isOverdue( ) | 250 | bool 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 | } |
220 | void OTodo::setProgress(ushort progress ) | 256 | void OTodo::setProgress(ushort progress ) |
221 | { | 257 | { |
222 | changeOrModify(); | 258 | changeOrModify(); |
223 | data->prog = progress; | 259 | data->prog = progress; |
224 | } | 260 | } |
225 | QString OTodo::toShortText() const { | 261 | QString 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 | */ |
231 | QString OTodo::toRichText() const | 267 | QString 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 | } |
299 | bool OTodo::hasNotifiers()const { | ||
300 | if (!data->notifiers) return false; | ||
301 | return data->notifiers->isEmpty(); | ||
302 | } | ||
263 | OPimNotifyManager& OTodo::notifiers() { | 303 | OPimNotifyManager& OTodo::notifiers() { |
264 | return data->notifiers; | 304 | if (!data->notifiers ) |
305 | data->notifiers = new OPimNotifyManager; | ||
306 | return (*data->notifiers); | ||
265 | } | 307 | } |
266 | 308 | ||
267 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 309 | bool 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 | } |
279 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 321 | bool 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 | } |
292 | bool OTodo::operator>(const OTodo &toDoEvent )const | 334 | bool 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 | } |
305 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 347 | bool 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{ |
@@ -360,65 +402,74 @@ QMap<int, QString> OTodo::toMap() const { | |||
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 | ||
377 | QMap<QString, QString> OTodo::toExtraMap()const { | 419 | QMap<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 | */ |
385 | void OTodo::changeOrModify() { | 427 | void 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 | */ |
399 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 441 | void 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 | } |
415 | QString OTodo::type() const { | 466 | QString OTodo::type() const { |
416 | return QString::fromLatin1("OTodo"); | 467 | return QString::fromLatin1("OTodo"); |
417 | } | 468 | } |
418 | QString OTodo::recordField(int /*id*/ )const { | 469 | QString OTodo::recordField(int /*id*/ )const { |
419 | return QString::null; | 470 | return QString::null; |
420 | } | 471 | } |
421 | 472 | ||
422 | int OTodo::rtti(){ | 473 | int 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 | |||
@@ -83,126 +83,142 @@ public: | |||
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 ¬ifiers(); | 183 | OPimNotifyManager ¬ifiers(); |
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 |