-rw-r--r-- | libopie/pim/otodo.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index 6dd4c0e..765d5a9 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp | |||
@@ -1,382 +1,382 @@ | |||
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 | 15 | ||
16 | #include "otodo.h" | 16 | #include "otodo.h" |
17 | 17 | ||
18 | 18 | ||
19 | struct OTodo::OTodoData : public QShared { | 19 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | 20 | OTodoData() : QShared() { |
21 | }; | 21 | }; |
22 | 22 | ||
23 | QDate date; | 23 | QDate date; |
24 | bool isCompleted:1; | 24 | bool isCompleted:1; |
25 | bool hasDate:1; | 25 | bool hasDate:1; |
26 | int priority; | 26 | int priority; |
27 | QString desc; | 27 | QString desc; |
28 | QString sum; | 28 | QString sum; |
29 | QMap<QString, QString> extra; | 29 | QMap<QString, QString> extra; |
30 | ushort prog; | 30 | ushort prog; |
31 | bool hasAlarmDateTime :1; | 31 | bool hasAlarmDateTime :1; |
32 | QDateTime alarmDateTime; | 32 | QDateTime alarmDateTime; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | OTodo::OTodo(const OTodo &event ) | 35 | OTodo::OTodo(const OTodo &event ) |
36 | : OPimRecord( event ), data( event.data ) | 36 | : OPimRecord( event ), data( event.data ) |
37 | { | 37 | { |
38 | data->ref(); | 38 | data->ref(); |
39 | // qWarning("ref up"); | 39 | // qWarning("ref up"); |
40 | } | 40 | } |
41 | OTodo::~OTodo() { | 41 | OTodo::~OTodo() { |
42 | 42 | ||
43 | // qWarning("~OTodo " ); | 43 | // qWarning("~OTodo " ); |
44 | if ( data->deref() ) { | 44 | if ( data->deref() ) { |
45 | // qWarning("OTodo::dereffing"); | 45 | // qWarning("OTodo::dereffing"); |
46 | delete data; | 46 | delete data; |
47 | data = 0l; | 47 | data = 0l; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | OTodo::OTodo(bool completed, int priority, | 50 | OTodo::OTodo(bool completed, int priority, |
51 | const QArray<int> &category, | 51 | const QArray<int> &category, |
52 | const QString& summary, | 52 | const QString& summary, |
53 | const QString &description, | 53 | const QString &description, |
54 | ushort progress, | 54 | ushort progress, |
55 | bool hasDate, QDate date, int uid ) | 55 | bool hasDate, QDate date, int uid ) |
56 | : OPimRecord( uid ) | 56 | : OPimRecord( uid ) |
57 | { | 57 | { |
58 | // qWarning("OTodoData " + summary); | 58 | // qWarning("OTodoData " + summary); |
59 | setCategories( category ); | 59 | setCategories( category ); |
60 | 60 | ||
61 | data = new OTodoData; | 61 | data = new OTodoData; |
62 | 62 | ||
63 | data->date = date; | 63 | data->date = date; |
64 | data->isCompleted = completed; | 64 | data->isCompleted = completed; |
65 | data->hasDate = hasDate; | 65 | data->hasDate = hasDate; |
66 | data->priority = priority; | 66 | data->priority = priority; |
67 | data->sum = summary; | 67 | data->sum = summary; |
68 | data->prog = progress; | 68 | data->prog = progress; |
69 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 69 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
70 | data->hasAlarmDateTime = false; | 70 | data->hasAlarmDateTime = false; |
71 | 71 | ||
72 | } | 72 | } |
73 | OTodo::OTodo(bool completed, int priority, | 73 | OTodo::OTodo(bool completed, int priority, |
74 | const QStringList &category, | 74 | const QStringList &category, |
75 | const QString& summary, | 75 | const QString& summary, |
76 | const QString &description, | 76 | const QString &description, |
77 | ushort progress, | 77 | ushort progress, |
78 | bool hasDate, QDate date, int uid ) | 78 | bool hasDate, QDate date, int uid ) |
79 | : OPimRecord( uid ) | 79 | : OPimRecord( uid ) |
80 | { | 80 | { |
81 | // qWarning("OTodoData" + summary); | 81 | // qWarning("OTodoData" + summary); |
82 | setCategories( idsFromString( category.join(";") ) ); | 82 | setCategories( idsFromString( category.join(";") ) ); |
83 | 83 | ||
84 | data = new OTodoData; | 84 | data = new OTodoData; |
85 | 85 | ||
86 | data->date = date; | 86 | data->date = date; |
87 | data->isCompleted = completed; | 87 | data->isCompleted = completed; |
88 | data->hasDate = hasDate; | 88 | data->hasDate = hasDate; |
89 | data->priority = priority; | 89 | data->priority = priority; |
90 | data->sum = summary; | 90 | data->sum = summary; |
91 | data->prog = progress; | 91 | data->prog = progress; |
92 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 92 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
93 | data->hasAlarmDateTime = false; | 93 | data->hasAlarmDateTime = false; |
94 | 94 | ||
95 | } | 95 | } |
96 | bool OTodo::match( const QRegExp ®Exp )const | 96 | bool OTodo::match( const QRegExp ®Exp )const |
97 | { | 97 | { |
98 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 98 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
99 | return true; | 99 | return true; |
100 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 100 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
101 | return true; | 101 | return true; |
102 | }else if(data->desc.find( regExp ) != -1 ){ | 102 | }else if(data->desc.find( regExp ) != -1 ){ |
103 | return true; | 103 | return true; |
104 | }else if(data->sum.find( regExp ) != -1 ) { | 104 | }else if(data->sum.find( regExp ) != -1 ) { |
105 | return true; | 105 | return true; |
106 | } | 106 | } |
107 | return false; | 107 | return false; |
108 | } | 108 | } |
109 | bool OTodo::isCompleted() const | 109 | bool OTodo::isCompleted() const |
110 | { | 110 | { |
111 | return data->isCompleted; | 111 | return data->isCompleted; |
112 | } | 112 | } |
113 | bool OTodo::hasDueDate() const | 113 | bool OTodo::hasDueDate() const |
114 | { | 114 | { |
115 | return data->hasDate; | 115 | return data->hasDate; |
116 | } | 116 | } |
117 | bool OTodo::hasAlarmDateTime() const | 117 | bool OTodo::hasAlarmDateTime() const |
118 | { | 118 | { |
119 | return data->hasAlarmDateTime; | 119 | return data->hasAlarmDateTime; |
120 | } | 120 | } |
121 | int OTodo::priority()const | 121 | int OTodo::priority()const |
122 | { | 122 | { |
123 | return data->priority; | 123 | return data->priority; |
124 | } | 124 | } |
125 | QString OTodo::summary() const | 125 | QString OTodo::summary() const |
126 | { | 126 | { |
127 | return data->sum; | 127 | return data->sum; |
128 | } | 128 | } |
129 | ushort OTodo::progress() const | 129 | ushort OTodo::progress() const |
130 | { | 130 | { |
131 | return data->prog; | 131 | return data->prog; |
132 | } | 132 | } |
133 | QDate OTodo::dueDate()const | 133 | QDate OTodo::dueDate()const |
134 | { | 134 | { |
135 | return data->date; | 135 | return data->date; |
136 | } | 136 | } |
137 | 137 | ||
138 | QDateTime OTodo::alarmDateTime() const | 138 | QDateTime OTodo::alarmDateTime() const |
139 | { | 139 | { |
140 | return data->alarmDateTime; | 140 | return data->alarmDateTime; |
141 | } | 141 | } |
142 | 142 | ||
143 | QString OTodo::description()const | 143 | QString OTodo::description()const |
144 | { | 144 | { |
145 | return data->desc; | 145 | return data->desc; |
146 | } | 146 | } |
147 | void OTodo::setCompleted( bool completed ) | 147 | void OTodo::setCompleted( bool completed ) |
148 | { | 148 | { |
149 | changeOrModify(); | 149 | changeOrModify(); |
150 | data->isCompleted = completed; | 150 | data->isCompleted = completed; |
151 | } | 151 | } |
152 | void OTodo::setHasDueDate( bool hasDate ) | 152 | void OTodo::setHasDueDate( bool hasDate ) |
153 | { | 153 | { |
154 | changeOrModify(); | 154 | changeOrModify(); |
155 | data->hasDate = hasDate; | 155 | data->hasDate = hasDate; |
156 | } | 156 | } |
157 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) | 157 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) |
158 | { | 158 | { |
159 | changeOrModify(); | 159 | changeOrModify(); |
160 | data->hasAlarmDateTime = hasAlarmDateTime; | 160 | data->hasAlarmDateTime = hasAlarmDateTime; |
161 | } | 161 | } |
162 | void OTodo::setDescription(const QString &desc ) | 162 | void OTodo::setDescription(const QString &desc ) |
163 | { | 163 | { |
164 | // qWarning( "desc " + desc ); | 164 | // qWarning( "desc " + desc ); |
165 | changeOrModify(); | 165 | changeOrModify(); |
166 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 166 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
167 | } | 167 | } |
168 | void OTodo::setSummary( const QString& sum ) | 168 | void OTodo::setSummary( const QString& sum ) |
169 | { | 169 | { |
170 | changeOrModify(); | 170 | changeOrModify(); |
171 | data->sum = sum; | 171 | data->sum = sum; |
172 | } | 172 | } |
173 | void OTodo::setPriority(int prio ) | 173 | void OTodo::setPriority(int prio ) |
174 | { | 174 | { |
175 | changeOrModify(); | 175 | changeOrModify(); |
176 | data->priority = prio; | 176 | data->priority = prio; |
177 | } | 177 | } |
178 | void OTodo::setDueDate( QDate date ) | 178 | void OTodo::setDueDate( QDate date ) |
179 | { | 179 | { |
180 | changeOrModify(); | 180 | changeOrModify(); |
181 | data->date = date; | 181 | data->date = date; |
182 | } | 182 | } |
183 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) | 183 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) |
184 | { | 184 | { |
185 | changeOrModify(); | 185 | changeOrModify(); |
186 | data->alarmDateTime = alarm; | 186 | data->alarmDateTime = alarm; |
187 | } | 187 | } |
188 | bool OTodo::isOverdue( ) | 188 | bool OTodo::isOverdue( ) |
189 | { | 189 | { |
190 | if( data->hasDate ) | 190 | if( data->hasDate && !data->isCompleted) |
191 | return QDate::currentDate() > data->date; | 191 | return QDate::currentDate() > data->date; |
192 | return false; | 192 | return false; |
193 | } | 193 | } |
194 | void OTodo::setProgress(ushort progress ) | 194 | void OTodo::setProgress(ushort progress ) |
195 | { | 195 | { |
196 | changeOrModify(); | 196 | changeOrModify(); |
197 | data->prog = progress; | 197 | data->prog = progress; |
198 | } | 198 | } |
199 | QString OTodo::toShortText() const { | 199 | QString OTodo::toShortText() const { |
200 | return summary(); | 200 | return summary(); |
201 | } | 201 | } |
202 | /*! | 202 | /*! |
203 | Returns a richt text string | 203 | Returns a richt text string |
204 | */ | 204 | */ |
205 | QString OTodo::toRichText() const | 205 | QString OTodo::toRichText() const |
206 | { | 206 | { |
207 | QString text; | 207 | QString text; |
208 | QStringList catlist; | 208 | QStringList catlist; |
209 | 209 | ||
210 | // Description of the todo | 210 | // Description of the todo |
211 | if ( !summary().isEmpty() ) { | 211 | if ( !summary().isEmpty() ) { |
212 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | 212 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; |
213 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 213 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
214 | } | 214 | } |
215 | if( !description().isEmpty() ){ | 215 | if( !description().isEmpty() ){ |
216 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 216 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
217 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 217 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; |
218 | } | 218 | } |
219 | text += "<br><br><br>"; | 219 | text += "<br><br><br>"; |
220 | 220 | ||
221 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 221 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
222 | + QString::number( priority() ) + " <br>"; | 222 | + QString::number( priority() ) + " <br>"; |
223 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 223 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
224 | + QString::number( progress() ) + " %<br>"; | 224 | + QString::number( progress() ) + " %<br>"; |
225 | if (hasDueDate() ){ | 225 | if (hasDueDate() ){ |
226 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 226 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
227 | text += dueDate().toString(); | 227 | text += dueDate().toString(); |
228 | text += "<br>"; | 228 | text += "<br>"; |
229 | } | 229 | } |
230 | if (hasAlarmDateTime() ){ | 230 | if (hasAlarmDateTime() ){ |
231 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; | 231 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; |
232 | text += alarmDateTime().toString(); | 232 | text += alarmDateTime().toString(); |
233 | text += "<br>"; | 233 | text += "<br>"; |
234 | } | 234 | } |
235 | 235 | ||
236 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 236 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
237 | text += categoryNames().join(", "); | 237 | text += categoryNames().join(", "); |
238 | text += "<br>"; | 238 | text += "<br>"; |
239 | 239 | ||
240 | return text; | 240 | return text; |
241 | } | 241 | } |
242 | 242 | ||
243 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 243 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
244 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 244 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
245 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 245 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
246 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 246 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
247 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 247 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
248 | return priority() < toDoEvent.priority(); | 248 | return priority() < toDoEvent.priority(); |
249 | }else{ | 249 | }else{ |
250 | return dueDate() < toDoEvent.dueDate(); | 250 | return dueDate() < toDoEvent.dueDate(); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | return false; | 253 | return false; |
254 | } | 254 | } |
255 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 255 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
256 | { | 256 | { |
257 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 257 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
258 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 258 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
259 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 259 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
260 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 260 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
261 | return priority() <= toDoEvent.priority(); | 261 | return priority() <= toDoEvent.priority(); |
262 | }else{ | 262 | }else{ |
263 | return dueDate() <= toDoEvent.dueDate(); | 263 | return dueDate() <= toDoEvent.dueDate(); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | return true; | 266 | return true; |
267 | } | 267 | } |
268 | bool OTodo::operator>(const OTodo &toDoEvent )const | 268 | bool OTodo::operator>(const OTodo &toDoEvent )const |
269 | { | 269 | { |
270 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 270 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
271 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 271 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
272 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 272 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
273 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 273 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
274 | return priority() > toDoEvent.priority(); | 274 | return priority() > toDoEvent.priority(); |
275 | }else{ | 275 | }else{ |
276 | return dueDate() > toDoEvent.dueDate(); | 276 | return dueDate() > toDoEvent.dueDate(); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | return false; | 279 | return false; |
280 | } | 280 | } |
281 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 281 | bool OTodo::operator>=(const OTodo &toDoEvent )const |
282 | { | 282 | { |
283 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 283 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
284 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 284 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
285 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 285 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
286 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 286 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
287 | return priority() > toDoEvent.priority(); | 287 | return priority() > toDoEvent.priority(); |
288 | }else{ | 288 | }else{ |
289 | return dueDate() > toDoEvent.dueDate(); | 289 | return dueDate() > toDoEvent.dueDate(); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | return true; | 292 | return true; |
293 | } | 293 | } |
294 | bool OTodo::operator==(const OTodo &toDoEvent )const | 294 | bool OTodo::operator==(const OTodo &toDoEvent )const |
295 | { | 295 | { |
296 | if ( data->priority != toDoEvent.data->priority ) return false; | 296 | if ( data->priority != toDoEvent.data->priority ) return false; |
297 | if ( data->priority != toDoEvent.data->prog ) return false; | 297 | if ( data->priority != toDoEvent.data->prog ) return false; |
298 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; | 298 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; |
299 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; | 299 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; |
300 | if ( data->date != toDoEvent.data->date ) return false; | 300 | if ( data->date != toDoEvent.data->date ) return false; |
301 | if ( data->sum != toDoEvent.data->sum ) return false; | 301 | if ( data->sum != toDoEvent.data->sum ) return false; |
302 | if ( data->desc != toDoEvent.data->desc ) return false; | 302 | if ( data->desc != toDoEvent.data->desc ) return false; |
303 | if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) | 303 | if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) |
304 | return false; | 304 | return false; |
305 | if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) | 305 | if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) |
306 | return false; | 306 | return false; |
307 | 307 | ||
308 | return OPimRecord::operator==( toDoEvent ); | 308 | return OPimRecord::operator==( toDoEvent ); |
309 | } | 309 | } |
310 | void OTodo::deref() { | 310 | void OTodo::deref() { |
311 | 311 | ||
312 | // qWarning("deref in ToDoEvent"); | 312 | // qWarning("deref in ToDoEvent"); |
313 | if ( data->deref() ) { | 313 | if ( data->deref() ) { |
314 | // qWarning("deleting"); | 314 | // qWarning("deleting"); |
315 | delete data; | 315 | delete data; |
316 | data= 0; | 316 | data= 0; |
317 | } | 317 | } |
318 | } | 318 | } |
319 | OTodo &OTodo::operator=(const OTodo &item ) | 319 | OTodo &OTodo::operator=(const OTodo &item ) |
320 | { | 320 | { |
321 | OPimRecord::operator=( item ); | 321 | OPimRecord::operator=( item ); |
322 | //qWarning("operator= ref "); | 322 | //qWarning("operator= ref "); |
323 | item.data->ref(); | 323 | item.data->ref(); |
324 | deref(); | 324 | deref(); |
325 | data = item.data; | 325 | data = item.data; |
326 | 326 | ||
327 | return *this; | 327 | return *this; |
328 | } | 328 | } |
329 | 329 | ||
330 | QMap<int, QString> OTodo::toMap() const { | 330 | QMap<int, QString> OTodo::toMap() const { |
331 | QMap<int, QString> map; | 331 | QMap<int, QString> map; |
332 | 332 | ||
333 | map.insert( Uid, QString::number( uid() ) ); | 333 | map.insert( Uid, QString::number( uid() ) ); |
334 | map.insert( Category, idsToString( categories() ) ); | 334 | map.insert( Category, idsToString( categories() ) ); |
335 | map.insert( HasDate, QString::number( data->hasDate ) ); | 335 | map.insert( HasDate, QString::number( data->hasDate ) ); |
336 | map.insert( Completed, QString::number( data->isCompleted ) ); | 336 | map.insert( Completed, QString::number( data->isCompleted ) ); |
337 | map.insert( Description, data->desc ); | 337 | map.insert( Description, data->desc ); |
338 | map.insert( Summary, data->sum ); | 338 | map.insert( Summary, data->sum ); |
339 | map.insert( Priority, QString::number( data->priority ) ); | 339 | map.insert( Priority, QString::number( data->priority ) ); |
340 | map.insert( DateDay, QString::number( data->date.day() ) ); | 340 | map.insert( DateDay, QString::number( data->date.day() ) ); |
341 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 341 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
342 | map.insert( DateYear, QString::number( data->date.year() ) ); | 342 | map.insert( DateYear, QString::number( data->date.year() ) ); |
343 | map.insert( Progress, QString::number( data->prog ) ); | 343 | map.insert( Progress, QString::number( data->prog ) ); |
344 | map.insert( CrossReference, crossToString() ); | 344 | map.insert( CrossReference, crossToString() ); |
345 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); | 345 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); |
346 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); | 346 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); |
347 | 347 | ||
348 | return map; | 348 | return map; |
349 | } | 349 | } |
350 | 350 | ||
351 | QMap<QString, QString> OTodo::toExtraMap()const { | 351 | QMap<QString, QString> OTodo::toExtraMap()const { |
352 | return data->extra; | 352 | return data->extra; |
353 | } | 353 | } |
354 | /** | 354 | /** |
355 | * change or modify looks at the ref count and either | 355 | * change or modify looks at the ref count and either |
356 | * creates a new QShared Object or it can modify it | 356 | * creates a new QShared Object or it can modify it |
357 | * right in place | 357 | * right in place |
358 | */ | 358 | */ |
359 | void OTodo::changeOrModify() { | 359 | void OTodo::changeOrModify() { |
360 | if ( data->count != 1 ) { | 360 | if ( data->count != 1 ) { |
361 | // qWarning("changeOrModify"); | 361 | // qWarning("changeOrModify"); |
362 | data->deref(); | 362 | data->deref(); |
363 | OTodoData* d2 = new OTodoData(); | 363 | OTodoData* d2 = new OTodoData(); |
364 | copy(data, d2 ); | 364 | copy(data, d2 ); |
365 | data = d2; | 365 | data = d2; |
366 | } | 366 | } |
367 | } | 367 | } |
368 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 368 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
369 | dest->date = src->date; | 369 | dest->date = src->date; |
370 | dest->isCompleted = src->isCompleted; | 370 | dest->isCompleted = src->isCompleted; |
371 | dest->hasDate = src->hasDate; | 371 | dest->hasDate = src->hasDate; |
372 | dest->priority = src->priority; | 372 | dest->priority = src->priority; |
373 | dest->desc = src->desc; | 373 | dest->desc = src->desc; |
374 | dest->sum = src->sum; | 374 | dest->sum = src->sum; |
375 | dest->extra = src->extra; | 375 | dest->extra = src->extra; |
376 | dest->prog = src->prog; | 376 | dest->prog = src->prog; |
377 | dest->hasAlarmDateTime = src->hasAlarmDateTime; | 377 | dest->hasAlarmDateTime = src->hasAlarmDateTime; |
378 | dest->alarmDateTime = src->alarmDateTime; | 378 | dest->alarmDateTime = src->alarmDateTime; |
379 | } | 379 | } |
380 | QString OTodo::type() const { | 380 | QString OTodo::type() const { |
381 | return QString::fromLatin1("OTodo"); | 381 | return QString::fromLatin1("OTodo"); |
382 | } | 382 | } |
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index 6dd4c0e..765d5a9 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -1,382 +1,382 @@ | |||
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 | 15 | ||
16 | #include "otodo.h" | 16 | #include "otodo.h" |
17 | 17 | ||
18 | 18 | ||
19 | struct OTodo::OTodoData : public QShared { | 19 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | 20 | OTodoData() : QShared() { |
21 | }; | 21 | }; |
22 | 22 | ||
23 | QDate date; | 23 | QDate date; |
24 | bool isCompleted:1; | 24 | bool isCompleted:1; |
25 | bool hasDate:1; | 25 | bool hasDate:1; |
26 | int priority; | 26 | int priority; |
27 | QString desc; | 27 | QString desc; |
28 | QString sum; | 28 | QString sum; |
29 | QMap<QString, QString> extra; | 29 | QMap<QString, QString> extra; |
30 | ushort prog; | 30 | ushort prog; |
31 | bool hasAlarmDateTime :1; | 31 | bool hasAlarmDateTime :1; |
32 | QDateTime alarmDateTime; | 32 | QDateTime alarmDateTime; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | OTodo::OTodo(const OTodo &event ) | 35 | OTodo::OTodo(const OTodo &event ) |
36 | : OPimRecord( event ), data( event.data ) | 36 | : OPimRecord( event ), data( event.data ) |
37 | { | 37 | { |
38 | data->ref(); | 38 | data->ref(); |
39 | // qWarning("ref up"); | 39 | // qWarning("ref up"); |
40 | } | 40 | } |
41 | OTodo::~OTodo() { | 41 | OTodo::~OTodo() { |
42 | 42 | ||
43 | // qWarning("~OTodo " ); | 43 | // qWarning("~OTodo " ); |
44 | if ( data->deref() ) { | 44 | if ( data->deref() ) { |
45 | // qWarning("OTodo::dereffing"); | 45 | // qWarning("OTodo::dereffing"); |
46 | delete data; | 46 | delete data; |
47 | data = 0l; | 47 | data = 0l; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | OTodo::OTodo(bool completed, int priority, | 50 | OTodo::OTodo(bool completed, int priority, |
51 | const QArray<int> &category, | 51 | const QArray<int> &category, |
52 | const QString& summary, | 52 | const QString& summary, |
53 | const QString &description, | 53 | const QString &description, |
54 | ushort progress, | 54 | ushort progress, |
55 | bool hasDate, QDate date, int uid ) | 55 | bool hasDate, QDate date, int uid ) |
56 | : OPimRecord( uid ) | 56 | : OPimRecord( uid ) |
57 | { | 57 | { |
58 | // qWarning("OTodoData " + summary); | 58 | // qWarning("OTodoData " + summary); |
59 | setCategories( category ); | 59 | setCategories( category ); |
60 | 60 | ||
61 | data = new OTodoData; | 61 | data = new OTodoData; |
62 | 62 | ||
63 | data->date = date; | 63 | data->date = date; |
64 | data->isCompleted = completed; | 64 | data->isCompleted = completed; |
65 | data->hasDate = hasDate; | 65 | data->hasDate = hasDate; |
66 | data->priority = priority; | 66 | data->priority = priority; |
67 | data->sum = summary; | 67 | data->sum = summary; |
68 | data->prog = progress; | 68 | data->prog = progress; |
69 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 69 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
70 | data->hasAlarmDateTime = false; | 70 | data->hasAlarmDateTime = false; |
71 | 71 | ||
72 | } | 72 | } |
73 | OTodo::OTodo(bool completed, int priority, | 73 | OTodo::OTodo(bool completed, int priority, |
74 | const QStringList &category, | 74 | const QStringList &category, |
75 | const QString& summary, | 75 | const QString& summary, |
76 | const QString &description, | 76 | const QString &description, |
77 | ushort progress, | 77 | ushort progress, |
78 | bool hasDate, QDate date, int uid ) | 78 | bool hasDate, QDate date, int uid ) |
79 | : OPimRecord( uid ) | 79 | : OPimRecord( uid ) |
80 | { | 80 | { |
81 | // qWarning("OTodoData" + summary); | 81 | // qWarning("OTodoData" + summary); |
82 | setCategories( idsFromString( category.join(";") ) ); | 82 | setCategories( idsFromString( category.join(";") ) ); |
83 | 83 | ||
84 | data = new OTodoData; | 84 | data = new OTodoData; |
85 | 85 | ||
86 | data->date = date; | 86 | data->date = date; |
87 | data->isCompleted = completed; | 87 | data->isCompleted = completed; |
88 | data->hasDate = hasDate; | 88 | data->hasDate = hasDate; |
89 | data->priority = priority; | 89 | data->priority = priority; |
90 | data->sum = summary; | 90 | data->sum = summary; |
91 | data->prog = progress; | 91 | data->prog = progress; |
92 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 92 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
93 | data->hasAlarmDateTime = false; | 93 | data->hasAlarmDateTime = false; |
94 | 94 | ||
95 | } | 95 | } |
96 | bool OTodo::match( const QRegExp ®Exp )const | 96 | bool OTodo::match( const QRegExp ®Exp )const |
97 | { | 97 | { |
98 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 98 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
99 | return true; | 99 | return true; |
100 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 100 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
101 | return true; | 101 | return true; |
102 | }else if(data->desc.find( regExp ) != -1 ){ | 102 | }else if(data->desc.find( regExp ) != -1 ){ |
103 | return true; | 103 | return true; |
104 | }else if(data->sum.find( regExp ) != -1 ) { | 104 | }else if(data->sum.find( regExp ) != -1 ) { |
105 | return true; | 105 | return true; |
106 | } | 106 | } |
107 | return false; | 107 | return false; |
108 | } | 108 | } |
109 | bool OTodo::isCompleted() const | 109 | bool OTodo::isCompleted() const |
110 | { | 110 | { |
111 | return data->isCompleted; | 111 | return data->isCompleted; |
112 | } | 112 | } |
113 | bool OTodo::hasDueDate() const | 113 | bool OTodo::hasDueDate() const |
114 | { | 114 | { |
115 | return data->hasDate; | 115 | return data->hasDate; |
116 | } | 116 | } |
117 | bool OTodo::hasAlarmDateTime() const | 117 | bool OTodo::hasAlarmDateTime() const |
118 | { | 118 | { |
119 | return data->hasAlarmDateTime; | 119 | return data->hasAlarmDateTime; |
120 | } | 120 | } |
121 | int OTodo::priority()const | 121 | int OTodo::priority()const |
122 | { | 122 | { |
123 | return data->priority; | 123 | return data->priority; |
124 | } | 124 | } |
125 | QString OTodo::summary() const | 125 | QString OTodo::summary() const |
126 | { | 126 | { |
127 | return data->sum; | 127 | return data->sum; |
128 | } | 128 | } |
129 | ushort OTodo::progress() const | 129 | ushort OTodo::progress() const |
130 | { | 130 | { |
131 | return data->prog; | 131 | return data->prog; |
132 | } | 132 | } |
133 | QDate OTodo::dueDate()const | 133 | QDate OTodo::dueDate()const |
134 | { | 134 | { |
135 | return data->date; | 135 | return data->date; |
136 | } | 136 | } |
137 | 137 | ||
138 | QDateTime OTodo::alarmDateTime() const | 138 | QDateTime OTodo::alarmDateTime() const |
139 | { | 139 | { |
140 | return data->alarmDateTime; | 140 | return data->alarmDateTime; |
141 | } | 141 | } |
142 | 142 | ||
143 | QString OTodo::description()const | 143 | QString OTodo::description()const |
144 | { | 144 | { |
145 | return data->desc; | 145 | return data->desc; |
146 | } | 146 | } |
147 | void OTodo::setCompleted( bool completed ) | 147 | void OTodo::setCompleted( bool completed ) |
148 | { | 148 | { |
149 | changeOrModify(); | 149 | changeOrModify(); |
150 | data->isCompleted = completed; | 150 | data->isCompleted = completed; |
151 | } | 151 | } |
152 | void OTodo::setHasDueDate( bool hasDate ) | 152 | void OTodo::setHasDueDate( bool hasDate ) |
153 | { | 153 | { |
154 | changeOrModify(); | 154 | changeOrModify(); |
155 | data->hasDate = hasDate; | 155 | data->hasDate = hasDate; |
156 | } | 156 | } |
157 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) | 157 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) |
158 | { | 158 | { |
159 | changeOrModify(); | 159 | changeOrModify(); |
160 | data->hasAlarmDateTime = hasAlarmDateTime; | 160 | data->hasAlarmDateTime = hasAlarmDateTime; |
161 | } | 161 | } |
162 | void OTodo::setDescription(const QString &desc ) | 162 | void OTodo::setDescription(const QString &desc ) |
163 | { | 163 | { |
164 | // qWarning( "desc " + desc ); | 164 | // qWarning( "desc " + desc ); |
165 | changeOrModify(); | 165 | changeOrModify(); |
166 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 166 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
167 | } | 167 | } |
168 | void OTodo::setSummary( const QString& sum ) | 168 | void OTodo::setSummary( const QString& sum ) |
169 | { | 169 | { |
170 | changeOrModify(); | 170 | changeOrModify(); |
171 | data->sum = sum; | 171 | data->sum = sum; |
172 | } | 172 | } |
173 | void OTodo::setPriority(int prio ) | 173 | void OTodo::setPriority(int prio ) |
174 | { | 174 | { |
175 | changeOrModify(); | 175 | changeOrModify(); |
176 | data->priority = prio; | 176 | data->priority = prio; |
177 | } | 177 | } |
178 | void OTodo::setDueDate( QDate date ) | 178 | void OTodo::setDueDate( QDate date ) |
179 | { | 179 | { |
180 | changeOrModify(); | 180 | changeOrModify(); |
181 | data->date = date; | 181 | data->date = date; |
182 | } | 182 | } |
183 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) | 183 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) |
184 | { | 184 | { |
185 | changeOrModify(); | 185 | changeOrModify(); |
186 | data->alarmDateTime = alarm; | 186 | data->alarmDateTime = alarm; |
187 | } | 187 | } |
188 | bool OTodo::isOverdue( ) | 188 | bool OTodo::isOverdue( ) |
189 | { | 189 | { |
190 | if( data->hasDate ) | 190 | if( data->hasDate && !data->isCompleted) |
191 | return QDate::currentDate() > data->date; | 191 | return QDate::currentDate() > data->date; |
192 | return false; | 192 | return false; |
193 | } | 193 | } |
194 | void OTodo::setProgress(ushort progress ) | 194 | void OTodo::setProgress(ushort progress ) |
195 | { | 195 | { |
196 | changeOrModify(); | 196 | changeOrModify(); |
197 | data->prog = progress; | 197 | data->prog = progress; |
198 | } | 198 | } |
199 | QString OTodo::toShortText() const { | 199 | QString OTodo::toShortText() const { |
200 | return summary(); | 200 | return summary(); |
201 | } | 201 | } |
202 | /*! | 202 | /*! |
203 | Returns a richt text string | 203 | Returns a richt text string |
204 | */ | 204 | */ |
205 | QString OTodo::toRichText() const | 205 | QString OTodo::toRichText() const |
206 | { | 206 | { |
207 | QString text; | 207 | QString text; |
208 | QStringList catlist; | 208 | QStringList catlist; |
209 | 209 | ||
210 | // Description of the todo | 210 | // Description of the todo |
211 | if ( !summary().isEmpty() ) { | 211 | if ( !summary().isEmpty() ) { |
212 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | 212 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; |
213 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 213 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
214 | } | 214 | } |
215 | if( !description().isEmpty() ){ | 215 | if( !description().isEmpty() ){ |
216 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 216 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
217 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 217 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; |
218 | } | 218 | } |
219 | text += "<br><br><br>"; | 219 | text += "<br><br><br>"; |
220 | 220 | ||
221 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 221 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
222 | + QString::number( priority() ) + " <br>"; | 222 | + QString::number( priority() ) + " <br>"; |
223 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 223 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
224 | + QString::number( progress() ) + " %<br>"; | 224 | + QString::number( progress() ) + " %<br>"; |
225 | if (hasDueDate() ){ | 225 | if (hasDueDate() ){ |
226 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 226 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
227 | text += dueDate().toString(); | 227 | text += dueDate().toString(); |
228 | text += "<br>"; | 228 | text += "<br>"; |
229 | } | 229 | } |
230 | if (hasAlarmDateTime() ){ | 230 | if (hasAlarmDateTime() ){ |
231 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; | 231 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; |
232 | text += alarmDateTime().toString(); | 232 | text += alarmDateTime().toString(); |
233 | text += "<br>"; | 233 | text += "<br>"; |
234 | } | 234 | } |
235 | 235 | ||
236 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 236 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
237 | text += categoryNames().join(", "); | 237 | text += categoryNames().join(", "); |
238 | text += "<br>"; | 238 | text += "<br>"; |
239 | 239 | ||
240 | return text; | 240 | return text; |
241 | } | 241 | } |
242 | 242 | ||
243 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 243 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
244 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 244 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
245 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 245 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
246 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 246 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
247 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 247 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
248 | return priority() < toDoEvent.priority(); | 248 | return priority() < toDoEvent.priority(); |
249 | }else{ | 249 | }else{ |
250 | return dueDate() < toDoEvent.dueDate(); | 250 | return dueDate() < toDoEvent.dueDate(); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | return false; | 253 | return false; |
254 | } | 254 | } |
255 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 255 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
256 | { | 256 | { |
257 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 257 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
258 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 258 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
259 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 259 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
260 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 260 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
261 | return priority() <= toDoEvent.priority(); | 261 | return priority() <= toDoEvent.priority(); |
262 | }else{ | 262 | }else{ |
263 | return dueDate() <= toDoEvent.dueDate(); | 263 | return dueDate() <= toDoEvent.dueDate(); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | return true; | 266 | return true; |
267 | } | 267 | } |
268 | bool OTodo::operator>(const OTodo &toDoEvent )const | 268 | bool OTodo::operator>(const OTodo &toDoEvent )const |
269 | { | 269 | { |
270 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 270 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
271 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 271 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
272 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 272 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
273 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 273 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
274 | return priority() > toDoEvent.priority(); | 274 | return priority() > toDoEvent.priority(); |
275 | }else{ | 275 | }else{ |
276 | return dueDate() > toDoEvent.dueDate(); | 276 | return dueDate() > toDoEvent.dueDate(); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | return false; | 279 | return false; |
280 | } | 280 | } |
281 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 281 | bool OTodo::operator>=(const OTodo &toDoEvent )const |
282 | { | 282 | { |
283 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 283 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
284 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 284 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
285 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 285 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
286 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 286 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
287 | return priority() > toDoEvent.priority(); | 287 | return priority() > toDoEvent.priority(); |
288 | }else{ | 288 | }else{ |
289 | return dueDate() > toDoEvent.dueDate(); | 289 | return dueDate() > toDoEvent.dueDate(); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | return true; | 292 | return true; |
293 | } | 293 | } |
294 | bool OTodo::operator==(const OTodo &toDoEvent )const | 294 | bool OTodo::operator==(const OTodo &toDoEvent )const |
295 | { | 295 | { |
296 | if ( data->priority != toDoEvent.data->priority ) return false; | 296 | if ( data->priority != toDoEvent.data->priority ) return false; |
297 | if ( data->priority != toDoEvent.data->prog ) return false; | 297 | if ( data->priority != toDoEvent.data->prog ) return false; |
298 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; | 298 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; |
299 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; | 299 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; |
300 | if ( data->date != toDoEvent.data->date ) return false; | 300 | if ( data->date != toDoEvent.data->date ) return false; |
301 | if ( data->sum != toDoEvent.data->sum ) return false; | 301 | if ( data->sum != toDoEvent.data->sum ) return false; |
302 | if ( data->desc != toDoEvent.data->desc ) return false; | 302 | if ( data->desc != toDoEvent.data->desc ) return false; |
303 | if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) | 303 | if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) |
304 | return false; | 304 | return false; |
305 | if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) | 305 | if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) |
306 | return false; | 306 | return false; |
307 | 307 | ||
308 | return OPimRecord::operator==( toDoEvent ); | 308 | return OPimRecord::operator==( toDoEvent ); |
309 | } | 309 | } |
310 | void OTodo::deref() { | 310 | void OTodo::deref() { |
311 | 311 | ||
312 | // qWarning("deref in ToDoEvent"); | 312 | // qWarning("deref in ToDoEvent"); |
313 | if ( data->deref() ) { | 313 | if ( data->deref() ) { |
314 | // qWarning("deleting"); | 314 | // qWarning("deleting"); |
315 | delete data; | 315 | delete data; |
316 | data= 0; | 316 | data= 0; |
317 | } | 317 | } |
318 | } | 318 | } |
319 | OTodo &OTodo::operator=(const OTodo &item ) | 319 | OTodo &OTodo::operator=(const OTodo &item ) |
320 | { | 320 | { |
321 | OPimRecord::operator=( item ); | 321 | OPimRecord::operator=( item ); |
322 | //qWarning("operator= ref "); | 322 | //qWarning("operator= ref "); |
323 | item.data->ref(); | 323 | item.data->ref(); |
324 | deref(); | 324 | deref(); |
325 | data = item.data; | 325 | data = item.data; |
326 | 326 | ||
327 | return *this; | 327 | return *this; |
328 | } | 328 | } |
329 | 329 | ||
330 | QMap<int, QString> OTodo::toMap() const { | 330 | QMap<int, QString> OTodo::toMap() const { |
331 | QMap<int, QString> map; | 331 | QMap<int, QString> map; |
332 | 332 | ||
333 | map.insert( Uid, QString::number( uid() ) ); | 333 | map.insert( Uid, QString::number( uid() ) ); |
334 | map.insert( Category, idsToString( categories() ) ); | 334 | map.insert( Category, idsToString( categories() ) ); |
335 | map.insert( HasDate, QString::number( data->hasDate ) ); | 335 | map.insert( HasDate, QString::number( data->hasDate ) ); |
336 | map.insert( Completed, QString::number( data->isCompleted ) ); | 336 | map.insert( Completed, QString::number( data->isCompleted ) ); |
337 | map.insert( Description, data->desc ); | 337 | map.insert( Description, data->desc ); |
338 | map.insert( Summary, data->sum ); | 338 | map.insert( Summary, data->sum ); |
339 | map.insert( Priority, QString::number( data->priority ) ); | 339 | map.insert( Priority, QString::number( data->priority ) ); |
340 | map.insert( DateDay, QString::number( data->date.day() ) ); | 340 | map.insert( DateDay, QString::number( data->date.day() ) ); |
341 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 341 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
342 | map.insert( DateYear, QString::number( data->date.year() ) ); | 342 | map.insert( DateYear, QString::number( data->date.year() ) ); |
343 | map.insert( Progress, QString::number( data->prog ) ); | 343 | map.insert( Progress, QString::number( data->prog ) ); |
344 | map.insert( CrossReference, crossToString() ); | 344 | map.insert( CrossReference, crossToString() ); |
345 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); | 345 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); |
346 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); | 346 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); |
347 | 347 | ||
348 | return map; | 348 | return map; |
349 | } | 349 | } |
350 | 350 | ||
351 | QMap<QString, QString> OTodo::toExtraMap()const { | 351 | QMap<QString, QString> OTodo::toExtraMap()const { |
352 | return data->extra; | 352 | return data->extra; |
353 | } | 353 | } |
354 | /** | 354 | /** |
355 | * change or modify looks at the ref count and either | 355 | * change or modify looks at the ref count and either |
356 | * creates a new QShared Object or it can modify it | 356 | * creates a new QShared Object or it can modify it |
357 | * right in place | 357 | * right in place |
358 | */ | 358 | */ |
359 | void OTodo::changeOrModify() { | 359 | void OTodo::changeOrModify() { |
360 | if ( data->count != 1 ) { | 360 | if ( data->count != 1 ) { |
361 | // qWarning("changeOrModify"); | 361 | // qWarning("changeOrModify"); |
362 | data->deref(); | 362 | data->deref(); |
363 | OTodoData* d2 = new OTodoData(); | 363 | OTodoData* d2 = new OTodoData(); |
364 | copy(data, d2 ); | 364 | copy(data, d2 ); |
365 | data = d2; | 365 | data = d2; |
366 | } | 366 | } |
367 | } | 367 | } |
368 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 368 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
369 | dest->date = src->date; | 369 | dest->date = src->date; |
370 | dest->isCompleted = src->isCompleted; | 370 | dest->isCompleted = src->isCompleted; |
371 | dest->hasDate = src->hasDate; | 371 | dest->hasDate = src->hasDate; |
372 | dest->priority = src->priority; | 372 | dest->priority = src->priority; |
373 | dest->desc = src->desc; | 373 | dest->desc = src->desc; |
374 | dest->sum = src->sum; | 374 | dest->sum = src->sum; |
375 | dest->extra = src->extra; | 375 | dest->extra = src->extra; |
376 | dest->prog = src->prog; | 376 | dest->prog = src->prog; |
377 | dest->hasAlarmDateTime = src->hasAlarmDateTime; | 377 | dest->hasAlarmDateTime = src->hasAlarmDateTime; |
378 | dest->alarmDateTime = src->alarmDateTime; | 378 | dest->alarmDateTime = src->alarmDateTime; |
379 | } | 379 | } |
380 | QString OTodo::type() const { | 380 | QString OTodo::type() const { |
381 | return QString::fromLatin1("OTodo"); | 381 | return QString::fromLatin1("OTodo"); |
382 | } | 382 | } |