author | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
commit | f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf (patch) (unidiff) | |
tree | 4044006e676c78370fdeccf960ea4214f13eabd2 | |
parent | 2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb (diff) | |
download | opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.zip opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.gz opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.bz2 |
cosmetics
-rw-r--r-- | libopie2/opiepim/core/opimnotify.cpp | 251 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotify.h | 67 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 240 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.h | 40 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 141 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 66 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 749 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.h | 43 | ||||
-rw-r--r-- | libopie2/opiepim/ocontactfields.cpp | 496 | ||||
-rw-r--r-- | libopie2/opiepim/ocontactfields.h | 32 | ||||
-rw-r--r-- | libopie2/opiepim/oevent.cpp | 870 | ||||
-rw-r--r-- | libopie2/opiepim/oevent.h | 165 | ||||
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 230 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 602 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.h | 147 |
15 files changed, 2491 insertions, 1648 deletions
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp index c61f9da..43858f0 100644 --- a/libopie2/opiepim/core/opimnotify.cpp +++ b/libopie2/opiepim/core/opimnotify.cpp | |||
@@ -1,258 +1,379 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qshared.h> | ||
30 | 29 | ||
31 | #include <opie2/opimnotify.h> | 30 | #include "opimnotify.h" |
32 | 31 | ||
33 | namespace Opie { | 32 | /* QT */ |
33 | #include <qshared.h> | ||
34 | 34 | ||
35 | struct OPimNotify::Data : public QShared { | 35 | namespace Opie |
36 | Data() : QShared(),dur(-1),parent(0) { | 36 | { |
37 | 37 | ||
38 | struct OPimNotify::Data : public QShared | ||
39 | { | ||
40 | Data() : QShared(), dur( -1 ), parent( 0 ) | ||
41 | { | ||
38 | } | 42 | } |
39 | QDateTime start; | 43 | QDateTime start; |
40 | int dur; | 44 | int dur; |
41 | QString application; | 45 | QString application; |
42 | int parent; | 46 | int parent; |
43 | }; | 47 | }; |
44 | 48 | ||
45 | OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { | 49 | OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) |
50 | { | ||
46 | data = new Data; | 51 | data = new Data; |
47 | data->start = start; | 52 | data->start = start; |
48 | data->dur = duration; | 53 | data->dur = duration; |
49 | data->parent = parent; | 54 | data->parent = parent; |
50 | } | 55 | } |
51 | OPimNotify::OPimNotify( const OPimNotify& noti) | 56 | |
52 | : data( noti.data ) | 57 | |
58 | OPimNotify::OPimNotify( const OPimNotify& noti ) | ||
59 | : data( noti.data ) | ||
53 | { | 60 | { |
54 | data->ref(); | 61 | data->ref(); |
55 | } | 62 | } |
56 | OPimNotify::~OPimNotify() { | 63 | |
57 | if ( data->deref() ) { | 64 | |
65 | OPimNotify::~OPimNotify() | ||
66 | { | ||
67 | if ( data->deref() ) | ||
68 | { | ||
58 | delete data; | 69 | delete data; |
59 | data = 0l; | 70 | data = 0l; |
60 | } | 71 | } |
61 | } | 72 | } |
62 | 73 | ||
63 | OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { | 74 | |
75 | OPimNotify &OPimNotify::operator=( const OPimNotify& noti ) | ||
76 | { | ||
64 | noti.data->ref(); | 77 | noti.data->ref(); |
65 | deref(); | 78 | deref(); |
66 | data = noti.data; | 79 | data = noti.data; |
67 | 80 | ||
68 | return *this; | 81 | return *this; |
69 | } | 82 | } |
70 | bool OPimNotify::operator==( const OPimNotify& noti ) { | 83 | |
84 | |||
85 | bool OPimNotify::operator==( const OPimNotify& noti ) | ||
86 | { | ||
71 | if ( data == noti.data ) return true; | 87 | if ( data == noti.data ) return true; |
72 | if ( data->dur != noti.data->dur ) return false; | 88 | if ( data->dur != noti.data->dur ) return false; |
73 | if ( data->parent != noti.data->parent ) return false; | 89 | if ( data->parent != noti.data->parent ) return false; |
74 | if ( data->application != noti.data->application ) return false; | 90 | if ( data->application != noti.data->application ) return false; |
75 | if ( data->start != noti.data->start ) return false; | 91 | if ( data->start != noti.data->start ) return false; |
76 | 92 | ||
77 | return true; | 93 | return true; |
78 | } | 94 | } |
79 | QDateTime OPimNotify::dateTime()const { | 95 | |
96 | |||
97 | QDateTime OPimNotify::dateTime() const | ||
98 | { | ||
80 | return data->start; | 99 | return data->start; |
81 | } | 100 | } |
82 | QString OPimNotify::service()const { | 101 | |
102 | |||
103 | QString OPimNotify::service() const | ||
104 | { | ||
83 | return data->application; | 105 | return data->application; |
84 | } | 106 | } |
85 | int OPimNotify::parent()const { | 107 | |
108 | |||
109 | int OPimNotify::parent() const | ||
110 | { | ||
86 | return data->parent; | 111 | return data->parent; |
87 | } | 112 | } |
88 | int OPimNotify::duration()const { | 113 | |
114 | |||
115 | int OPimNotify::duration() const | ||
116 | { | ||
89 | return data->dur; | 117 | return data->dur; |
90 | } | 118 | } |
91 | QDateTime OPimNotify::endTime()const { | 119 | |
92 | return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) ); | 120 | |
121 | QDateTime OPimNotify::endTime() const | ||
122 | { | ||
123 | return QDateTime( data->start.date(), data->start.time().addSecs( data->dur ) ); | ||
93 | } | 124 | } |
94 | void OPimNotify::setDateTime( const QDateTime& time ) { | 125 | |
126 | |||
127 | void OPimNotify::setDateTime( const QDateTime& time ) | ||
128 | { | ||
95 | copyIntern(); | 129 | copyIntern(); |
96 | data->start = time; | 130 | data->start = time; |
97 | } | 131 | } |
98 | void OPimNotify::setDuration( int dur ) { | 132 | |
133 | |||
134 | void OPimNotify::setDuration( int dur ) | ||
135 | { | ||
99 | copyIntern(); | 136 | copyIntern(); |
100 | data->dur = dur; | 137 | data->dur = dur; |
101 | } | 138 | } |
102 | void OPimNotify::setParent( int uid ) { | 139 | |
140 | |||
141 | void OPimNotify::setParent( int uid ) | ||
142 | { | ||
103 | copyIntern(); | 143 | copyIntern(); |
104 | data->parent = uid; | 144 | data->parent = uid; |
105 | } | 145 | } |
106 | void OPimNotify::setService( const QString& str ) { | 146 | |
147 | |||
148 | void OPimNotify::setService( const QString& str ) | ||
149 | { | ||
107 | copyIntern(); | 150 | copyIntern(); |
108 | data->application = str; | 151 | data->application = str; |
109 | } | 152 | } |
110 | void OPimNotify::copyIntern() { | 153 | |
111 | if ( data->count != 1 ) { | 154 | |
155 | void OPimNotify::copyIntern() | ||
156 | { | ||
157 | if ( data->count != 1 ) | ||
158 | { | ||
112 | data->deref(); | 159 | data->deref(); |
113 | Data* dat = new Data; | 160 | Data* dat = new Data; |
114 | dat->start = data->start; | 161 | dat->start = data->start; |
115 | dat->dur = data->dur; | 162 | dat->dur = data->dur; |
116 | dat->application = data->application; | 163 | dat->application = data->application; |
117 | dat->parent = data->parent; | 164 | dat->parent = data->parent; |
118 | data = dat; | 165 | data = dat; |
119 | } | 166 | } |
120 | } | 167 | } |
121 | void OPimNotify::deref() { | 168 | |
122 | if ( data->deref() ) { | 169 | |
170 | void OPimNotify::deref() | ||
171 | { | ||
172 | if ( data->deref() ) | ||
173 | { | ||
123 | delete data; | 174 | delete data; |
124 | data = 0; | 175 | data = 0; |
125 | } | 176 | } |
126 | } | 177 | } |
127 | 178 | ||
179 | |||
128 | /***********************************************************/ | 180 | /***********************************************************/ |
129 | struct OPimAlarm::Data : public QShared { | 181 | struct OPimAlarm::Data : public QShared |
130 | Data() : QShared() { | 182 | { |
183 | Data() : QShared() | ||
184 | { | ||
131 | sound = 1; | 185 | sound = 1; |
132 | } | 186 | } |
133 | int sound; | 187 | int sound; |
134 | QString file; | 188 | QString file; |
135 | }; | 189 | }; |
190 | |||
191 | |||
136 | OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) | 192 | OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) |
137 | : OPimNotify( start, duration, parent ) | 193 | : OPimNotify( start, duration, parent ) |
138 | { | 194 | { |
139 | data = new Data; | 195 | data = new Data; |
140 | data->sound = sound; | 196 | data->sound = sound; |
141 | } | 197 | } |
142 | OPimAlarm::OPimAlarm( const OPimAlarm& al) | 198 | |
143 | : OPimNotify(al), data( al.data ) | 199 | |
200 | OPimAlarm::OPimAlarm( const OPimAlarm& al ) | ||
201 | : OPimNotify( al ), data( al.data ) | ||
144 | { | 202 | { |
145 | data->ref(); | 203 | data->ref(); |
146 | } | 204 | } |
147 | OPimAlarm::~OPimAlarm() { | 205 | |
148 | if ( data->deref() ) { | 206 | |
207 | OPimAlarm::~OPimAlarm() | ||
208 | { | ||
209 | if ( data->deref() ) | ||
210 | { | ||
149 | delete data; | 211 | delete data; |
150 | data = 0l; | 212 | data = 0l; |
151 | } | 213 | } |
152 | } | 214 | } |
153 | OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) | 215 | |
216 | |||
217 | OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al ) | ||
154 | { | 218 | { |
155 | OPimNotify::operator=( al ); | 219 | OPimNotify::operator=( al ); |
156 | deref(); | 220 | deref(); |
157 | al.data->ref(); | 221 | al.data->ref(); |
158 | 222 | ||
159 | data = al.data; | 223 | data = al.data; |
160 | 224 | ||
161 | 225 | ||
162 | return *this; | 226 | return *this; |
163 | } | 227 | } |
164 | bool OPimAlarm::operator==( const OPimAlarm& al) { | 228 | |
229 | |||
230 | bool OPimAlarm::operator==( const OPimAlarm& al ) | ||
231 | { | ||
165 | if ( data->sound != al.data->sound ) return false; | 232 | if ( data->sound != al.data->sound ) return false; |
166 | else if ( data->sound == Custom && data->file != al.data->file ) | 233 | else if ( data->sound == Custom && data->file != al.data->file ) |
167 | return false; | 234 | return false; |
168 | 235 | ||
169 | return OPimNotify::operator==( al ); | 236 | return OPimNotify::operator==( al ); |
170 | } | 237 | } |
171 | QString OPimAlarm::type()const { | 238 | |
172 | return QString::fromLatin1("OPimAlarm"); | 239 | |
240 | QString OPimAlarm::type() const | ||
241 | { | ||
242 | return QString::fromLatin1( "OPimAlarm" ); | ||
173 | } | 243 | } |
174 | int OPimAlarm::sound()const { | 244 | |
245 | |||
246 | int OPimAlarm::sound() const | ||
247 | { | ||
175 | return data->sound; | 248 | return data->sound; |
176 | } | 249 | } |
177 | QString OPimAlarm::file()const { | 250 | |
251 | |||
252 | QString OPimAlarm::file() const | ||
253 | { | ||
178 | return data->file; | 254 | return data->file; |
179 | } | 255 | } |
180 | void OPimAlarm::setSound( int snd) { | 256 | |
257 | |||
258 | void OPimAlarm::setSound( int snd ) | ||
259 | { | ||
181 | copyIntern(); | 260 | copyIntern(); |
182 | data->sound = snd; | 261 | data->sound = snd; |
183 | } | 262 | } |
184 | void OPimAlarm::setFile( const QString& sound ) { | 263 | |
264 | |||
265 | void OPimAlarm::setFile( const QString& sound ) | ||
266 | { | ||
185 | copyIntern(); | 267 | copyIntern(); |
186 | data->file = sound; | 268 | data->file = sound; |
187 | } | 269 | } |
188 | void OPimAlarm::deref() { | 270 | |
189 | if ( data->deref() ) { | 271 | |
272 | void OPimAlarm::deref() | ||
273 | { | ||
274 | if ( data->deref() ) | ||
275 | { | ||
190 | delete data; | 276 | delete data; |
191 | data = 0l; | 277 | data = 0l; |
192 | } | 278 | } |
193 | } | 279 | } |
194 | void OPimAlarm::copyIntern() { | 280 | |
195 | if ( data->count != 1 ) { | 281 | |
282 | void OPimAlarm::copyIntern() | ||
283 | { | ||
284 | if ( data->count != 1 ) | ||
285 | { | ||
196 | data->deref(); | 286 | data->deref(); |
197 | Data *newDat = new Data; | 287 | Data *newDat = new Data; |
198 | newDat->sound = data->sound; | 288 | newDat->sound = data->sound; |
199 | newDat->file = data->file; | 289 | newDat->file = data->file; |
200 | data = newDat; | 290 | data = newDat; |
201 | } | 291 | } |
202 | } | 292 | } |
293 | |||
294 | |||
203 | /************************/ | 295 | /************************/ |
204 | struct OPimReminder::Data : public QShared { | 296 | struct OPimReminder::Data : public QShared |
205 | Data() : QShared(), record( 0) { | 297 | { |
206 | } | 298 | Data() : QShared(), record( 0 ) |
299 | {} | ||
207 | int record; | 300 | int record; |
208 | 301 | ||
209 | }; | 302 | }; |
210 | OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) | 303 | |
211 | : OPimNotify( start, dur, parent ) | 304 | |
305 | OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) | ||
306 | : OPimNotify( start, dur, parent ) | ||
212 | { | 307 | { |
213 | data = new Data; | 308 | data = new Data; |
214 | data->record = uid; | 309 | data->record = uid; |
215 | } | 310 | } |
311 | |||
312 | |||
216 | OPimReminder::OPimReminder( const OPimReminder& rem ) | 313 | OPimReminder::OPimReminder( const OPimReminder& rem ) |
217 | : OPimNotify( rem ), data( rem.data ) | 314 | : OPimNotify( rem ), data( rem.data ) |
218 | { | 315 | { |
219 | data->ref(); | 316 | data->ref(); |
220 | } | 317 | } |
221 | OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { | 318 | |
222 | OPimNotify::operator=(rem ); | 319 | |
320 | OPimReminder& OPimReminder::operator=( const OPimReminder& rem ) | ||
321 | { | ||
322 | OPimNotify::operator=( rem ); | ||
223 | 323 | ||
224 | deref(); | 324 | deref(); |
225 | rem.data->ref(); | 325 | rem.data->ref(); |
226 | data = rem.data; | 326 | data = rem.data; |
227 | 327 | ||
228 | return *this; | 328 | return *this; |
229 | } | 329 | } |
230 | bool OPimReminder::operator==( const OPimReminder& rem) { | 330 | |
331 | |||
332 | bool OPimReminder::operator==( const OPimReminder& rem ) | ||
333 | { | ||
231 | if ( data->record != rem.data->record ) return false; | 334 | if ( data->record != rem.data->record ) return false; |
232 | 335 | ||
233 | return OPimNotify::operator==( rem ); | 336 | return OPimNotify::operator==( rem ); |
234 | } | 337 | } |
235 | QString OPimReminder::type()const { | 338 | |
236 | return QString::fromLatin1("OPimReminder"); | 339 | |
340 | QString OPimReminder::type() const | ||
341 | { | ||
342 | return QString::fromLatin1( "OPimReminder" ); | ||
237 | } | 343 | } |
238 | int OPimReminder::recordUid()const { | 344 | |
345 | |||
346 | int OPimReminder::recordUid() const | ||
347 | { | ||
239 | return data->record; | 348 | return data->record; |
240 | } | 349 | } |
241 | void OPimReminder::setRecordUid( int uid ) { | 350 | |
351 | |||
352 | void OPimReminder::setRecordUid( int uid ) | ||
353 | { | ||
242 | copyIntern(); | 354 | copyIntern(); |
243 | data->record = uid; | 355 | data->record = uid; |
244 | } | 356 | } |
245 | void OPimReminder::deref() { | 357 | |
246 | if ( data->deref() ) { | 358 | |
359 | void OPimReminder::deref() | ||
360 | { | ||
361 | if ( data->deref() ) | ||
362 | { | ||
247 | delete data; | 363 | delete data; |
248 | data = 0l; | 364 | data = 0l; |
249 | } | 365 | } |
250 | } | 366 | } |
251 | void OPimReminder::copyIntern() { | 367 | |
252 | if ( data->count != 1 ) { | 368 | |
253 | Data* da = new Data; | 369 | void OPimReminder::copyIntern() |
370 | { | ||
371 | if ( data->count != 1 ) | ||
372 | { | ||
373 | Data * da = new Data; | ||
254 | da->record = data->record; | 374 | da->record = data->record; |
255 | data = da; | 375 | data = da; |
256 | } | 376 | } |
257 | } | 377 | } |
378 | |||
258 | } | 379 | } |
diff --git a/libopie2/opiepim/core/opimnotify.h b/libopie2/opiepim/core/opimnotify.h index fed3970..d0e40ca 100644 --- a/libopie2/opiepim/core/opimnotify.h +++ b/libopie2/opiepim/core/opimnotify.h | |||
@@ -1,176 +1,181 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_NOTIFY_H | ||
30 | #define OPIE_PIM_NOTIFY_H | ||
31 | 29 | ||
30 | #ifndef OPIMNOTIFY_H | ||
31 | #define OPIMNOTIFY_H | ||
32 | |||
33 | /* QT */ | ||
32 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
33 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
34 | 36 | ||
35 | 37 | namespace Opie | |
36 | namespace Opie { | 38 | { |
37 | /** | 39 | /** |
38 | * This is the base class of Notifiers. Possible | 40 | * This is the base class of Notifiers. Possible |
39 | * notifiers would be Alarms, Reminders | 41 | * notifiers would be Alarms, Reminders |
40 | * What they share is that they have | 42 | * What they share is that they have |
41 | * A DateTime, Type, Duration | 43 | * A DateTime, Type, Duration |
42 | * This is what this base class takes care of | 44 | * This is what this base class takes care of |
43 | * on top of that it's shared | 45 | * on top of that it's shared |
44 | */ | 46 | */ |
45 | /* | 47 | /* |
46 | * TALK to eilers: have a class OPimDuration which sets the Duration | 48 | * TALK to eilers: have a class OPimDuration which sets the Duration |
47 | * given on the Due/Start Date? -zecke | 49 | * given on the Due/Start Date? -zecke |
48 | * discuss: do we need a uid for the notify? -zecke | 50 | * discuss: do we need a uid for the notify? -zecke |
49 | */ | 51 | */ |
50 | class OPimNotify { | 52 | class OPimNotify |
51 | public: | 53 | { |
54 | |||
55 | public: | ||
52 | typedef QValueList<OPimNotify> ValueList; | 56 | typedef QValueList<OPimNotify> ValueList; |
53 | OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); | 57 | OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); |
54 | OPimNotify( const OPimNotify& ); | 58 | OPimNotify( const OPimNotify& ); |
55 | virtual ~OPimNotify(); | 59 | virtual ~OPimNotify(); |
56 | 60 | ||
57 | OPimNotify &operator=(const OPimNotify& ); | 61 | OPimNotify &operator=( const OPimNotify& ); |
58 | bool operator==( const OPimNotify& ); | 62 | bool operator==( const OPimNotify& ); |
59 | 63 | ||
60 | virtual QString type()const = 0; | 64 | virtual QString type() const = 0; |
61 | 65 | ||
62 | /** start date */ | 66 | /** start date */ |
63 | QDateTime dateTime()const; | 67 | QDateTime dateTime() const; |
64 | QString service()const; | 68 | QString service() const; |
65 | 69 | ||
66 | /** | 70 | /** |
67 | * RETURN the parent uid | 71 | * RETURN the parent uid |
68 | */ | 72 | */ |
69 | int parent()const; | 73 | int parent() const; |
70 | 74 | ||
71 | /** | 75 | /** |
72 | * in Seconds | 76 | * in Seconds |
73 | */ | 77 | */ |
74 | int duration()const; | 78 | int duration() const; |
75 | 79 | ||
76 | /** | 80 | /** |
77 | * Start Time + Duration | 81 | * Start Time + Duration |
78 | */ | 82 | */ |
79 | QDateTime endTime()const; | 83 | QDateTime endTime() const; |
80 | 84 | ||
81 | void setDateTime( const QDateTime& ); | 85 | void setDateTime( const QDateTime& ); |
82 | void setDuration( int dur ); | 86 | void setDuration( int dur ); |
83 | void setParent(int uid ); | 87 | void setParent( int uid ); |
84 | void setService( const QString& ); | 88 | void setService( const QString& ); |
85 | 89 | ||
86 | 90 | ||
87 | private: | 91 | private: |
88 | inline void copyIntern(); | 92 | inline void copyIntern(); |
89 | void deref(); | 93 | void deref(); |
90 | struct Data; | 94 | struct Data; |
91 | Data* data; | 95 | Data* data; |
92 | 96 | ||
93 | /* d-pointer */ | 97 | /* d-pointer */ |
94 | class NotifyPrivate; | 98 | class NotifyPrivate; |
95 | NotifyPrivate* d; | 99 | NotifyPrivate* d; |
96 | 100 | ||
97 | }; | 101 | }; |
98 | /** | 102 | /** |
99 | * An alarm is a sound/mail/buzzer played/send | 103 | * An alarm is a sound/mail/buzzer played/send |
100 | * at a given time to inform about | 104 | * at a given time to inform about |
101 | * an Event | 105 | * an Event |
102 | */ | 106 | */ |
103 | class OPimAlarm : public OPimNotify { | 107 | class OPimAlarm : public OPimNotify |
104 | public: | 108 | { |
105 | enum Sound{Loud=1, Silent=0, Custom=2 }; | 109 | public: |
110 | enum Sound{Loud = 1, Silent = 0, Custom = 2 }; | ||
106 | OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); | 111 | OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); |
107 | OPimAlarm( const OPimAlarm& ); | 112 | OPimAlarm( const OPimAlarm& ); |
108 | ~OPimAlarm(); | 113 | ~OPimAlarm(); |
109 | 114 | ||
110 | OPimAlarm &operator=( const OPimAlarm& ); | 115 | OPimAlarm &operator=( const OPimAlarm& ); |
111 | bool operator==( const OPimAlarm& ); | 116 | bool operator==( const OPimAlarm& ); |
112 | QString type()const; | 117 | QString type() const; |
113 | 118 | ||
114 | int sound()const; | 119 | int sound() const; |
115 | QString file()const; | 120 | QString file() const; |
116 | 121 | ||
117 | void setSound( int ); | 122 | void setSound( int ); |
118 | /* only when sound is custom... */ | 123 | /* only when sound is custom... */ |
119 | void setFile( const QString& sound ); | 124 | void setFile( const QString& sound ); |
120 | 125 | ||
121 | private: | 126 | private: |
122 | void deref(); | 127 | void deref(); |
123 | void copyIntern(); | 128 | void copyIntern(); |
124 | struct Data; | 129 | struct Data; |
125 | Data * data; | 130 | Data * data; |
126 | 131 | ||
127 | class Private; | 132 | class Private; |
128 | Private* d; | 133 | Private* d; |
129 | 134 | ||
130 | }; | 135 | }; |
131 | 136 | ||
132 | /** | 137 | /** |
133 | * A Reminder will be put into the | 138 | * A Reminder will be put into the |
134 | * datebook | 139 | * datebook |
135 | * Note that the returned dateTime() may be not valid. | 140 | * Note that the returned dateTime() may be not valid. |
136 | * In these cases one must resolve the uid and get the OEvent | 141 | * In these cases one must resolve the uid and get the OEvent |
137 | */ | 142 | */ |
138 | class OPimReminder : public OPimNotify { | 143 | class OPimReminder : public OPimNotify |
139 | public: | 144 | { |
140 | 145 | public: | |
141 | /** | 146 | /** |
142 | * c'tor of a reminder | 147 | * c'tor of a reminder |
143 | * @param uid The uid of the Record inside the Datebook | 148 | * @param uid The uid of the Record inside the Datebook |
144 | * @param start the StartDate invalid for all day... | 149 | * @param start the StartDate invalid for all day... |
145 | * @param duration The duration of the event ( -1 for all day ) | 150 | * @param duration The duration of the event ( -1 for all day ) |
146 | * @param parent The 'parent' record of this reminder | 151 | * @param parent The 'parent' record of this reminder |
147 | */ | 152 | */ |
148 | OPimReminder( int uid = 0, const QDateTime& start = QDateTime(), | 153 | OPimReminder( int uid = 0, const QDateTime& start = QDateTime(), |
149 | int duration = 0, int parent = 0 ); | 154 | int duration = 0, int parent = 0 ); |
150 | OPimReminder( const OPimReminder& ); | 155 | OPimReminder( const OPimReminder& ); |
151 | OPimReminder &operator=(const OPimReminder& ); | 156 | OPimReminder &operator=( const OPimReminder& ); |
152 | 157 | ||
153 | QString type()const; | 158 | QString type() const; |
154 | 159 | ||
155 | bool operator==( const OPimReminder& ); | 160 | bool operator==( const OPimReminder& ); |
156 | 161 | ||
157 | /** | 162 | /** |
158 | * the uid of the alarm | 163 | * the uid of the alarm |
159 | * inside the 'datebook' application | 164 | * inside the 'datebook' application |
160 | */ | 165 | */ |
161 | int recordUid()const; | 166 | int recordUid() const; |
162 | void setRecordUid( int uid ); | 167 | void setRecordUid( int uid ); |
163 | 168 | ||
164 | private: | 169 | private: |
165 | void deref(); | 170 | void deref(); |
166 | void copyIntern(); | 171 | void copyIntern(); |
167 | 172 | ||
168 | struct Data; | 173 | struct Data; |
169 | Data* data; | 174 | Data* data; |
170 | class Private; | 175 | class Private; |
171 | Private *d; | 176 | Private *d; |
172 | }; | 177 | }; |
173 | 178 | ||
174 | } | 179 | } |
175 | 180 | ||
176 | #endif | 181 | #endif |
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 1771fad..a54d597 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp | |||
@@ -1,193 +1,249 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <opie2/opimnotifymanager.h> | ||
30 | 29 | ||
30 | #include "opimnotifymanager.h" | ||
31 | |||
32 | /* OPIE */ | ||
31 | #include <opie2/oconversion.h> | 33 | #include <opie2/oconversion.h> |
32 | 34 | ||
35 | /* QT */ | ||
33 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
34 | 37 | ||
35 | namespace Opie { | 38 | namespace Opie |
39 | { | ||
36 | 40 | ||
37 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) | 41 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al ) |
38 | : m_rem( rem ), m_al( al ) | 42 | : m_rem( rem ), m_al( al ) |
39 | {} | 43 | {} |
40 | OPimNotifyManager::~OPimNotifyManager() { | 44 | |
41 | } | 45 | |
46 | OPimNotifyManager::~OPimNotifyManager() | ||
47 | {} | ||
48 | |||
49 | |||
42 | /* use static_cast and type instead of dynamic... */ | 50 | /* use static_cast and type instead of dynamic... */ |
43 | void OPimNotifyManager::add( const OPimNotify& noti) { | 51 | void OPimNotifyManager::add( const OPimNotify& noti ) |
44 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 52 | { |
45 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 53 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) |
54 | { | ||
55 | const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); | ||
46 | m_rem.append( rem ); | 56 | m_rem.append( rem ); |
47 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 57 | } |
48 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 58 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) |
59 | { | ||
60 | const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); | ||
49 | m_al.append( al ); | 61 | m_al.append( al ); |
50 | } | 62 | } |
51 | } | 63 | } |
52 | void OPimNotifyManager::remove( const OPimNotify& noti) { | 64 | |
53 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 65 | |
54 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 66 | void OPimNotifyManager::remove( const OPimNotify& noti ) |
67 | { | ||
68 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) | ||
69 | { | ||
70 | const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); | ||
55 | m_rem.remove( rem ); | 71 | m_rem.remove( rem ); |
56 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 72 | } |
57 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 73 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) |
74 | { | ||
75 | const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); | ||
58 | m_al.remove( al ); | 76 | m_al.remove( al ); |
59 | } | 77 | } |
60 | } | 78 | } |
61 | void OPimNotifyManager::replace( const OPimNotify& noti) { | 79 | |
62 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 80 | |
63 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 81 | void OPimNotifyManager::replace( const OPimNotify& noti ) |
82 | { | ||
83 | if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) | ||
84 | { | ||
85 | const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); | ||
64 | m_rem.remove( rem ); | 86 | m_rem.remove( rem ); |
65 | m_rem.append( rem ); | 87 | m_rem.append( rem ); |
66 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 88 | } |
67 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 89 | else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) |
90 | { | ||
91 | const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); | ||
68 | m_al.remove( al ); | 92 | m_al.remove( al ); |
69 | m_al.append( al ); | 93 | m_al.append( al ); |
70 | } | 94 | } |
71 | } | 95 | } |
72 | OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { | 96 | |
97 | |||
98 | OPimNotifyManager::Reminders OPimNotifyManager::reminders() const | ||
99 | { | ||
73 | return m_rem; | 100 | return m_rem; |
74 | } | 101 | } |
75 | OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { | 102 | |
103 | |||
104 | OPimNotifyManager::Alarms OPimNotifyManager::alarms() const | ||
105 | { | ||
76 | return m_al; | 106 | return m_al; |
77 | } | 107 | } |
78 | OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const { | ||
79 | Alarms::ConstIterator it; | ||
80 | found = true; | ||
81 | 108 | ||
82 | for ( it = m_al.begin(); it != m_al.end(); ++it ){ | ||
83 | if ( (*it).dateTime() == when ) | ||
84 | return (*it); | ||
85 | } | ||
86 | 109 | ||
87 | // Fall through if nothing could be found | 110 | OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const |
88 | found = false; | 111 | { |
89 | OPimAlarm empty; | 112 | Alarms::ConstIterator it; |
90 | return empty; | 113 | found = true; |
114 | |||
115 | for ( it = m_al.begin(); it != m_al.end(); ++it ) | ||
116 | { | ||
117 | if ( ( *it ).dateTime() == when ) | ||
118 | return ( *it ); | ||
119 | } | ||
120 | |||
121 | // Fall through if nothing could be found | ||
122 | found = false; | ||
123 | OPimAlarm empty; | ||
124 | return empty; | ||
91 | } | 125 | } |
92 | 126 | ||
93 | 127 | ||
94 | void OPimNotifyManager::setAlarms( const Alarms& al) { | 128 | void OPimNotifyManager::setAlarms( const Alarms& al ) |
129 | { | ||
95 | m_al = al; | 130 | m_al = al; |
96 | } | 131 | } |
97 | void OPimNotifyManager::setReminders( const Reminders& rem) { | 132 | |
133 | |||
134 | void OPimNotifyManager::setReminders( const Reminders& rem ) | ||
135 | { | ||
98 | m_rem = rem; | 136 | m_rem = rem; |
99 | } | 137 | } |
138 | |||
139 | |||
100 | /* FIXME!!! */ | 140 | /* FIXME!!! */ |
101 | /** | 141 | /** |
102 | * The idea is to check if the provider for our service | 142 | * The idea is to check if the provider for our service |
103 | * is online | 143 | * is online |
104 | * if it is we will use QCOP | 144 | * if it is we will use QCOP |
105 | * if not the Factory to get the backend... | 145 | * if not the Factory to get the backend... |
106 | * Qtopia1.6 services would be kewl to have here.... | 146 | * Qtopia1.6 services would be kewl to have here.... |
107 | */ | 147 | */ |
108 | void OPimNotifyManager::registerNotify( const OPimNotify& ) { | 148 | void OPimNotifyManager::registerNotify( const OPimNotify& ) |
109 | 149 | { | |
110 | } | 150 | } |
151 | |||
152 | |||
111 | /* FIXME!!! */ | 153 | /* FIXME!!! */ |
112 | /** | 154 | /** |
113 | * same as above... | 155 | * same as above... |
114 | * Also implement Url model | 156 | * Also implement Url model |
115 | * have a MainWindow.... | 157 | * have a MainWindow.... |
116 | */ | 158 | */ |
117 | void OPimNotifyManager::deregister( const OPimNotify& ) { | 159 | void OPimNotifyManager::deregister( const OPimNotify& ) |
118 | 160 | { | |
119 | } | 161 | } |
120 | 162 | ||
121 | bool OPimNotifyManager::isEmpty()const { | 163 | |
122 | qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); | 164 | bool OPimNotifyManager::isEmpty() const |
165 | { | ||
166 | qWarning( "is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); | ||
123 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; | 167 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; |
124 | else return false; | 168 | else return false; |
125 | } | 169 | } |
126 | 170 | ||
127 | // Taken from otodoaccessxml.. | 171 | |
172 | // Taken from otodoaccessxml.. code duplication bad. any alternative? | ||
128 | QString OPimNotifyManager::alarmsToString() const | 173 | QString OPimNotifyManager::alarmsToString() const |
129 | { | 174 | { |
130 | QString str; | 175 | QString str; |
131 | 176 | ||
132 | OPimNotifyManager::Alarms alarms = m_al; | 177 | OPimNotifyManager::Alarms alarms = m_al; |
133 | if ( !alarms.isEmpty() ) { | 178 | if ( !alarms.isEmpty() ) |
134 | QStringList als; | 179 | { |
135 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | 180 | QStringList als; |
136 | for ( ; it != alarms.end(); ++it ) { | 181 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); |
137 | /* only if time is valid */ | 182 | for ( ; it != alarms.end(); ++it ) |
138 | if ( (*it).dateTime().isValid() ) { | 183 | { |
139 | als << OConversion::dateTimeToString( (*it).dateTime() ) | 184 | /* only if time is valid */ |
140 | + ":" + QString::number( (*it).duration() ) | 185 | if ( ( *it ).dateTime().isValid() ) |
141 | + ":" + QString::number( (*it).sound() ) | 186 | { |
142 | + ":"; | 187 | als << OConversion::dateTimeToString( ( *it ).dateTime() ) |
143 | } | 188 | + ":" + QString::number( ( *it ).duration() ) |
144 | } | 189 | + ":" + QString::number( ( *it ).sound() ) |
145 | // now write the list | 190 | + ":"; |
146 | qWarning("als: %s", als.join("____________").latin1() ); | 191 | } |
147 | str = als.join(";"); | 192 | } |
148 | } | 193 | // now write the list |
149 | 194 | qWarning( "als: %s", als.join( "____________" ).latin1() ); | |
150 | return str; | 195 | str = als.join( ";" ); |
196 | } | ||
197 | |||
198 | return str; | ||
151 | } | 199 | } |
200 | |||
201 | |||
152 | QString OPimNotifyManager::remindersToString() const | 202 | QString OPimNotifyManager::remindersToString() const |
153 | { | 203 | { |
154 | QString str; | 204 | QString str; |
155 | 205 | ||
156 | OPimNotifyManager::Reminders reminders = m_rem; | 206 | OPimNotifyManager::Reminders reminders = m_rem; |
157 | if (!reminders.isEmpty() ) { | 207 | if ( !reminders.isEmpty() ) |
158 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | 208 | { |
159 | QStringList records; | 209 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); |
160 | for ( ; it != reminders.end(); ++it ) { | 210 | QStringList records; |
161 | records << QString::number( (*it).recordUid() ); | 211 | for ( ; it != reminders.end(); ++it ) |
162 | } | 212 | { |
163 | str = records.join(";"); | 213 | records << QString::number( ( *it ).recordUid() ); |
164 | } | 214 | } |
215 | str = records.join( ";" ); | ||
216 | } | ||
165 | 217 | ||
166 | return str; | 218 | return str; |
167 | } | 219 | } |
168 | 220 | ||
221 | |||
169 | void OPimNotifyManager::alarmsFromString( const QString& str ) | 222 | void OPimNotifyManager::alarmsFromString( const QString& str ) |
170 | { | 223 | { |
171 | QStringList als = QStringList::split(";", str ); | 224 | QStringList als = QStringList::split( ";", str ); |
172 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | 225 | for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) |
173 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | 226 | { |
174 | qWarning("alarm: %s", alarm.join("___").latin1() ); | 227 | QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty |
175 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), | 228 | qWarning( "alarm: %s", alarm.join( "___" ).latin1() ); |
176 | OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); | 229 | qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(), |
177 | OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), | 230 | OConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() ); |
178 | alarm[1].toInt() ); | 231 | OPimAlarm al( alarm[ 2 ].toInt(), OConversion::dateTimeFromString( alarm[ 0 ] ), |
179 | add( al ); | 232 | alarm[ 1 ].toInt() ); |
180 | } | 233 | add( al ); |
234 | } | ||
181 | } | 235 | } |
182 | 236 | ||
237 | |||
183 | void OPimNotifyManager::remindersFromString( const QString& str ) | 238 | void OPimNotifyManager::remindersFromString( const QString& str ) |
184 | { | 239 | { |
185 | 240 | ||
186 | QStringList rems = QStringList::split(";", str ); | 241 | QStringList rems = QStringList::split( ";", str ); |
187 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | 242 | for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) |
188 | OPimReminder rem( (*it).toInt() ); | 243 | { |
189 | add( rem ); | 244 | OPimReminder rem( ( *it ).toInt() ); |
190 | } | 245 | add( rem ); |
191 | 246 | } | |
247 | |||
192 | } | 248 | } |
193 | } | 249 | } |
diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h index 0272e5d..9241ea2 100644 --- a/libopie2/opiepim/core/opimnotifymanager.h +++ b/libopie2/opiepim/core/opimnotifymanager.h | |||
@@ -1,122 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_NOTIFY_MANAGER_H | 29 | #ifndef OPIMNOTIFYMANAGER_H |
30 | #define OPIE_PIM_NOTIFY_MANAGER_H | 30 | #define OPIMNOTIFYMANAGER_H |
31 | |||
32 | #include <qvaluelist.h> | ||
33 | 31 | ||
32 | /* OPIE */ | ||
34 | #include <opie2/opimnotify.h> | 33 | #include <opie2/opimnotify.h> |
35 | 34 | ||
36 | namespace Opie { | 35 | /* QT */ |
36 | #include <qvaluelist.h> | ||
37 | |||
38 | namespace Opie | ||
39 | { | ||
37 | /** | 40 | /** |
38 | * The notify manager keeps track of the Notifiers.... | 41 | * The notify manager keeps track of the Notifiers.... |
39 | */ | 42 | */ |
40 | class OPimNotifyManager { | 43 | class OPimNotifyManager |
41 | public: | 44 | { |
45 | public: | ||
42 | typedef QValueList<OPimReminder> Reminders; | 46 | typedef QValueList<OPimReminder> Reminders; |
43 | typedef QValueList<OPimAlarm> Alarms; | 47 | typedef QValueList<OPimAlarm> Alarms; |
44 | OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() ); | 48 | OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() ); |
45 | ~OPimNotifyManager(); | 49 | ~OPimNotifyManager(); |
46 | 50 | ||
47 | /* we will cast it for you ;) */ | 51 | /* we will cast it for you ;) */ |
48 | void add( const OPimNotify& ); | 52 | void add( const OPimNotify& ); |
49 | void remove( const OPimNotify& ); | 53 | void remove( const OPimNotify& ); |
50 | /* replaces all with this one! */ | 54 | /* replaces all with this one! */ |
51 | void replace( const OPimNotify& ); | 55 | void replace( const OPimNotify& ); |
52 | 56 | ||
53 | Reminders reminders()const; | 57 | Reminders reminders() const; |
54 | 58 | ||
55 | /** | 59 | /** |
56 | * Return | 60 | * Return |
57 | */ | 61 | */ |
58 | Alarms alarms()const; | 62 | Alarms alarms() const; |
59 | 63 | ||
60 | /** | 64 | /** |
61 | * Return alarm at DateTime "when". If more than one is registered at this | 65 | * Return alarm at DateTime "when". If more than one is registered at this |
62 | * DateTime, the first one is returned. | 66 | * DateTime, the first one is returned. |
63 | * If none was found, an empty Alarm is returned. | 67 | * If none was found, an empty Alarm is returned. |
64 | * @param when The date and time of the returned alarm | 68 | * @param when The date and time of the returned alarm |
65 | * @param found Returns true if anything was found. | 69 | * @param found Returns true if anything was found. |
66 | * @return Returns the found alarm at given DateTime. It is empty if found is false | 70 | * @return Returns the found alarm at given DateTime. It is empty if found is false |
67 | * (nothing could be found at given date and time) | 71 | * (nothing could be found at given date and time) |
68 | */ | 72 | */ |
69 | OPimAlarm alarmAtDateTime( const QDateTime& when, bool& found ) const; | 73 | OPimAlarm alarmAtDateTime( const QDateTime& when, bool& found ) const; |
70 | 74 | ||
71 | void setAlarms( const Alarms& ); | 75 | void setAlarms( const Alarms& ); |
72 | void setReminders( const Reminders& ); | 76 | void setReminders( const Reminders& ); |
73 | 77 | ||
74 | /* register is a Ansi C keyword... */ | 78 | /* register is a Ansi C keyword... */ |
75 | /** | 79 | /** |
76 | * This function will register the Notify to the Alarm Server | 80 | * This function will register the Notify to the Alarm Server |
77 | * or datebook depending on the type of the notify | 81 | * or datebook depending on the type of the notify |
78 | */ | 82 | */ |
79 | void registerNotify( const OPimNotify& ); | 83 | void registerNotify( const OPimNotify& ); |
80 | 84 | ||
81 | /** | 85 | /** |
82 | * this will do the opposite.. | 86 | * this will do the opposite.. |
83 | */ | 87 | */ |
84 | void deregister( const OPimNotify& ); | 88 | void deregister( const OPimNotify& ); |
85 | 89 | ||
86 | bool isEmpty()const; | 90 | bool isEmpty() const; |
87 | 91 | ||
88 | /** | 92 | /** |
89 | * Return all alarms as string | 93 | * Return all alarms as string |
90 | */ | 94 | */ |
91 | QString alarmsToString() const; | 95 | QString alarmsToString() const; |
92 | /** | 96 | /** |
93 | * Return all notifiers as string | 97 | * Return all notifiers as string |
94 | */ | 98 | */ |
95 | QString remindersToString() const; | 99 | QString remindersToString() const; |
96 | 100 | ||
97 | /** | 101 | /** |
98 | * Convert string to alarms | 102 | * Convert string to alarms |
99 | * @param str String created by alarmsToString() | 103 | * @param str String created by alarmsToString() |
100 | */ | 104 | */ |
101 | void alarmsFromString( const QString& str ); | 105 | void alarmsFromString( const QString& str ); |
102 | 106 | ||
103 | /** | 107 | /** |
104 | * Convert string to reminders | 108 | * Convert string to reminders |
105 | * @param str String created by remindersToString() | 109 | * @param str String created by remindersToString() |
106 | */ | 110 | */ |
107 | void remindersFromString( const QString& str ); | 111 | void remindersFromString( const QString& str ); |
108 | 112 | ||
109 | 113 | private: | |
110 | |||
111 | private: | ||
112 | Reminders m_rem; | 114 | Reminders m_rem; |
113 | Alarms m_al; | 115 | Alarms m_al; |
114 | 116 | ||
115 | class Private; | 117 | class Private; |
116 | Private *d; | 118 | Private *d; |
117 | 119 | ||
118 | }; | 120 | }; |
119 | 121 | ||
120 | } | 122 | } |
121 | 123 | ||
122 | #endif | 124 | #endif |
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 72bb372..c603f44 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -1,213 +1,274 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qarray.h> | ||
30 | 29 | ||
30 | #include "opimrecord.h" | ||
31 | |||
32 | /* OPIE */ | ||
31 | #include <qpe/categories.h> | 33 | #include <qpe/categories.h> |
32 | #include <qpe/categoryselect.h> | 34 | #include <qpe/categoryselect.h> |
33 | 35 | ||
34 | #include <opie2/opimrecord.h> | 36 | /* QT */ |
37 | #include <qarray.h> | ||
35 | 38 | ||
36 | namespace Opie { | 39 | namespace Opie |
40 | { | ||
37 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); | 41 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); |
38 | 42 | ||
39 | 43 | ||
40 | OPimRecord::OPimRecord( int uid ) | 44 | OPimRecord::OPimRecord( int uid ) |
41 | : Qtopia::Record() { | 45 | : Qtopia::Record() |
46 | { | ||
42 | 47 | ||
43 | m_lastHit = -1; | 48 | m_lastHit = -1; |
44 | setUid( uid ); | 49 | setUid( uid ); |
45 | } | 50 | } |
46 | OPimRecord::~OPimRecord() { | 51 | |
47 | } | 52 | |
53 | OPimRecord::~OPimRecord() | ||
54 | {} | ||
55 | |||
56 | |||
48 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 57 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
49 | : Qtopia::Record( rec ) | 58 | : Qtopia::Record( rec ) |
50 | { | 59 | { |
51 | (*this) = rec; | 60 | ( *this ) = rec; |
52 | } | 61 | } |
53 | 62 | ||
54 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 63 | |
55 | if ( this == &rec ) return *this; | 64 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec ) |
65 | { | ||
66 | if ( this == &rec ) return * this; | ||
56 | 67 | ||
57 | Qtopia::Record::operator=( rec ); | 68 | Qtopia::Record::operator=( rec ); |
58 | m_xrefman = rec.m_xrefman; | 69 | m_xrefman = rec.m_xrefman; |
59 | m_lastHit = rec.m_lastHit; | 70 | m_lastHit = rec.m_lastHit; |
60 | 71 | ||
61 | return *this; | 72 | return *this; |
62 | } | 73 | } |
74 | |||
75 | |||
63 | /* | 76 | /* |
64 | * category names | 77 | * category names |
65 | */ | 78 | */ |
66 | QStringList OPimRecord::categoryNames( const QString& appname ) const { | 79 | QStringList OPimRecord::categoryNames( const QString& appname ) const |
80 | { | ||
67 | QStringList list; | 81 | QStringList list; |
68 | QArray<int> cats = categories(); | 82 | QArray<int> cats = categories(); |
69 | Categories catDB; | 83 | Categories catDB; |
70 | catDB.load( categoryFileName() ); | 84 | catDB.load( categoryFileName() ); |
71 | 85 | ||
72 | for (uint i = 0; i < cats.count(); i++ ) { | 86 | for ( uint i = 0; i < cats.count(); i++ ) |
73 | list << catDB.label( appname, cats[i] ); | 87 | { |
88 | list << catDB.label( appname, cats[ i ] ); | ||
74 | } | 89 | } |
75 | 90 | ||
76 | return list; | 91 | return list; |
77 | } | 92 | } |
78 | void OPimRecord::setCategoryNames( const QStringList& ) { | ||
79 | 93 | ||
94 | |||
95 | void OPimRecord::setCategoryNames( const QStringList& ) | ||
96 | { | ||
80 | } | 97 | } |
81 | void OPimRecord::addCategoryName( const QString& ) { | 98 | |
99 | |||
100 | void OPimRecord::addCategoryName( const QString& ) | ||
101 | { | ||
82 | Categories catDB; | 102 | Categories catDB; |
83 | catDB.load( categoryFileName() ); | 103 | catDB.load( categoryFileName() ); |
84 | 104 | ||
85 | 105 | ||
86 | } | 106 | } |
87 | bool OPimRecord::isEmpty()const { | 107 | |
108 | |||
109 | bool OPimRecord::isEmpty() const | ||
110 | { | ||
88 | return ( uid() == 0 ); | 111 | return ( uid() == 0 ); |
89 | } | 112 | } |
113 | |||
114 | |||
90 | /*QString OPimRecord::crossToString()const { | 115 | /*QString OPimRecord::crossToString()const { |
91 | QString str; | 116 | QString str; |
92 | QMap<QString, QArray<int> >::ConstIterator it; | 117 | QMap<QString, QArray<int> >::ConstIterator it; |
93 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | 118 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { |
94 | QArray<int> id = it.data(); | 119 | QArray<int> id = it.data(); |
95 | for ( uint i = 0; i < id.size(); ++i ) { | 120 | for ( uint i = 0; i < id.size(); ++i ) { |
96 | str += it.key() + "," + QString::number( i ) + ";"; | 121 | str += it.key() + "," + QString::number( i ) + ";"; |
97 | } | 122 | } |
98 | } | 123 | } |
99 | str = str.remove( str.length()-1, 1); // strip the ; | 124 | str = str.remove( str.length()-1, 1); // strip the ; |
100 | //qWarning("IDS " + str ); | 125 | //qWarning("IDS " + str ); |
101 | 126 | ||
102 | return str; | 127 | return str; |
103 | }*/ | 128 | }*/ |
104 | /* if uid = 1 assign a new one */ | 129 | /* if uid = 1 assign a new one */ |
105 | void OPimRecord::setUid( int uid ) { | 130 | void OPimRecord::setUid( int uid ) |
106 | if ( uid == 1) | 131 | { |
132 | if ( uid == 1 ) | ||
107 | uid = uidGen().generate(); | 133 | uid = uidGen().generate(); |
108 | 134 | ||
109 | Qtopia::Record::setUid( uid ); | 135 | Qtopia::Record::setUid( uid ); |
110 | }; | 136 | }; |
111 | Qtopia::UidGen &OPimRecord::uidGen() { | 137 | |
138 | |||
139 | Qtopia::UidGen &OPimRecord::uidGen() | ||
140 | { | ||
112 | return m_uidGen; | 141 | return m_uidGen; |
113 | } | 142 | } |
114 | OPimXRefManager &OPimRecord::xrefmanager() { | 143 | |
144 | |||
145 | OPimXRefManager &OPimRecord::xrefmanager() | ||
146 | { | ||
115 | return m_xrefman; | 147 | return m_xrefman; |
116 | } | 148 | } |
117 | int OPimRecord::rtti(){ | 149 | |
150 | |||
151 | int OPimRecord::rtti() | ||
152 | { | ||
118 | return 0; | 153 | return 0; |
119 | } | 154 | } |
120 | 155 | ||
121 | /** | 156 | /** |
122 | * now let's put our data into the stream | 157 | * now let's put our data into the stream |
123 | */ | 158 | */ |
124 | /* | 159 | /* |
125 | * First read UID | 160 | * First read UID |
126 | * Categories | 161 | * Categories |
127 | * XRef | 162 | * XRef |
128 | */ | 163 | */ |
129 | bool OPimRecord::loadFromStream( QDataStream& stream ) { | 164 | bool OPimRecord::loadFromStream( QDataStream& stream ) |
165 | { | ||
130 | int Int; | 166 | int Int; |
131 | uint UInt; | 167 | uint UInt; |
132 | stream >> Int; | 168 | stream >> Int; |
133 | setUid(Int); | 169 | setUid( Int ); |
134 | 170 | ||
135 | /** Categories */ | 171 | /** Categories */ |
136 | stream >> UInt; | 172 | stream >> UInt; |
137 | QArray<int> array(UInt); | 173 | QArray<int> array( UInt ); |
138 | for (uint i = 0; i < UInt; i++ ) { | 174 | for ( uint i = 0; i < UInt; i++ ) |
139 | stream >> array[i]; | 175 | { |
176 | stream >> array[ i ]; | ||
140 | } | 177 | } |
141 | setCategories( array ); | 178 | setCategories( array ); |
142 | 179 | ||
143 | /* | 180 | /* |
144 | * now we do the X-Ref stuff | 181 | * now we do the X-Ref stuff |
145 | */ | 182 | */ |
146 | OPimXRef xref; | 183 | OPimXRef xref; |
147 | stream >> UInt; | 184 | stream >> UInt; |
148 | for ( uint i = 0; i < UInt; i++ ) { | 185 | for ( uint i = 0; i < UInt; i++ ) |
186 | { | ||
149 | xref.setPartner( OPimXRef::One, partner( stream ) ); | 187 | xref.setPartner( OPimXRef::One, partner( stream ) ); |
150 | xref.setPartner( OPimXRef::Two, partner( stream ) ); | 188 | xref.setPartner( OPimXRef::Two, partner( stream ) ); |
151 | m_xrefman.add( xref ); | 189 | m_xrefman.add( xref ); |
152 | } | 190 | } |
153 | 191 | ||
154 | return true; | 192 | return true; |
155 | } | 193 | } |
156 | bool OPimRecord::saveToStream( QDataStream& stream )const { | 194 | |
195 | |||
196 | bool OPimRecord::saveToStream( QDataStream& stream ) const | ||
197 | { | ||
157 | /** UIDs */ | 198 | /** UIDs */ |
158 | 199 | ||
159 | stream << uid(); | 200 | stream << uid(); |
160 | 201 | ||
161 | /** Categories */ | 202 | /** Categories */ |
162 | stream << categories().count(); | 203 | stream << categories().count(); |
163 | for ( uint i = 0; i < categories().count(); i++ ) { | 204 | for ( uint i = 0; i < categories().count(); i++ ) |
164 | stream << categories()[i]; | 205 | { |
206 | stream << categories() [ i ]; | ||
165 | } | 207 | } |
166 | 208 | ||
167 | /* | 209 | /* |
168 | * first the XRef count | 210 | * first the XRef count |
169 | * then the xrefs | 211 | * then the xrefs |
170 | */ | 212 | */ |
171 | stream << m_xrefman.list().count(); | 213 | stream << m_xrefman.list().count(); |
172 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); | 214 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); |
173 | it != m_xrefman.list().end(); ++it ) { | 215 | it != m_xrefman.list().end(); ++it ) |
174 | flush( (*it).partner( OPimXRef::One), stream ); | 216 | { |
175 | flush( (*it).partner( OPimXRef::Two), stream ); | 217 | flush( ( *it ).partner( OPimXRef::One ), stream ); |
218 | flush( ( *it ).partner( OPimXRef::Two ), stream ); | ||
176 | } | 219 | } |
177 | return true; | 220 | return true; |
178 | } | 221 | } |
179 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ | 222 | |
223 | |||
224 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const | ||
225 | { | ||
180 | str << par.service(); | 226 | str << par.service(); |
181 | str << par.uid(); | 227 | str << par.uid(); |
182 | str << par.field(); | 228 | str << par.field(); |
183 | } | 229 | } |
184 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { | 230 | |
231 | |||
232 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) | ||
233 | { | ||
185 | OPimXRefPartner par; | 234 | OPimXRefPartner par; |
186 | QString str; | 235 | QString str; |
187 | int i; | 236 | int i; |
188 | 237 | ||
189 | stream >> str; | 238 | stream >> str; |
190 | par.setService( str ); | 239 | par.setService( str ); |
191 | 240 | ||
192 | stream >> i; | 241 | stream >> i; |
193 | par.setUid( i ); | 242 | par.setUid( i ); |
194 | 243 | ||
195 | stream >> i ; | 244 | stream >> i ; |
196 | par.setField( i ); | 245 | par.setField( i ); |
197 | 246 | ||
198 | return par; | 247 | return par; |
199 | } | 248 | } |
200 | void OPimRecord::setLastHitField( int lastHit )const { | 249 | |
250 | |||
251 | void OPimRecord::setLastHitField( int lastHit ) const | ||
252 | { | ||
201 | m_lastHit = lastHit; | 253 | m_lastHit = lastHit; |
202 | } | 254 | } |
203 | int OPimRecord::lastHitField()const{ | 255 | |
256 | |||
257 | int OPimRecord::lastHitField() const | ||
258 | { | ||
204 | return m_lastHit; | 259 | return m_lastHit; |
205 | } | 260 | } |
206 | QMap<QString, QString> OPimRecord::toExtraMap()const { | 261 | |
262 | |||
263 | QMap<QString, QString> OPimRecord::toExtraMap() const | ||
264 | { | ||
207 | return customMap; | 265 | return customMap; |
208 | } | 266 | } |
209 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { | 267 | |
268 | |||
269 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map ) | ||
270 | { | ||
210 | customMap = map; | 271 | customMap = map; |
211 | } | 272 | } |
212 | 273 | ||
213 | } | 274 | } |
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index 63a3a98..4981a41 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h | |||
@@ -1,187 +1,193 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_RECORD_H | ||
30 | #define OPIE_PIM_RECORD_H | ||
31 | 29 | ||
32 | #include <qdatastream.h> | 30 | #ifndef OPIMRECORD_H |
33 | #include <qmap.h> | 31 | #define OPIMRECORD_H |
34 | #include <qstring.h> | ||
35 | #include <qstringlist.h> | ||
36 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <opie2/opimxrefmanager.h> | ||
37 | /* | 35 | /* |
38 | * we need to get customMap which is private... | 36 | * we need to get customMap which is private... |
39 | */ | 37 | */ |
40 | #define private protected | 38 | #define private protected |
41 | #include <qpe/palmtoprecord.h> | 39 | #include <qpe/palmtoprecord.h> |
42 | #undef private | 40 | #undef private |
43 | 41 | ||
44 | #include <opie2/opimxrefmanager.h> | 42 | /* QT */ |
43 | #include <qdatastream.h> | ||
44 | #include <qmap.h> | ||
45 | #include <qstring.h> | ||
46 | #include <qstringlist.h> | ||
45 | 47 | ||
46 | namespace Opie { | 48 | namespace Opie |
49 | { | ||
47 | /** | 50 | /** |
48 | * This is the base class for | 51 | * This is the base class for |
49 | * all PIM Records | 52 | * all PIM Records |
50 | * | 53 | * |
51 | */ | 54 | */ |
52 | class OPimRecord : public Qtopia::Record { | 55 | class OPimRecord : public Qtopia::Record |
53 | public: | 56 | { |
57 | public: | ||
54 | /** | 58 | /** |
55 | * c'tor | 59 | * c'tor |
56 | * uid of 0 isEmpty | 60 | * uid of 0 isEmpty |
57 | * uid of 1 will be assigned a new one | 61 | * uid of 1 will be assigned a new one |
58 | */ | 62 | */ |
59 | OPimRecord(int uid = 0); | 63 | OPimRecord( int uid = 0 ); |
60 | ~OPimRecord(); | 64 | ~OPimRecord(); |
61 | 65 | ||
62 | /** | 66 | /** |
63 | * copy c'tor | 67 | * copy c'tor |
64 | */ | 68 | */ |
65 | OPimRecord( const OPimRecord& rec ); | 69 | OPimRecord( const OPimRecord& rec ); |
66 | 70 | ||
67 | /** | 71 | /** |
68 | * copy operator | 72 | * copy operator |
69 | */ | 73 | */ |
70 | OPimRecord &operator=( const OPimRecord& ); | 74 | OPimRecord &operator=( const OPimRecord& ); |
71 | 75 | ||
72 | /** | 76 | /** |
73 | * category names resolved | 77 | * category names resolved |
74 | */ | 78 | */ |
75 | QStringList categoryNames( const QString& appname )const; | 79 | QStringList categoryNames( const QString& appname ) const; |
76 | 80 | ||
77 | /** | 81 | /** |
78 | * set category names they will be resolved | 82 | * set category names they will be resolved |
79 | */ | 83 | */ |
80 | void setCategoryNames( const QStringList& ); | 84 | void setCategoryNames( const QStringList& ); |
81 | 85 | ||
82 | /** | 86 | /** |
83 | * addCategoryName adds a name | 87 | * addCategoryName adds a name |
84 | * to the internal category list | 88 | * to the internal category list |
85 | */ | 89 | */ |
86 | void addCategoryName( const QString& ); | 90 | void addCategoryName( const QString& ); |
87 | 91 | ||
88 | /** | 92 | /** |
89 | * if a Record isEmpty | 93 | * if a Record isEmpty |
90 | * it's empty if it's 0 | 94 | * it's empty if it's 0 |
91 | */ | 95 | */ |
92 | virtual bool isEmpty()const; | 96 | virtual bool isEmpty() const; |
93 | 97 | ||
94 | /** | 98 | /** |
95 | * toRichText summary | 99 | * toRichText summary |
96 | */ | 100 | */ |
97 | virtual QString toRichText()const = 0; | 101 | virtual QString toRichText() const = 0; |
98 | 102 | ||
99 | /** | 103 | /** |
100 | * a small one line summary | 104 | * a small one line summary |
101 | */ | 105 | */ |
102 | virtual QString toShortText()const = 0; | 106 | virtual QString toShortText() const = 0; |
103 | 107 | ||
104 | /** | 108 | /** |
105 | * the name of the Record | 109 | * the name of the Record |
106 | */ | 110 | */ |
107 | virtual QString type()const = 0; | 111 | virtual QString type() const = 0; |
108 | 112 | ||
109 | /** | 113 | /** |
110 | * matches the Records the regular expression? | 114 | * matches the Records the regular expression? |
111 | */ | 115 | */ |
112 | virtual bool match( const QString ®exp ) const | 116 | virtual bool match( const QString ®exp ) const |
113 | {setLastHitField( -1 ); | 117 | { |
114 | return Qtopia::Record::match(QRegExp(regexp));}; | 118 | setLastHitField( -1 ); |
119 | return Qtopia::Record::match( QRegExp( regexp ) ); | ||
120 | }; | ||
115 | 121 | ||
116 | /** | 122 | /** |
117 | * if implemented this function returns which item has been | 123 | * if implemented this function returns which item has been |
118 | * last hit by the match() function. | 124 | * last hit by the match() function. |
119 | * or -1 if not implemented or no hit has occured | 125 | * or -1 if not implemented or no hit has occured |
120 | */ | 126 | */ |
121 | int lastHitField()const; | 127 | int lastHitField() const; |
122 | 128 | ||
123 | /** | 129 | /** |
124 | * converts the internal structure to a map | 130 | * converts the internal structure to a map |
125 | */ | 131 | */ |
126 | virtual QMap<int, QString> toMap()const = 0; | 132 | virtual QMap<int, QString> toMap() const = 0; |
127 | // virtual fromMap( const <int, QString>& map ) = 0; // Should be added in the future (eilers) | 133 | // virtual fromMap( const <int, QString>& map ) = 0; // Should be added in the future (eilers) |
128 | 134 | ||
129 | /** | 135 | /** |
130 | * key value representation of extra items | 136 | * key value representation of extra items |
131 | */ | 137 | */ |
132 | QMap<QString, QString> toExtraMap()const; | 138 | QMap<QString, QString> toExtraMap() const; |
133 | void setExtraMap( const QMap<QString, QString>& ); | 139 | void setExtraMap( const QMap<QString, QString>& ); |
134 | 140 | ||
135 | /** | 141 | /** |
136 | * the name for a recordField | 142 | * the name for a recordField |
137 | */ | 143 | */ |
138 | virtual QString recordField(int)const = 0; | 144 | virtual QString recordField( int ) const = 0; |
139 | 145 | ||
140 | /** | 146 | /** |
141 | * returns a reference of the | 147 | * returns a reference of the |
142 | * Cross Reference Manager | 148 | * Cross Reference Manager |
143 | * Partner 'One' is THIS PIM RECORD! | 149 | * Partner 'One' is THIS PIM RECORD! |
144 | * 'Two' is the Partner where we link to | 150 | * 'Two' is the Partner where we link to |
145 | */ | 151 | */ |
146 | OPimXRefManager& xrefmanager(); | 152 | OPimXRefManager& xrefmanager(); |
147 | 153 | ||
148 | /** | 154 | /** |
149 | * set the uid | 155 | * set the uid |
150 | */ | 156 | */ |
151 | virtual void setUid( int uid ); | 157 | virtual void setUid( int uid ); |
152 | 158 | ||
153 | /* | 159 | /* |
154 | * used inside the Templates for casting | 160 | * used inside the Templates for casting |
155 | * REIMPLEMENT in your .... | 161 | * REIMPLEMENT in your .... |
156 | */ | 162 | */ |
157 | static int rtti(); | 163 | static int rtti(); |
158 | 164 | ||
159 | /** | 165 | /** |
160 | * some marshalling and de marshalling code | 166 | * some marshalling and de marshalling code |
161 | * saves the OPimRecord | 167 | * saves the OPimRecord |
162 | * to and from a DataStream | 168 | * to and from a DataStream |
163 | */ | 169 | */ |
164 | virtual bool loadFromStream(QDataStream& ); | 170 | virtual bool loadFromStream( QDataStream& ); |
165 | virtual bool saveToStream( QDataStream& stream )const; | 171 | virtual bool saveToStream( QDataStream& stream ) const; |
166 | 172 | ||
167 | protected: | 173 | protected: |
168 | // need to be const cause it is called from const methods | 174 | // need to be const cause it is called from const methods |
169 | mutable int m_lastHit; | 175 | mutable int m_lastHit; |
170 | void setLastHitField( int lastHit )const; | 176 | void setLastHitField( int lastHit ) const; |
171 | Qtopia::UidGen &uidGen(); | 177 | Qtopia::UidGen &uidGen(); |
172 | // QString crossToString()const; | 178 | // QString crossToString()const; |
173 | 179 | ||
174 | private: | 180 | private: |
175 | class OPimRecordPrivate; | 181 | class OPimRecordPrivate; |
176 | OPimRecordPrivate *d; | 182 | OPimRecordPrivate *d; |
177 | OPimXRefManager m_xrefman; | 183 | OPimXRefManager m_xrefman; |
178 | static Qtopia::UidGen m_uidGen; | 184 | static Qtopia::UidGen m_uidGen; |
179 | 185 | ||
180 | private: | 186 | private: |
181 | void flush( const OPimXRefPartner&, QDataStream& stream )const; | 187 | void flush( const OPimXRefPartner&, QDataStream& stream ) const; |
182 | OPimXRefPartner partner( QDataStream& ); | 188 | OPimXRefPartner partner( QDataStream& ); |
183 | }; | 189 | }; |
184 | 190 | ||
185 | } | 191 | } |
186 | 192 | ||
187 | #endif | 193 | #endif |
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index f1a22a7..fa5313f 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -1,245 +1,228 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | /********************************************************************** | ||
31 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
32 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) | ||
33 | ** | ||
34 | ** This file may be distributed and/or modified under the terms of the | ||
35 | ** GNU General Public License version 2 as published by the Free Software | ||
36 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
37 | ** packaging of this file. | ||
38 | ** | ||
39 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
40 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
41 | ** | ||
42 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
43 | ** | ||
44 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
45 | ** not clear to you. | ||
46 | ** | ||
47 | **********************************************************************/ | ||
48 | |||
49 | #define QTOPIA_INTERNAL_CONTACT_MRE | 30 | #define QTOPIA_INTERNAL_CONTACT_MRE |
50 | 31 | ||
51 | #include <opie2/ocontact.h> | 32 | #include "ocontact.h" |
33 | |||
34 | /* OPIE */ | ||
52 | #include <opie2/opimresolver.h> | 35 | #include <opie2/opimresolver.h> |
53 | #include <opie2/oconversion.h> | 36 | #include <opie2/oconversion.h> |
54 | |||
55 | #include <qpe/stringutil.h> | 37 | #include <qpe/stringutil.h> |
56 | #include <qpe/timestring.h> | 38 | #include <qpe/timestring.h> |
57 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
58 | 40 | ||
41 | /* QT */ | ||
59 | #include <qobject.h> | 42 | #include <qobject.h> |
60 | #include <qregexp.h> | 43 | #include <qregexp.h> |
61 | #include <qstylesheet.h> | 44 | #include <qstylesheet.h> |
62 | #include <qfileinfo.h> | 45 | #include <qfileinfo.h> |
63 | #include <qmap.h> | 46 | #include <qmap.h> |
64 | 47 | ||
48 | /* STD */ | ||
65 | #include <stdio.h> | 49 | #include <stdio.h> |
66 | 50 | ||
67 | /*! | 51 | /*! |
68 | \class Contact contact.h | 52 | \class Contact contact.h |
69 | \brief The Contact class holds the data of an address book entry. | 53 | \brief The Contact class holds the data of an address book entry. |
70 | 54 | ||
71 | This data includes information the name of the person, contact | 55 | This data includes information the name of the person, contact |
72 | information, and business information such as deparment and job title. | 56 | information, and business information such as deparment and job title. |
73 | 57 | ||
74 | \ingroup qtopiaemb | 58 | \ingroup qtopiaemb |
75 | \ingroup qtopiadesktop | 59 | \ingroup qtopiadesktop |
76 | */ | 60 | */ |
77 | 61 | ||
78 | 62 | ||
79 | namespace Opie { | 63 | namespace Opie |
64 | { | ||
80 | /*! | 65 | /*! |
81 | Creates a new, empty contact. | 66 | Creates a new, empty contact. |
82 | */ | 67 | */ |
83 | OContact::OContact() | 68 | OContact::OContact():OPimRecord(), mMap(), d( 0 ) |
84 | : OPimRecord(), mMap(), d( 0 ) | 69 | {} |
85 | { | ||
86 | } | ||
87 | 70 | ||
88 | /*! | 71 | /*! |
89 | \internal | 72 | \internal |
90 | Creates a new contact. The properties of the contact are | 73 | Creates a new contact. The properties of the contact are |
91 | set from \a fromMap. | 74 | set from \a fromMap. |
92 | */ | 75 | */ |
93 | OContact::OContact( const QMap<int, QString> &fromMap ) : | 76 | OContact::OContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) |
94 | OPimRecord(), mMap( fromMap ), d( 0 ) | ||
95 | { | 77 | { |
96 | QString cats = mMap[ Qtopia::AddressCategory ]; | 78 | QString cats = mMap[ Qtopia::AddressCategory ]; |
97 | if ( !cats.isEmpty() ) | 79 | if ( !cats.isEmpty() ) |
98 | setCategories( idsFromString( cats ) ); | 80 | setCategories( idsFromString( cats ) ); |
99 | 81 | ||
100 | QString uidStr = find( Qtopia::AddressUid ); | 82 | QString uidStr = find( Qtopia::AddressUid ); |
101 | 83 | ||
102 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ | 84 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) |
103 | qWarning( "Invalid UID found. Generate new one.." ); | 85 | { |
104 | setUid( uidGen().generate() ); | 86 | qWarning( "Invalid UID found. Generate new one.." ); |
105 | }else | 87 | setUid( uidGen().generate() ); |
106 | setUid( uidStr.toInt() ); | 88 | } |
89 | else | ||
90 | setUid( uidStr.toInt() ); | ||
107 | 91 | ||
108 | // if ( !uidStr.isEmpty() ) | 92 | // if ( !uidStr.isEmpty() ) |
109 | // setUid( uidStr.toInt() ); | 93 | // setUid( uidStr.toInt() ); |
110 | } | 94 | } |
111 | 95 | ||
112 | /*! | 96 | /*! |
113 | Destroys a contact. | 97 | Destroys a contact. |
114 | */ | 98 | */ |
115 | OContact::~OContact() | 99 | OContact::~OContact() |
116 | { | 100 | {} |
117 | } | ||
118 | 101 | ||
119 | /*! \fn void OContact::setTitle( const QString &str ) | 102 | /*! \fn void OContact::setTitle( const QString &str ) |
120 | Sets the title of the contact to \a str. | 103 | Sets the title of the contact to \a str. |
121 | */ | 104 | */ |
122 | 105 | ||
123 | /*! \fn void OContact::setFirstName( const QString &str ) | 106 | /*! \fn void OContact::setFirstName( const QString &str ) |
124 | Sets the first name of the contact to \a str. | 107 | Sets the first name of the contact to \a str. |
125 | */ | 108 | */ |
126 | 109 | ||
127 | /*! \fn void OContact::setMiddleName( const QString &str ) | 110 | /*! \fn void OContact::setMiddleName( const QString &str ) |
128 | Sets the middle name of the contact to \a str. | 111 | Sets the middle name of the contact to \a str. |
129 | */ | 112 | */ |
130 | 113 | ||
131 | /*! \fn void OContact::setLastName( const QString &str ) | 114 | /*! \fn void OContact::setLastName( const QString &str ) |
132 | Sets the last name of the contact to \a str. | 115 | Sets the last name of the contact to \a str. |
133 | */ | 116 | */ |
134 | 117 | ||
135 | /*! \fn void OContact::setSuffix( const QString &str ) | 118 | /*! \fn void OContact::setSuffix( const QString &str ) |
136 | Sets the suffix of the contact to \a str. | 119 | Sets the suffix of the contact to \a str. |
137 | */ | 120 | */ |
138 | 121 | ||
139 | /*! \fn void OContact::setFileAs( const QString &str ) | 122 | /*! \fn void OContact::setFileAs( const QString &str ) |
140 | Sets the contact to filed as \a str. | 123 | Sets the contact to filed as \a str. |
141 | */ | 124 | */ |
142 | 125 | ||
143 | /*! \fn void OContact::setDefaultEmail( const QString &str ) | 126 | /*! \fn void OContact::setDefaultEmail( const QString &str ) |
144 | Sets the default email of the contact to \a str. | 127 | Sets the default email of the contact to \a str. |
145 | */ | 128 | */ |
146 | 129 | ||
147 | /*! \fn void OContact::setHomeStreet( const QString &str ) | 130 | /*! \fn void OContact::setHomeStreet( const QString &str ) |
148 | Sets the home street address of the contact to \a str. | 131 | Sets the home street address of the contact to \a str. |
149 | */ | 132 | */ |
150 | 133 | ||
151 | /*! \fn void OContact::setHomeCity( const QString &str ) | 134 | /*! \fn void OContact::setHomeCity( const QString &str ) |
152 | Sets the home city of the contact to \a str. | 135 | Sets the home city of the contact to \a str. |
153 | */ | 136 | */ |
154 | 137 | ||
155 | /*! \fn void OContact::setHomeState( const QString &str ) | 138 | /*! \fn void OContact::setHomeState( const QString &str ) |
156 | Sets the home state of the contact to \a str. | 139 | Sets the home state of the contact to \a str. |
157 | */ | 140 | */ |
158 | 141 | ||
159 | /*! \fn void OContact::setHomeZip( const QString &str ) | 142 | /*! \fn void OContact::setHomeZip( const QString &str ) |
160 | Sets the home zip code of the contact to \a str. | 143 | Sets the home zip code of the contact to \a str. |
161 | */ | 144 | */ |
162 | 145 | ||
163 | /*! \fn void OContact::setHomeCountry( const QString &str ) | 146 | /*! \fn void OContact::setHomeCountry( const QString &str ) |
164 | Sets the home country of the contact to \a str. | 147 | Sets the home country of the contact to \a str. |
165 | */ | 148 | */ |
166 | 149 | ||
167 | /*! \fn void OContact::setHomePhone( const QString &str ) | 150 | /*! \fn void OContact::setHomePhone( const QString &str ) |
168 | Sets the home phone number of the contact to \a str. | 151 | Sets the home phone number of the contact to \a str. |
169 | */ | 152 | */ |
170 | 153 | ||
171 | /*! \fn void OContact::setHomeFax( const QString &str ) | 154 | /*! \fn void OContact::setHomeFax( const QString &str ) |
172 | Sets the home fax number of the contact to \a str. | 155 | Sets the home fax number of the contact to \a str. |
173 | */ | 156 | */ |
174 | 157 | ||
175 | /*! \fn void OContact::setHomeMobile( const QString &str ) | 158 | /*! \fn void OContact::setHomeMobile( const QString &str ) |
176 | Sets the home mobile phone number of the contact to \a str. | 159 | Sets the home mobile phone number of the contact to \a str. |
177 | */ | 160 | */ |
178 | 161 | ||
179 | /*! \fn void OContact::setHomeWebpage( const QString &str ) | 162 | /*! \fn void OContact::setHomeWebpage( const QString &str ) |
180 | Sets the home webpage of the contact to \a str. | 163 | Sets the home webpage of the contact to \a str. |
181 | */ | 164 | */ |
182 | 165 | ||
183 | /*! \fn void OContact::setCompany( const QString &str ) | 166 | /*! \fn void OContact::setCompany( const QString &str ) |
184 | Sets the company for contact to \a str. | 167 | Sets the company for contact to \a str. |
185 | */ | 168 | */ |
186 | 169 | ||
187 | /*! \fn void OContact::setJobTitle( const QString &str ) | 170 | /*! \fn void OContact::setJobTitle( const QString &str ) |
188 | Sets the job title of the contact to \a str. | 171 | Sets the job title of the contact to \a str. |
189 | */ | 172 | */ |
190 | 173 | ||
191 | /*! \fn void OContact::setDepartment( const QString &str ) | 174 | /*! \fn void OContact::setDepartment( const QString &str ) |
192 | Sets the department for contact to \a str. | 175 | Sets the department for contact to \a str. |
193 | */ | 176 | */ |
194 | 177 | ||
195 | /*! \fn void OContact::setOffice( const QString &str ) | 178 | /*! \fn void OContact::setOffice( const QString &str ) |
196 | Sets the office for contact to \a str. | 179 | Sets the office for contact to \a str. |
197 | */ | 180 | */ |
198 | 181 | ||
199 | /*! \fn void OContact::setBusinessStreet( const QString &str ) | 182 | /*! \fn void OContact::setBusinessStreet( const QString &str ) |
200 | Sets the business street address of the contact to \a str. | 183 | Sets the business street address of the contact to \a str. |
201 | */ | 184 | */ |
202 | 185 | ||
203 | /*! \fn void OContact::setBusinessCity( const QString &str ) | 186 | /*! \fn void OContact::setBusinessCity( const QString &str ) |
204 | Sets the business city of the contact to \a str. | 187 | Sets the business city of the contact to \a str. |
205 | */ | 188 | */ |
206 | 189 | ||
207 | /*! \fn void OContact::setBusinessState( const QString &str ) | 190 | /*! \fn void OContact::setBusinessState( const QString &str ) |
208 | Sets the business state of the contact to \a str. | 191 | Sets the business state of the contact to \a str. |
209 | */ | 192 | */ |
210 | 193 | ||
211 | /*! \fn void OContact::setBusinessZip( const QString &str ) | 194 | /*! \fn void OContact::setBusinessZip( const QString &str ) |
212 | Sets the business zip code of the contact to \a str. | 195 | Sets the business zip code of the contact to \a str. |
213 | */ | 196 | */ |
214 | 197 | ||
215 | /*! \fn void OContact::setBusinessCountry( const QString &str ) | 198 | /*! \fn void OContact::setBusinessCountry( const QString &str ) |
216 | Sets the business country of the contact to \a str. | 199 | Sets the business country of the contact to \a str. |
217 | */ | 200 | */ |
218 | 201 | ||
219 | /*! \fn void OContact::setBusinessPhone( const QString &str ) | 202 | /*! \fn void OContact::setBusinessPhone( const QString &str ) |
220 | Sets the business phone number of the contact to \a str. | 203 | Sets the business phone number of the contact to \a str. |
221 | */ | 204 | */ |
222 | 205 | ||
223 | /*! \fn void OContact::setBusinessFax( const QString &str ) | 206 | /*! \fn void OContact::setBusinessFax( const QString &str ) |
224 | Sets the business fax number of the contact to \a str. | 207 | Sets the business fax number of the contact to \a str. |
225 | */ | 208 | */ |
226 | 209 | ||
227 | /*! \fn void OContact::setBusinessMobile( const QString &str ) | 210 | /*! \fn void OContact::setBusinessMobile( const QString &str ) |
228 | Sets the business mobile phone number of the contact to \a str. | 211 | Sets the business mobile phone number of the contact to \a str. |
229 | */ | 212 | */ |
230 | 213 | ||
231 | /*! \fn void OContact::setBusinessPager( const QString &str ) | 214 | /*! \fn void OContact::setBusinessPager( const QString &str ) |
232 | Sets the business pager number of the contact to \a str. | 215 | Sets the business pager number of the contact to \a str. |
233 | */ | 216 | */ |
234 | 217 | ||
235 | /*! \fn void OContact::setBusinessWebpage( const QString &str ) | 218 | /*! \fn void OContact::setBusinessWebpage( const QString &str ) |
236 | Sets the business webpage of the contact to \a str. | 219 | Sets the business webpage of the contact to \a str. |
237 | */ | 220 | */ |
238 | 221 | ||
239 | /*! \fn void OContact::setProfession( const QString &str ) | 222 | /*! \fn void OContact::setProfession( const QString &str ) |
240 | Sets the profession of the contact to \a str. | 223 | Sets the profession of the contact to \a str. |
241 | */ | 224 | */ |
242 | 225 | ||
243 | /*! \fn void OContact::setAssistant( const QString &str ) | 226 | /*! \fn void OContact::setAssistant( const QString &str ) |
244 | Sets the assistant of the contact to \a str. | 227 | Sets the assistant of the contact to \a str. |
245 | */ | 228 | */ |
@@ -330,909 +313,981 @@ OContact::~OContact() | |||
330 | */ | 313 | */ |
331 | 314 | ||
332 | /*! \fn QString OContact::homeWebpage() const | 315 | /*! \fn QString OContact::homeWebpage() const |
333 | Returns the home webpage of the contact. | 316 | Returns the home webpage of the contact. |
334 | */ | 317 | */ |
335 | 318 | ||
336 | /*! \fn QString OContact::company() const | 319 | /*! \fn QString OContact::company() const |
337 | Returns the company for the contact. | 320 | Returns the company for the contact. |
338 | */ | 321 | */ |
339 | 322 | ||
340 | /*! \fn QString OContact::department() const | 323 | /*! \fn QString OContact::department() const |
341 | Returns the department for the contact. | 324 | Returns the department for the contact. |
342 | */ | 325 | */ |
343 | 326 | ||
344 | /*! \fn QString OContact::office() const | 327 | /*! \fn QString OContact::office() const |
345 | Returns the office for the contact. | 328 | Returns the office for the contact. |
346 | */ | 329 | */ |
347 | 330 | ||
348 | /*! \fn QString OContact::jobTitle() const | 331 | /*! \fn QString OContact::jobTitle() const |
349 | Returns the job title of the contact. | 332 | Returns the job title of the contact. |
350 | */ | 333 | */ |
351 | 334 | ||
352 | /*! \fn QString OContact::profession() const | 335 | /*! \fn QString OContact::profession() const |
353 | Returns the profession of the contact. | 336 | Returns the profession of the contact. |
354 | */ | 337 | */ |
355 | 338 | ||
356 | /*! \fn QString OContact::assistant() const | 339 | /*! \fn QString OContact::assistant() const |
357 | Returns the assistant of the contact. | 340 | Returns the assistant of the contact. |
358 | */ | 341 | */ |
359 | 342 | ||
360 | /*! \fn QString OContact::manager() const | 343 | /*! \fn QString OContact::manager() const |
361 | Returns the manager of the contact. | 344 | Returns the manager of the contact. |
362 | */ | 345 | */ |
363 | 346 | ||
364 | /*! \fn QString OContact::businessStreet() const | 347 | /*! \fn QString OContact::businessStreet() const |
365 | Returns the business street address of the contact. | 348 | Returns the business street address of the contact. |
366 | */ | 349 | */ |
367 | 350 | ||
368 | /*! \fn QString OContact::businessCity() const | 351 | /*! \fn QString OContact::businessCity() const |
369 | Returns the business city of the contact. | 352 | Returns the business city of the contact. |
370 | */ | 353 | */ |
371 | 354 | ||
372 | /*! \fn QString OContact::businessState() const | 355 | /*! \fn QString OContact::businessState() const |
373 | Returns the business state of the contact. | 356 | Returns the business state of the contact. |
374 | */ | 357 | */ |
375 | 358 | ||
376 | /*! \fn QString OContact::businessZip() const | 359 | /*! \fn QString OContact::businessZip() const |
377 | Returns the business zip of the contact. | 360 | Returns the business zip of the contact. |
378 | */ | 361 | */ |
379 | 362 | ||
380 | /*! \fn QString OContact::businessCountry() const | 363 | /*! \fn QString OContact::businessCountry() const |
381 | Returns the business country of the contact. | 364 | Returns the business country of the contact. |
382 | */ | 365 | */ |
383 | 366 | ||
384 | /*! \fn QString OContact::businessPhone() const | 367 | /*! \fn QString OContact::businessPhone() const |
385 | Returns the business phone number of the contact. | 368 | Returns the business phone number of the contact. |
386 | */ | 369 | */ |
387 | 370 | ||
388 | /*! \fn QString OContact::businessFax() const | 371 | /*! \fn QString OContact::businessFax() const |
389 | Returns the business fax number of the contact. | 372 | Returns the business fax number of the contact. |
390 | */ | 373 | */ |
391 | 374 | ||
392 | /*! \fn QString OContact::businessMobile() const | 375 | /*! \fn QString OContact::businessMobile() const |
393 | Returns the business mobile number of the contact. | 376 | Returns the business mobile number of the contact. |
394 | */ | 377 | */ |
395 | 378 | ||
396 | /*! \fn QString OContact::businessPager() const | 379 | /*! \fn QString OContact::businessPager() const |
397 | Returns the business pager number of the contact. | 380 | Returns the business pager number of the contact. |
398 | */ | 381 | */ |
399 | 382 | ||
400 | /*! \fn QString OContact::businessWebpage() const | 383 | /*! \fn QString OContact::businessWebpage() const |
401 | Returns the business webpage of the contact. | 384 | Returns the business webpage of the contact. |
402 | */ | 385 | */ |
403 | 386 | ||
404 | /*! \fn QString OContact::spouse() const | 387 | /*! \fn QString OContact::spouse() const |
405 | Returns the spouse of the contact. | 388 | Returns the spouse of the contact. |
406 | */ | 389 | */ |
407 | 390 | ||
408 | /*! \fn QString OContact::gender() const | 391 | /*! \fn QString OContact::gender() const |
409 | Returns the gender of the contact. | 392 | Returns the gender of the contact. |
410 | */ | 393 | */ |
411 | 394 | ||
412 | /*! \fn QString OContact::nickname() const | 395 | /*! \fn QString OContact::nickname() const |
413 | Returns the nickname of the contact. | 396 | Returns the nickname of the contact. |
414 | */ | 397 | */ |
415 | 398 | ||
416 | /*! \fn QString OContact::children() const | 399 | /*! \fn QString OContact::children() const |
417 | Returns the children of the contact. | 400 | Returns the children of the contact. |
418 | */ | 401 | */ |
419 | 402 | ||
420 | /*! \fn QString OContact::notes() const | 403 | /*! \fn QString OContact::notes() const |
421 | Returns the notes relating to the the contact. | 404 | Returns the notes relating to the the contact. |
422 | */ | 405 | */ |
423 | 406 | ||
424 | /*! \fn QString OContact::groups() const | 407 | /*! \fn QString OContact::groups() const |
425 | \internal | 408 | \internal |
426 | Returns the groups for the contact. | 409 | Returns the groups for the contact. |
427 | */ | 410 | */ |
428 | 411 | ||
429 | /*! \fn QStringList OContact::groupList() const | 412 | /*! \fn QStringList OContact::groupList() const |
430 | \internal | 413 | \internal |
431 | */ | 414 | */ |
432 | 415 | ||
433 | /*! \fn QString OContact::field(int) const | 416 | /*! \fn QString OContact::field(int) const |
434 | \internal | 417 | \internal |
435 | */ | 418 | */ |
436 | 419 | ||
437 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) | 420 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) |
438 | \internal | 421 | \internal |
439 | */ | 422 | */ |
440 | 423 | ||
441 | /*! \fn void OContact::setUid( int id ) | 424 | /*! \fn void OContact::setUid( int id ) |
442 | \internal | 425 | \internal |
443 | Sets the uid for this record to \a id. | 426 | Sets the uid for this record to \a id. |
444 | */ | 427 | */ |
445 | 428 | ||
446 | /*! \enum OContact::journal_action | 429 | /*! \enum OContact::journal_action |
447 | \internal | 430 | \internal |
448 | */ | 431 | */ |
449 | 432 | ||
450 | /*! | 433 | /*! |
451 | \internal | 434 | \internal |
452 | */ | 435 | */ |
453 | QMap<int, QString> OContact::toMap() const | 436 | QMap<int, QString> OContact::toMap() const |
454 | { | 437 | { |
455 | QMap<int, QString> map = mMap; | 438 | QMap<int, QString> map = mMap; |
456 | QString cats = idsToString( categories() ); | 439 | QString cats = idsToString( categories() ); |
457 | if ( !cats.isEmpty() ) | 440 | if ( !cats.isEmpty() ) |
458 | map.insert( Qtopia::AddressCategory, cats ); | 441 | map.insert( Qtopia::AddressCategory, cats ); |
459 | return map; | 442 | return map; |
460 | } | 443 | } |
461 | 444 | ||
462 | /*! | 445 | /*! |
463 | Returns a rich text formatted QString representing the contents the contact. | 446 | Returns a rich text formatted QString representing the contents the contact. |
464 | */ | 447 | */ |
465 | QString OContact::toRichText() const | 448 | QString OContact::toRichText() const |
466 | { | 449 | { |
467 | QString text; | 450 | QString text; |
468 | QString value, comp, state; | 451 | QString value, comp, state; |
469 | QString str; | 452 | QString str; |
470 | bool marker = false; | 453 | bool marker = false; |
471 | 454 | ||
472 | Config cfg("qpe"); | 455 | Config cfg( "qpe" ); |
473 | cfg.setGroup("Appearance"); | 456 | cfg.setGroup( "Appearance" ); |
474 | int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State ); | 457 | int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State ); |
475 | 458 | ||
476 | // name, jobtitle and company | 459 | // name, jobtitle and company |
477 | if ( !(value = fullName()).isEmpty() ) | 460 | if ( !( value = fullName() ).isEmpty() ) |
478 | text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString(value) + "</h3></b>"; | 461 | text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString( value ) + "</h3></b>"; |
479 | 462 | ||
480 | if ( !(value = jobTitle()).isEmpty() ) | 463 | if ( !( value = jobTitle() ).isEmpty() ) |
481 | text += Qtopia::escapeString(value) + " "; | 464 | text += Qtopia::escapeString( value ) + " "; |
482 | 465 | ||
483 | comp = company(); | 466 | comp = company(); |
484 | if ( !(value = department()).isEmpty() ) { | 467 | if ( !( value = department() ).isEmpty() ) |
485 | text += Qtopia::escapeString(value); | 468 | { |
486 | if ( comp ) | 469 | text += Qtopia::escapeString( value ); |
487 | text += ", " + Qtopia::escapeString(comp); | 470 | if ( comp ) |
488 | }else if ( comp ) | 471 | text += ", " + Qtopia::escapeString( comp ); |
489 | text += "<br>" + Qtopia::escapeString(comp); | 472 | } |
473 | else if ( comp ) | ||
474 | text += "<br>" + Qtopia::escapeString( comp ); | ||
490 | text += "<br><hr>"; | 475 | text += "<br><hr>"; |
491 | 476 | ||
492 | // defailt email | 477 | // defailt email |
493 | QString defEmail = defaultEmail(); | 478 | QString defEmail = defaultEmail(); |
494 | if ( !defEmail.isEmpty() ){ | 479 | if ( !defEmail.isEmpty() ) |
495 | text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>" | 480 | { |
496 | + Qtopia::escapeString(defEmail); | 481 | text += "<b><img src=\"addressbook/email\"> " + QObject::tr( "Default Email: " ) + "</b>" |
497 | marker = true; | 482 | + Qtopia::escapeString( defEmail ); |
483 | marker = true; | ||
498 | } | 484 | } |
499 | 485 | ||
500 | // business address | 486 | // business address |
501 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 487 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
502 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 488 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) |
503 | text += QObject::tr( "<br><b>Work Address:</b>" ); | 489 | { |
504 | marker = true; | 490 | text += QObject::tr( "<br><b>Work Address:</b>" ); |
491 | marker = true; | ||
505 | } | 492 | } |
506 | 493 | ||
507 | if ( !(value = businessStreet()).isEmpty() ){ | 494 | if ( !( value = businessStreet() ).isEmpty() ) |
508 | text += "<br>" + Qtopia::escapeString(value); | 495 | { |
509 | marker = true; | 496 | text += "<br>" + Qtopia::escapeString( value ); |
497 | marker = true; | ||
510 | } | 498 | } |
511 | 499 | ||
512 | switch( addressformat ){ | 500 | switch ( addressformat ) |
513 | case Zip_City_State:{ // Zip_Code City, State | 501 | { |
514 | state = businessState(); | 502 | case Zip_City_State: |
515 | if ( !(value = businessZip()).isEmpty() ){ | 503 | { // Zip_Code City, State |
516 | text += "<br>" + Qtopia::escapeString(value) + " "; | 504 | state = businessState(); |
517 | marker = true; | 505 | if ( !( value = businessZip() ).isEmpty() ) |
518 | 506 | { | |
519 | } | 507 | text += "<br>" + Qtopia::escapeString( value ) + " "; |
520 | if ( !(value = businessCity()).isEmpty() ) { | 508 | marker = true; |
521 | marker = true; | 509 | |
522 | if ( businessZip().isEmpty() && !businessStreet().isEmpty() ) | 510 | } |
523 | text += "<br>"; | 511 | if ( !( value = businessCity() ).isEmpty() ) |
524 | text += Qtopia::escapeString(value); | 512 | { |
525 | if ( state ) | 513 | marker = true; |
526 | text += ", " + Qtopia::escapeString(state); | 514 | if ( businessZip().isEmpty() && !businessStreet().isEmpty() ) |
527 | } else if ( !state.isEmpty() ){ | 515 | text += "<br>"; |
528 | text += "<br>" + Qtopia::escapeString(state); | 516 | text += Qtopia::escapeString( value ); |
529 | marker = true; | 517 | if ( state ) |
530 | } | 518 | text += ", " + Qtopia::escapeString( state ); |
531 | break; | 519 | } |
532 | } | 520 | else if ( !state.isEmpty() ) |
533 | case City_State_Zip:{ // City, State Zip_Code | 521 | { |
534 | state = businessState(); | 522 | text += "<br>" + Qtopia::escapeString( state ); |
535 | if ( !(value = businessCity()).isEmpty() ) { | 523 | marker = true; |
536 | marker = true; | 524 | } |
537 | text += "<br>" + Qtopia::escapeString(value); | 525 | break; |
538 | if ( state ) | 526 | } |
539 | text += ", " + Qtopia::escapeString(state); | 527 | case City_State_Zip: |
540 | } else if ( !state.isEmpty() ){ | 528 | { // City, State Zip_Code |
541 | text += "<br>" + Qtopia::escapeString(state); | 529 | state = businessState(); |
542 | marker = true; | 530 | if ( !( value = businessCity() ).isEmpty() ) |
543 | } | 531 | { |
544 | if ( !(value = businessZip()).isEmpty() ){ | 532 | marker = true; |
545 | text += " " + Qtopia::escapeString(value); | 533 | text += "<br>" + Qtopia::escapeString( value ); |
546 | marker = true; | 534 | if ( state ) |
547 | } | 535 | text += ", " + Qtopia::escapeString( state ); |
548 | break; | 536 | } |
549 | } | 537 | else if ( !state.isEmpty() ) |
538 | { | ||
539 | text += "<br>" + Qtopia::escapeString( state ); | ||
540 | marker = true; | ||
541 | } | ||
542 | if ( !( value = businessZip() ).isEmpty() ) | ||
543 | { | ||
544 | text += " " + Qtopia::escapeString( value ); | ||
545 | marker = true; | ||
546 | } | ||
547 | break; | ||
548 | } | ||
550 | } | 549 | } |
551 | 550 | ||
552 | if ( !(value = businessCountry()).isEmpty() ){ | 551 | if ( !( value = businessCountry() ).isEmpty() ) |
553 | text += "<br>" + Qtopia::escapeString(value); | 552 | { |
554 | marker = true; | 553 | text += "<br>" + Qtopia::escapeString( value ); |
554 | marker = true; | ||
555 | } | 555 | } |
556 | 556 | ||
557 | // rest of Business data | 557 | // rest of Business data |
558 | str = office(); | 558 | str = office(); |
559 | if ( !str.isEmpty() ){ | 559 | if ( !str.isEmpty() ) |
560 | text += "<br><b>" + QObject::tr("Office: ") + "</b>" | 560 | { |
561 | + Qtopia::escapeString(str); | 561 | text += "<br><b>" + QObject::tr( "Office: " ) + "</b>" |
562 | marker = true; | 562 | + Qtopia::escapeString( str ); |
563 | marker = true; | ||
563 | } | 564 | } |
564 | str = businessWebpage(); | 565 | str = businessWebpage(); |
565 | if ( !str.isEmpty() ){ | 566 | if ( !str.isEmpty() ) |
566 | text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>" | 567 | { |
567 | + Qtopia::escapeString(str); | 568 | text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr( "Business Web Page: " ) + "</b>" |
568 | marker = true; | 569 | + Qtopia::escapeString( str ); |
570 | marker = true; | ||
569 | } | 571 | } |
570 | str = businessPhone(); | 572 | str = businessPhone(); |
571 | if ( !str.isEmpty() ){ | 573 | if ( !str.isEmpty() ) |
572 | text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>" | 574 | { |
573 | + Qtopia::escapeString(str); | 575 | text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr( "Business Phone: " ) + "</b>" |
574 | marker = true; | 576 | + Qtopia::escapeString( str ); |
577 | marker = true; | ||
575 | } | 578 | } |
576 | str = businessFax(); | 579 | str = businessFax(); |
577 | if ( !str.isEmpty() ){ | 580 | if ( !str.isEmpty() ) |
578 | text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>" | 581 | { |
579 | + Qtopia::escapeString(str); | 582 | text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr( "Business Fax: " ) + "</b>" |
580 | marker = true; | 583 | + Qtopia::escapeString( str ); |
584 | marker = true; | ||
581 | } | 585 | } |
582 | str = businessMobile(); | 586 | str = businessMobile(); |
583 | if ( !str.isEmpty() ){ | 587 | if ( !str.isEmpty() ) |
584 | text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>" | 588 | { |
585 | + Qtopia::escapeString(str); | 589 | text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr( "Business Mobile: " ) + "</b>" |
586 | marker = true; | 590 | + Qtopia::escapeString( str ); |
591 | marker = true; | ||
587 | } | 592 | } |
588 | str = businessPager(); | 593 | str = businessPager(); |
589 | if ( !str.isEmpty() ){ | 594 | if ( !str.isEmpty() ) |
590 | text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>" | 595 | { |
591 | + Qtopia::escapeString(str); | 596 | text += "<br><b>" + QObject::tr( "Business Pager: " ) + "</b>" |
592 | marker = true; | 597 | + Qtopia::escapeString( str ); |
598 | marker = true; | ||
593 | } | 599 | } |
594 | 600 | ||
595 | // text += "<br>"; | 601 | // text += "<br>"; |
596 | 602 | ||
597 | // home address | 603 | // home address |
598 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 604 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
599 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 605 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) |
600 | text += QObject::tr( "<br><b>Home Address:</b>" ); | 606 | { |
601 | marker = true; | 607 | text += QObject::tr( "<br><b>Home Address:</b>" ); |
608 | marker = true; | ||
602 | } | 609 | } |
603 | 610 | ||
604 | if ( !(value = homeStreet()).isEmpty() ){ | 611 | if ( !( value = homeStreet() ).isEmpty() ) |
605 | text += "<br>" + Qtopia::escapeString(value); | 612 | { |
606 | marker = true; | 613 | text += "<br>" + Qtopia::escapeString( value ); |
614 | marker = true; | ||
607 | } | 615 | } |
608 | 616 | ||
609 | switch( addressformat ){ | 617 | switch ( addressformat ) |
610 | case Zip_City_State:{ // Zip_Code City, State | 618 | { |
611 | state = homeState(); | 619 | case Zip_City_State: |
612 | if ( !(value = homeZip()).isEmpty() ){ | 620 | { // Zip_Code City, State |
613 | text += "<br>" + Qtopia::escapeString(value) + " "; | 621 | state = homeState(); |
614 | marker = true; | 622 | if ( !( value = homeZip() ).isEmpty() ) |
615 | } | 623 | { |
616 | if ( !(value = homeCity()).isEmpty() ) { | 624 | text += "<br>" + Qtopia::escapeString( value ) + " "; |
617 | marker = true; | 625 | marker = true; |
618 | if ( homeZip().isEmpty() && !homeStreet().isEmpty() ) | 626 | } |
619 | text += "<br>"; | 627 | if ( !( value = homeCity() ).isEmpty() ) |
620 | text += Qtopia::escapeString(value); | 628 | { |
621 | if ( !state.isEmpty() ) | 629 | marker = true; |
622 | text += ", " + Qtopia::escapeString(state); | 630 | if ( homeZip().isEmpty() && !homeStreet().isEmpty() ) |
623 | } else if (!state.isEmpty()) { | 631 | text += "<br>"; |
624 | text += "<br>" + Qtopia::escapeString(state); | 632 | text += Qtopia::escapeString( value ); |
625 | marker = true; | 633 | if ( !state.isEmpty() ) |
626 | } | 634 | text += ", " + Qtopia::escapeString( state ); |
627 | break; | 635 | } |
628 | } | 636 | else if ( !state.isEmpty() ) |
629 | case City_State_Zip:{ // City, State Zip_Code | 637 | { |
630 | state = homeState(); | 638 | text += "<br>" + Qtopia::escapeString( state ); |
631 | if ( !(value = homeCity()).isEmpty() ) { | 639 | marker = true; |
632 | marker = true; | 640 | } |
633 | text += "<br>" + Qtopia::escapeString(value); | 641 | break; |
634 | if ( state ) | 642 | } |
635 | text += ", " + Qtopia::escapeString(state); | 643 | case City_State_Zip: |
636 | } else if ( !state.isEmpty() ){ | 644 | { // City, State Zip_Code |
637 | text += "<br>" + Qtopia::escapeString(state); | 645 | state = homeState(); |
638 | marker = true; | 646 | if ( !( value = homeCity() ).isEmpty() ) |
639 | } | 647 | { |
640 | if ( !(value = homeZip()).isEmpty() ){ | 648 | marker = true; |
641 | text += " " + Qtopia::escapeString(value); | 649 | text += "<br>" + Qtopia::escapeString( value ); |
642 | marker = true; | 650 | if ( state ) |
643 | } | 651 | text += ", " + Qtopia::escapeString( state ); |
644 | break; | 652 | } |
645 | } | 653 | else if ( !state.isEmpty() ) |
654 | { | ||
655 | text += "<br>" + Qtopia::escapeString( state ); | ||
656 | marker = true; | ||
657 | } | ||
658 | if ( !( value = homeZip() ).isEmpty() ) | ||
659 | { | ||
660 | text += " " + Qtopia::escapeString( value ); | ||
661 | marker = true; | ||
662 | } | ||
663 | break; | ||
664 | } | ||
646 | } | 665 | } |
647 | 666 | ||
648 | if ( !(value = homeCountry()).isEmpty() ){ | 667 | if ( !( value = homeCountry() ).isEmpty() ) |
649 | text += "<br>" + Qtopia::escapeString(value); | 668 | { |
650 | marker = true; | 669 | text += "<br>" + Qtopia::escapeString( value ); |
670 | marker = true; | ||
651 | } | 671 | } |
652 | 672 | ||
653 | // rest of Home data | 673 | // rest of Home data |
654 | str = homeWebpage(); | 674 | str = homeWebpage(); |
655 | if ( !str.isEmpty() ){ | 675 | if ( !str.isEmpty() ) |
656 | text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>" | 676 | { |
657 | + Qtopia::escapeString(str); | 677 | text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr( "Home Web Page: " ) + "</b>" |
658 | marker = true; | 678 | + Qtopia::escapeString( str ); |
679 | marker = true; | ||
659 | } | 680 | } |
660 | str = homePhone(); | 681 | str = homePhone(); |
661 | if ( !str.isEmpty() ){ | 682 | if ( !str.isEmpty() ) |
662 | text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>" | 683 | { |
663 | + Qtopia::escapeString(str); | 684 | text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr( "Home Phone: " ) + "</b>" |
664 | marker = true; | 685 | + Qtopia::escapeString( str ); |
686 | marker = true; | ||
665 | } | 687 | } |
666 | str = homeFax(); | 688 | str = homeFax(); |
667 | if ( !str.isEmpty() ){ | 689 | if ( !str.isEmpty() ) |
668 | text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>" | 690 | { |
669 | + Qtopia::escapeString(str); | 691 | text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr( "Home Fax: " ) + "</b>" |
670 | marker = true; | 692 | + Qtopia::escapeString( str ); |
693 | marker = true; | ||
671 | } | 694 | } |
672 | str = homeMobile(); | 695 | str = homeMobile(); |
673 | if ( !str.isEmpty() ){ | 696 | if ( !str.isEmpty() ) |
674 | text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>" | 697 | { |
675 | + Qtopia::escapeString(str); | 698 | text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr( "Home Mobile: " ) + "</b>" |
676 | marker = true; | 699 | + Qtopia::escapeString( str ); |
700 | marker = true; | ||
677 | } | 701 | } |
678 | 702 | ||
679 | if ( marker ) | 703 | if ( marker ) |
680 | text += "<br><hr>"; | 704 | text += "<br><hr>"; |
681 | 705 | ||
682 | // the rest... | 706 | // the rest... |
683 | str = emails(); | 707 | str = emails(); |
684 | if ( !str.isEmpty() && ( str != defEmail ) ) | 708 | if ( !str.isEmpty() && ( str != defEmail ) ) |
685 | text += "<br><b>" + QObject::tr("All Emails: ") + "</b>" | 709 | text += "<br><b>" + QObject::tr( "All Emails: " ) + "</b>" |
686 | + Qtopia::escapeString(str); | 710 | + Qtopia::escapeString( str ); |
687 | str = profession(); | 711 | str = profession(); |
688 | if ( !str.isEmpty() ) | 712 | if ( !str.isEmpty() ) |
689 | text += "<br><b>" + QObject::tr("Profession: ") + "</b>" | 713 | text += "<br><b>" + QObject::tr( "Profession: " ) + "</b>" |
690 | + Qtopia::escapeString(str); | 714 | + Qtopia::escapeString( str ); |
691 | str = assistant(); | 715 | str = assistant(); |
692 | if ( !str.isEmpty() ) | 716 | if ( !str.isEmpty() ) |
693 | text += "<br><b>" + QObject::tr("Assistant: ") + "</b>" | 717 | text += "<br><b>" + QObject::tr( "Assistant: " ) + "</b>" |
694 | + Qtopia::escapeString(str); | 718 | + Qtopia::escapeString( str ); |
695 | str = manager(); | 719 | str = manager(); |
696 | if ( !str.isEmpty() ) | 720 | if ( !str.isEmpty() ) |
697 | text += "<br><b>" + QObject::tr("Manager: ") + "</b>" | 721 | text += "<br><b>" + QObject::tr( "Manager: " ) + "</b>" |
698 | + Qtopia::escapeString(str); | 722 | + Qtopia::escapeString( str ); |
699 | str = gender(); | 723 | str = gender(); |
700 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 724 | if ( !str.isEmpty() && str.toInt() != 0 ) |
701 | text += "<br>"; | 725 | { |
702 | if ( str.toInt() == 1 ) | 726 | text += "<br>"; |
703 | str = QObject::tr( "Male" ); | 727 | if ( str.toInt() == 1 ) |
704 | else if ( str.toInt() == 2 ) | 728 | str = QObject::tr( "Male" ); |
705 | str = QObject::tr( "Female" ); | 729 | else if ( str.toInt() == 2 ) |
706 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str; | 730 | str = QObject::tr( "Female" ); |
731 | text += "<b>" + QObject::tr( "Gender: " ) + "</b>" + str; | ||
707 | } | 732 | } |
708 | str = spouse(); | 733 | str = spouse(); |
709 | if ( !str.isEmpty() ) | 734 | if ( !str.isEmpty() ) |
710 | text += "<br><b>" + QObject::tr("Spouse: ") + "</b>" | 735 | text += "<br><b>" + QObject::tr( "Spouse: " ) + "</b>" |
711 | + Qtopia::escapeString(str); | 736 | + Qtopia::escapeString( str ); |
712 | if ( birthday().isValid() ){ | 737 | if ( birthday().isValid() ) |
713 | str = TimeString::numberDateString( birthday() ); | 738 | { |
714 | text += "<br><b>" + QObject::tr("Birthday: ") + "</b>" | 739 | str = TimeString::numberDateString( birthday() ); |
715 | + Qtopia::escapeString(str); | 740 | text += "<br><b>" + QObject::tr( "Birthday: " ) + "</b>" |
741 | + Qtopia::escapeString( str ); | ||
716 | } | 742 | } |
717 | if ( anniversary().isValid() ){ | 743 | if ( anniversary().isValid() ) |
718 | str = TimeString::numberDateString( anniversary() ); | 744 | { |
719 | text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>" | 745 | str = TimeString::numberDateString( anniversary() ); |
720 | + Qtopia::escapeString(str); | 746 | text += "<br><b>" + QObject::tr( "Anniversary: " ) + "</b>" |
747 | + Qtopia::escapeString( str ); | ||
721 | } | 748 | } |
722 | str = children(); | 749 | str = children(); |
723 | if ( !str.isEmpty() ) | 750 | if ( !str.isEmpty() ) |
724 | text += "<br><b>" + QObject::tr("Children: ") + "</b>" | 751 | text += "<br><b>" + QObject::tr( "Children: " ) + "</b>" |
725 | + Qtopia::escapeString(str); | 752 | + Qtopia::escapeString( str ); |
726 | 753 | ||
727 | str = nickname(); | 754 | str = nickname(); |
728 | if ( !str.isEmpty() ) | 755 | if ( !str.isEmpty() ) |
729 | text += "<br><b>" + QObject::tr("Nickname: ") + "</b>" | 756 | text += "<br><b>" + QObject::tr( "Nickname: " ) + "</b>" |
730 | + Qtopia::escapeString(str); | 757 | + Qtopia::escapeString( str ); |
731 | 758 | ||
732 | // categories | 759 | // categories |
733 | if ( categoryNames("Contacts").count() ){ | 760 | if ( categoryNames( "Contacts" ).count() ) |
734 | text += "<br><b>" + QObject::tr( "Category:") + "</b> "; | 761 | { |
735 | text += categoryNames("Contacts").join(", "); | 762 | text += "<br><b>" + QObject::tr( "Category:" ) + "</b> "; |
763 | text += categoryNames( "Contacts" ).join( ", " ); | ||
736 | } | 764 | } |
737 | 765 | ||
738 | // notes last | 766 | // notes last |
739 | if ( !(value = notes()).isEmpty() ) { | 767 | if ( !( value = notes() ).isEmpty() ) |
740 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; | 768 | { |
741 | QRegExp reg("\n"); | 769 | text += "<br><hr><b>" + QObject::tr( "Notes:" ) + "</b> "; |
742 | 770 | QRegExp reg( "\n" ); | |
743 | //QString tmp = Qtopia::escapeString(value); | 771 | |
744 | QString tmp = QStyleSheet::convertFromPlainText(value); | 772 | //QString tmp = Qtopia::escapeString(value); |
745 | //tmp.replace( reg, "<br>" ); | 773 | QString tmp = QStyleSheet::convertFromPlainText( value ); |
746 | text += "<br>" + tmp + "<br>"; | 774 | //tmp.replace( reg, "<br>" ); |
775 | text += "<br>" + tmp + "<br>"; | ||
747 | } | 776 | } |
748 | return text; | 777 | return text; |
749 | } | 778 | } |
750 | 779 | ||
751 | /*! | 780 | /*! |
752 | \internal | 781 | \internal |
753 | */ | 782 | */ |
754 | void OContact::insert( int key, const QString &v ) | 783 | void OContact::insert( int key, const QString &v ) |
755 | { | 784 | { |
756 | QString value = v.stripWhiteSpace(); | 785 | QString value = v.stripWhiteSpace(); |
757 | if ( value.isEmpty() ) | 786 | if ( value.isEmpty() ) |
758 | mMap.remove( key ); | 787 | mMap.remove( key ); |
759 | else | 788 | else |
760 | mMap.insert( key, value ); | 789 | mMap.insert( key, value ); |
761 | } | 790 | } |
762 | 791 | ||
763 | /*! | 792 | /*! |
764 | \internal | 793 | \internal |
765 | */ | 794 | */ |
766 | void OContact::replace( int key, const QString & v ) | 795 | void OContact::replace( int key, const QString & v ) |
767 | { | 796 | { |
768 | QString value = v.stripWhiteSpace(); | 797 | QString value = v.stripWhiteSpace(); |
769 | if ( value.isEmpty() ) | 798 | if ( value.isEmpty() ) |
770 | mMap.remove( key ); | 799 | mMap.remove( key ); |
771 | else | 800 | else |
772 | mMap.replace( key, value ); | 801 | mMap.replace( key, value ); |
773 | } | 802 | } |
774 | 803 | ||
775 | /*! | 804 | /*! |
776 | \internal | 805 | \internal |
777 | */ | 806 | */ |
778 | QString OContact::find( int key ) const | 807 | QString OContact::find( int key ) const |
779 | { | 808 | { |
780 | return mMap[key]; | 809 | return mMap[ key ]; |
781 | } | 810 | } |
782 | 811 | ||
783 | /*! | 812 | /*! |
784 | \internal | 813 | \internal |
785 | */ | 814 | */ |
786 | QString OContact::displayAddress( const QString &street, | 815 | QString OContact::displayAddress( const QString &street, |
787 | const QString &city, | 816 | const QString &city, |
788 | const QString &state, | 817 | const QString &state, |
789 | const QString &zip, | 818 | const QString &zip, |
790 | const QString &country ) const | 819 | const QString &country ) const |
791 | { | 820 | { |
792 | QString s = street; | 821 | QString s = street; |
793 | if ( !street.isEmpty() ) | 822 | if ( !street.isEmpty() ) |
794 | s+= "\n"; | 823 | s += "\n"; |
795 | s += city; | 824 | s += city; |
796 | if ( !city.isEmpty() && !state.isEmpty() ) | 825 | if ( !city.isEmpty() && !state.isEmpty() ) |
797 | s += ", "; | 826 | s += ", "; |
798 | s += state; | 827 | s += state; |
799 | if ( !state.isEmpty() && !zip.isEmpty() ) | 828 | if ( !state.isEmpty() && !zip.isEmpty() ) |
800 | s += " "; | 829 | s += " "; |
801 | s += zip; | 830 | s += zip; |
802 | if ( !country.isEmpty() && !s.isEmpty() ) | 831 | if ( !country.isEmpty() && !s.isEmpty() ) |
803 | s += "\n"; | 832 | s += "\n"; |
804 | s += country; | 833 | s += country; |
805 | return s; | 834 | return s; |
806 | } | 835 | } |
807 | 836 | ||
808 | /*! | 837 | /*! |
809 | \internal | 838 | \internal |
810 | */ | 839 | */ |
811 | QString OContact::displayBusinessAddress() const | 840 | QString OContact::displayBusinessAddress() const |
812 | { | 841 | { |
813 | return displayAddress( businessStreet(), businessCity(), | 842 | return displayAddress( businessStreet(), businessCity(), |
814 | businessState(), businessZip(), | 843 | businessState(), businessZip(), |
815 | businessCountry() ); | 844 | businessCountry() ); |
816 | } | 845 | } |
817 | 846 | ||
818 | /*! | 847 | /*! |
819 | \internal | 848 | \internal |
820 | */ | 849 | */ |
821 | QString OContact::displayHomeAddress() const | 850 | QString OContact::displayHomeAddress() const |
822 | { | 851 | { |
823 | return displayAddress( homeStreet(), homeCity(), | 852 | return displayAddress( homeStreet(), homeCity(), |
824 | homeState(), homeZip(), | 853 | homeState(), homeZip(), |
825 | homeCountry() ); | 854 | homeCountry() ); |
826 | } | 855 | } |
827 | 856 | ||
828 | /*! | 857 | /*! |
829 | Returns the full name of the contact | 858 | Returns the full name of the contact |
830 | */ | 859 | */ |
831 | QString OContact::fullName() const | 860 | QString OContact::fullName() const |
832 | { | 861 | { |
833 | QString title = find( Qtopia::Title ); | 862 | QString title = find( Qtopia::Title ); |
834 | QString firstName = find( Qtopia::FirstName ); | 863 | QString firstName = find( Qtopia::FirstName ); |
835 | QString middleName = find( Qtopia::MiddleName ); | 864 | QString middleName = find( Qtopia::MiddleName ); |
836 | QString lastName = find( Qtopia::LastName ); | 865 | QString lastName = find( Qtopia::LastName ); |
837 | QString suffix = find( Qtopia::Suffix ); | 866 | QString suffix = find( Qtopia::Suffix ); |
838 | 867 | ||
839 | QString name = title; | 868 | QString name = title; |
840 | if ( !firstName.isEmpty() ) { | 869 | if ( !firstName.isEmpty() ) |
841 | if ( !name.isEmpty() ) | 870 | { |
842 | name += " "; | 871 | if ( !name.isEmpty() ) |
843 | name += firstName; | 872 | name += " "; |
873 | name += firstName; | ||
844 | } | 874 | } |
845 | if ( !middleName.isEmpty() ) { | 875 | if ( !middleName.isEmpty() ) |
846 | if ( !name.isEmpty() ) | 876 | { |
847 | name += " "; | 877 | if ( !name.isEmpty() ) |
848 | name += middleName; | 878 | name += " "; |
879 | name += middleName; | ||
849 | } | 880 | } |
850 | if ( !lastName.isEmpty() ) { | 881 | if ( !lastName.isEmpty() ) |
851 | if ( !name.isEmpty() ) | 882 | { |
852 | name += " "; | 883 | if ( !name.isEmpty() ) |
853 | name += lastName; | 884 | name += " "; |
885 | name += lastName; | ||
854 | } | 886 | } |
855 | if ( !suffix.isEmpty() ) { | 887 | if ( !suffix.isEmpty() ) |
856 | if ( !name.isEmpty() ) | 888 | { |
857 | name += " "; | 889 | if ( !name.isEmpty() ) |
858 | name += suffix; | 890 | name += " "; |
891 | name += suffix; | ||
859 | } | 892 | } |
860 | return name.simplifyWhiteSpace(); | 893 | return name.simplifyWhiteSpace(); |
861 | } | 894 | } |
862 | 895 | ||
863 | /*! | 896 | /*! |
864 | Returns a list of the names of the children of the contact. | 897 | Returns a list of the names of the children of the contact. |
865 | */ | 898 | */ |
866 | QStringList OContact::childrenList() const | 899 | QStringList OContact::childrenList() const |
867 | { | 900 | { |
868 | return QStringList::split( " ", find( Qtopia::Children ) ); | 901 | return QStringList::split( " ", find( Qtopia::Children ) ); |
869 | } | 902 | } |
870 | 903 | ||
871 | /*! \fn void OContact::insertEmail( const QString &email ) | 904 | /*! \fn void OContact::insertEmail( const QString &email ) |
872 | 905 | ||
873 | Insert \a email into the email list. Ensures \a email can only be added | 906 | Insert \a email into the email list. Ensures \a email can only be added |
874 | once. If there is no default email address set, it sets it to the \a email. | 907 | once. If there is no default email address set, it sets it to the \a email. |
875 | */ | 908 | */ |
876 | 909 | ||
877 | /*! \fn void OContact::removeEmail( const QString &email ) | 910 | /*! \fn void OContact::removeEmail( const QString &email ) |
878 | 911 | ||
879 | Removes the \a email from the email list. If the default email was \a email, | 912 | Removes the \a email from the email list. If the default email was \a email, |
880 | then the default email address is assigned to the first email in the | 913 | then the default email address is assigned to the first email in the |
881 | email list | 914 | email list |
882 | */ | 915 | */ |
883 | 916 | ||
884 | /*! \fn void OContact::clearEmails() | 917 | /*! \fn void OContact::clearEmails() |
885 | 918 | ||
886 | Clears the email list. | 919 | Clears the email list. |
887 | */ | 920 | */ |
888 | 921 | ||
889 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) | 922 | /*! \fn void OContact::insertEmails( const QStringList &emailList ) |
890 | 923 | ||
891 | Appends the \a emailList to the exiting email list | 924 | Appends the \a emailList to the exiting email list |
892 | */ | 925 | */ |
893 | 926 | ||
894 | /*! | 927 | /*! |
895 | Returns a list of email addresses belonging to the contact, including | 928 | Returns a list of email addresses belonging to the contact, including |
896 | the default email address. | 929 | the default email address. |
897 | */ | 930 | */ |
898 | QStringList OContact::emailList() const | 931 | QStringList OContact::emailList() const |
899 | { | 932 | { |
900 | QString emailStr = emails(); | 933 | QString emailStr = emails(); |
901 | 934 | ||
902 | QStringList r; | 935 | QStringList r; |
903 | if ( !emailStr.isEmpty() ) { | 936 | if ( !emailStr.isEmpty() ) |
904 | qDebug(" emailstr "); | 937 | { |
905 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 938 | qDebug( " emailstr " ); |
906 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 939 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
907 | r += (*it).simplifyWhiteSpace(); | 940 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
941 | r += ( *it ).simplifyWhiteSpace(); | ||
908 | } | 942 | } |
909 | 943 | ||
910 | return r; | 944 | return r; |
911 | } | 945 | } |
912 | 946 | ||
913 | /*! | 947 | /*! |
914 | \overload | 948 | \overload |
915 | 949 | ||
916 | Generates the string for the contact to be filed as from the first, | 950 | Generates the string for the contact to be filed as from the first, |
917 | middle and last name of the contact. | 951 | middle and last name of the contact. |
918 | */ | 952 | */ |
919 | void OContact::setFileAs() | 953 | void OContact::setFileAs() |
920 | { | 954 | { |
921 | QString lastName, firstName, middleName, fileas; | 955 | QString lastName, firstName, middleName, fileas; |
922 | 956 | ||
923 | lastName = find( Qtopia::LastName ); | 957 | lastName = find( Qtopia::LastName ); |
924 | firstName = find( Qtopia::FirstName ); | 958 | firstName = find( Qtopia::FirstName ); |
925 | middleName = find( Qtopia::MiddleName ); | 959 | middleName = find( Qtopia::MiddleName ); |
926 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 960 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
927 | && !middleName.isEmpty() ) | 961 | && !middleName.isEmpty() ) |
928 | fileas = lastName + ", " + firstName + " " + middleName; | 962 | fileas = lastName + ", " + firstName + " " + middleName; |
929 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 963 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
930 | fileas = lastName + ", " + firstName; | 964 | fileas = lastName + ", " + firstName; |
931 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 965 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
932 | !middleName.isEmpty() ) | 966 | !middleName.isEmpty() ) |
933 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 967 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
934 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 968 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
935 | + lastName; | 969 | + lastName; |
936 | 970 | ||
937 | replace( Qtopia::FileAs, fileas ); | 971 | replace( Qtopia::FileAs, fileas ); |
938 | } | 972 | } |
939 | 973 | ||
940 | /*! | 974 | /*! |
941 | \internal | 975 | \internal |
942 | Appends the contact information to \a buf. | 976 | Appends the contact information to \a buf. |
943 | */ | 977 | */ |
944 | void OContact::save( QString &buf ) const | 978 | void OContact::save( QString &buf ) const |
945 | { | 979 | { |
946 | static const QStringList SLFIELDS = fields(); | 980 | static const QStringList SLFIELDS = fields(); |
947 | // I'm expecting "<Contact " in front of this... | 981 | // I'm expecting "<Contact " in front of this... |
948 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 982 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
949 | it != mMap.end(); ++it ) { | 983 | it != mMap.end(); ++it ) |
950 | const QString &value = it.data(); | 984 | { |
951 | int key = it.key(); | 985 | const QString &value = it.data(); |
952 | if ( !value.isEmpty() ) { | 986 | int key = it.key(); |
953 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 987 | if ( !value.isEmpty() ) |
954 | continue; | 988 | { |
955 | 989 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid ) | |
956 | key -= Qtopia::AddressCategory+1; | 990 | continue; |
957 | buf += SLFIELDS[key]; | 991 | |
958 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 992 | key -= Qtopia::AddressCategory + 1; |
959 | } | 993 | buf += SLFIELDS[ key ]; |
994 | buf += "=\"" + Qtopia::escapeString( value ) + "\" "; | ||
995 | } | ||
960 | } | 996 | } |
961 | buf += customToXml(); | 997 | buf += customToXml(); |
962 | if ( categories().count() > 0 ) | 998 | if ( categories().count() > 0 ) |
963 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 999 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
964 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 1000 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
965 | // You need to close this yourself | 1001 | // You need to close this yourself |
966 | } | 1002 | } |
967 | 1003 | ||
968 | 1004 | ||
969 | /*! | 1005 | /*! |
970 | \internal | 1006 | \internal |
971 | Returns the list of fields belonging to a contact | 1007 | Returns the list of fields belonging to a contact |
972 | Never change order of this list ! It has to be regarding | 1008 | Never change order of this list ! It has to be regarding |
973 | enum AddressBookFields !! | 1009 | enum AddressBookFields !! |
974 | */ | 1010 | */ |
975 | QStringList OContact::fields() | 1011 | QStringList OContact::fields() |
976 | { | 1012 | { |
977 | QStringList list; | 1013 | QStringList list; |
978 | 1014 | ||
979 | list.append( "Title" ); // Not Used! | 1015 | list.append( "Title" ); // Not Used! |
980 | list.append( "FirstName" ); | 1016 | list.append( "FirstName" ); |
981 | list.append( "MiddleName" ); | 1017 | list.append( "MiddleName" ); |
982 | list.append( "LastName" ); | 1018 | list.append( "LastName" ); |
983 | list.append( "Suffix" ); | 1019 | list.append( "Suffix" ); |
984 | list.append( "FileAs" ); | 1020 | list.append( "FileAs" ); |
985 | 1021 | ||
986 | list.append( "JobTitle" ); | 1022 | list.append( "JobTitle" ); |
987 | list.append( "Department" ); | 1023 | list.append( "Department" ); |
988 | list.append( "Company" ); | 1024 | list.append( "Company" ); |
989 | list.append( "BusinessPhone" ); | 1025 | list.append( "BusinessPhone" ); |
990 | list.append( "BusinessFax" ); | 1026 | list.append( "BusinessFax" ); |
991 | list.append( "BusinessMobile" ); | 1027 | list.append( "BusinessMobile" ); |
992 | 1028 | ||
993 | list.append( "DefaultEmail" ); | 1029 | list.append( "DefaultEmail" ); |
994 | list.append( "Emails" ); | 1030 | list.append( "Emails" ); |
995 | 1031 | ||
996 | list.append( "HomePhone" ); | 1032 | list.append( "HomePhone" ); |
997 | list.append( "HomeFax" ); | 1033 | list.append( "HomeFax" ); |
998 | list.append( "HomeMobile" ); | 1034 | list.append( "HomeMobile" ); |
999 | 1035 | ||
1000 | list.append( "BusinessStreet" ); | 1036 | list.append( "BusinessStreet" ); |
1001 | list.append( "BusinessCity" ); | 1037 | list.append( "BusinessCity" ); |
1002 | list.append( "BusinessState" ); | 1038 | list.append( "BusinessState" ); |
1003 | list.append( "BusinessZip" ); | 1039 | list.append( "BusinessZip" ); |
1004 | list.append( "BusinessCountry" ); | 1040 | list.append( "BusinessCountry" ); |
1005 | list.append( "BusinessPager" ); | 1041 | list.append( "BusinessPager" ); |
1006 | list.append( "BusinessWebPage" ); | 1042 | list.append( "BusinessWebPage" ); |
1007 | 1043 | ||
1008 | list.append( "Office" ); | 1044 | list.append( "Office" ); |
1009 | list.append( "Profession" ); | 1045 | list.append( "Profession" ); |
1010 | list.append( "Assistant" ); | 1046 | list.append( "Assistant" ); |
1011 | list.append( "Manager" ); | 1047 | list.append( "Manager" ); |
1012 | 1048 | ||
1013 | list.append( "HomeStreet" ); | 1049 | list.append( "HomeStreet" ); |
1014 | list.append( "HomeCity" ); | 1050 | list.append( "HomeCity" ); |
1015 | list.append( "HomeState" ); | 1051 | list.append( "HomeState" ); |
1016 | list.append( "HomeZip" ); | 1052 | list.append( "HomeZip" ); |
1017 | list.append( "HomeCountry" ); | 1053 | list.append( "HomeCountry" ); |
1018 | list.append( "HomeWebPage" ); | 1054 | list.append( "HomeWebPage" ); |
1019 | 1055 | ||
1020 | list.append( "Spouse" ); | 1056 | list.append( "Spouse" ); |
1021 | list.append( "Gender" ); | 1057 | list.append( "Gender" ); |
1022 | list.append( "Birthday" ); | 1058 | list.append( "Birthday" ); |
1023 | list.append( "Anniversary" ); | 1059 | list.append( "Anniversary" ); |
1024 | list.append( "Nickname" ); | 1060 | list.append( "Nickname" ); |
1025 | list.append( "Children" ); | 1061 | list.append( "Children" ); |
1026 | 1062 | ||
1027 | list.append( "Notes" ); | 1063 | list.append( "Notes" ); |
1028 | list.append( "Groups" ); | 1064 | list.append( "Groups" ); |
1029 | 1065 | ||
1030 | return list; | 1066 | return list; |
1031 | } | 1067 | } |
1032 | 1068 | ||
1033 | 1069 | ||
1034 | /*! | 1070 | /*! |
1035 | Sets the list of email address for contact to those contained in \a str. | 1071 | Sets the list of email address for contact to those contained in \a str. |
1036 | Email address should be separated by ';'s. | 1072 | Email address should be separated by ';'s. |
1037 | */ | 1073 | */ |
1038 | void OContact::setEmails( const QString &str ) | 1074 | void OContact::setEmails( const QString &str ) |
1039 | { | 1075 | { |
1040 | replace( Qtopia::Emails, str ); | 1076 | replace( Qtopia::Emails, str ); |
1041 | if ( str.isEmpty() ) | 1077 | if ( str.isEmpty() ) |
1042 | setDefaultEmail( QString::null ); | 1078 | setDefaultEmail( QString::null ); |
1043 | } | 1079 | } |
1044 | 1080 | ||
1045 | /*! | 1081 | /*! |
1046 | Sets the list of children for the contact to those contained in \a str. | 1082 | Sets the list of children for the contact to those contained in \a str. |
1047 | */ | 1083 | */ |
1048 | void OContact::setChildren( const QString &str ) | 1084 | void OContact::setChildren( const QString &str ) |
1049 | { | 1085 | { |
1050 | replace( Qtopia::Children, str ); | 1086 | replace( Qtopia::Children, str ); |
1051 | } | 1087 | } |
1052 | 1088 | ||
1053 | /*! | 1089 | /*! |
1054 | \overload | 1090 | \overload |
1055 | Returns TRUE if the contact matches the regular expression \a regexp. | 1091 | Returns TRUE if the contact matches the regular expression \a regexp. |
1056 | Otherwise returns FALSE. | 1092 | Otherwise returns FALSE. |
1057 | */ | 1093 | */ |
1058 | bool OContact::match( const QRegExp &r ) const | 1094 | bool OContact::match( const QRegExp &r ) const |
1059 | { | 1095 | { |
1060 | setLastHitField( -1 ); | 1096 | setLastHitField( -1 ); |
1061 | bool match; | 1097 | bool match; |
1062 | match = false; | 1098 | match = false; |
1063 | QMap<int, QString>::ConstIterator it; | 1099 | QMap<int, QString>::ConstIterator it; |
1064 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 1100 | for ( it = mMap.begin(); it != mMap.end(); ++it ) |
1065 | if ( (*it).find( r ) > -1 ) { | 1101 | { |
1102 | if ( ( *it ).find( r ) > -1 ) | ||
1103 | { | ||
1066 | setLastHitField( it.key() ); | 1104 | setLastHitField( it.key() ); |
1067 | match = true; | 1105 | match = true; |
1068 | break; | 1106 | break; |
1069 | } | 1107 | } |
1070 | } | 1108 | } |
1071 | return match; | 1109 | return match; |
1072 | } | 1110 | } |
1073 | 1111 | ||
1074 | 1112 | ||
1075 | QString OContact::toShortText() const | 1113 | QString OContact::toShortText() const |
1076 | { | 1114 | { |
1077 | return ( fullName() ); | 1115 | return ( fullName() ); |
1078 | } | 1116 | } |
1117 | |||
1118 | |||
1079 | QString OContact::type() const | 1119 | QString OContact::type() const |
1080 | { | 1120 | { |
1081 | return QString::fromLatin1( "OContact" ); | 1121 | return QString::fromLatin1( "OContact" ); |
1082 | } | 1122 | } |
1083 | 1123 | ||
1084 | 1124 | ||
1085 | |||
1086 | class QString OContact::recordField( int pos ) const | 1125 | class QString OContact::recordField( int pos ) const |
1087 | { | 1126 | { |
1088 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1127 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1089 | return SLFIELDS[pos]; | 1128 | return SLFIELDS[ pos ]; |
1090 | } | 1129 | } |
1091 | 1130 | ||
1092 | // In future releases, we should store birthday and anniversary | 1131 | // In future releases, we should store birthday and anniversary |
1093 | // internally as QDate instead of QString ! | 1132 | // internally as QDate instead of QString ! |
1094 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1133 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1095 | 1134 | ||
1096 | /*! \fn void OContact::setBirthday( const QDate& date ) | 1135 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1097 | Sets the birthday for the contact to \a date. If date is null | 1136 | Sets the birthday for the contact to \a date. If date is null |
1098 | the current stored date will be removed. | 1137 | the current stored date will be removed. |
1099 | */ | 1138 | */ |
1100 | void OContact::setBirthday( const QDate &v ) | 1139 | void OContact::setBirthday( const QDate &v ) |
1101 | { | 1140 | { |
1102 | if ( v.isNull() ){ | 1141 | if ( v.isNull() ) |
1103 | qWarning( "Remove Birthday"); | 1142 | { |
1104 | replace( Qtopia::Birthday, QString::null ); | 1143 | qWarning( "Remove Birthday" ); |
1105 | return; | 1144 | replace( Qtopia::Birthday, QString::null ); |
1106 | } | 1145 | return ; |
1146 | } | ||
1107 | 1147 | ||
1108 | if ( v.isValid() ) | 1148 | if ( v.isValid() ) |
1109 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); | 1149 | replace( Qtopia::Birthday, OConversion::dateToString( v ) ); |
1110 | 1150 | ||
1111 | } | 1151 | } |
1112 | 1152 | ||
1113 | 1153 | ||
1114 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1154 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1115 | Sets the anniversary of the contact to \a date. If date is | 1155 | Sets the anniversary of the contact to \a date. If date is |
1116 | null, the current stored date will be removed. | 1156 | null, the current stored date will be removed. |
1117 | */ | 1157 | */ |
1118 | void OContact::setAnniversary( const QDate &v ) | 1158 | void OContact::setAnniversary( const QDate &v ) |
1119 | { | 1159 | { |
1120 | if ( v.isNull() ){ | 1160 | if ( v.isNull() ) |
1121 | qWarning( "Remove Anniversary"); | 1161 | { |
1122 | replace( Qtopia::Anniversary, QString::null ); | 1162 | qWarning( "Remove Anniversary" ); |
1123 | return; | 1163 | replace( Qtopia::Anniversary, QString::null ); |
1124 | } | 1164 | return ; |
1125 | 1165 | } | |
1126 | if ( v.isValid() ) | 1166 | |
1127 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); | 1167 | if ( v.isValid() ) |
1168 | replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); | ||
1128 | } | 1169 | } |
1129 | 1170 | ||
1171 | |||
1130 | /*! \fn QDate OContact::birthday() const | 1172 | /*! \fn QDate OContact::birthday() const |
1131 | Returns the birthday of the contact. | 1173 | Returns the birthday of the contact. |
1132 | */ | 1174 | */ |
1133 | QDate OContact::birthday() const | 1175 | QDate OContact::birthday() const |
1134 | { | 1176 | { |
1135 | QString str = find( Qtopia::Birthday ); | 1177 | QString str = find( Qtopia::Birthday ); |
1136 | // qWarning ("Birthday %s", str.latin1() ); | 1178 | // qWarning ("Birthday %s", str.latin1() ); |
1137 | if ( !str.isEmpty() ) | 1179 | if ( !str.isEmpty() ) |
1138 | return OConversion::dateFromString ( str ); | 1180 | return OConversion::dateFromString ( str ); |
1139 | else | 1181 | else |
1140 | return QDate(); | 1182 | return QDate(); |
1141 | } | 1183 | } |
1142 | 1184 | ||
1143 | 1185 | ||
1144 | /*! \fn QDate OContact::anniversary() const | 1186 | /*! \fn QDate OContact::anniversary() const |
1145 | Returns the anniversary of the contact. | 1187 | Returns the anniversary of the contact. |
1146 | */ | 1188 | */ |
1147 | QDate OContact::anniversary() const | 1189 | QDate OContact::anniversary() const |
1148 | { | 1190 | { |
1149 | QDate empty; | 1191 | QDate empty; |
1150 | QString str = find( Qtopia::Anniversary ); | 1192 | QString str = find( Qtopia::Anniversary ); |
1151 | // qWarning ("Anniversary %s", str.latin1() ); | 1193 | // qWarning ("Anniversary %s", str.latin1() ); |
1152 | if ( !str.isEmpty() ) | 1194 | if ( !str.isEmpty() ) |
1153 | return OConversion::dateFromString ( str ); | 1195 | return OConversion::dateFromString ( str ); |
1154 | else | 1196 | else |
1155 | return empty; | 1197 | return empty; |
1156 | } | 1198 | } |
1157 | 1199 | ||
1158 | 1200 | ||
1159 | void OContact::insertEmail( const QString &v ) | 1201 | void OContact::insertEmail( const QString &v ) |
1160 | { | 1202 | { |
1161 | //qDebug("insertEmail %s", v.latin1()); | 1203 | //qDebug("insertEmail %s", v.latin1()); |
1162 | QString e = v.simplifyWhiteSpace(); | 1204 | QString e = v.simplifyWhiteSpace(); |
1163 | QString def = defaultEmail(); | 1205 | QString def = defaultEmail(); |
1164 | 1206 | ||
1165 | // if no default, set it as the default email and don't insert | 1207 | // if no default, set it as the default email and don't insert |
1166 | if ( def.isEmpty() ) { | 1208 | if ( def.isEmpty() ) |
1167 | setDefaultEmail( e ); // will insert into the list for us | 1209 | { |
1168 | return; | 1210 | setDefaultEmail( e ); // will insert into the list for us |
1211 | return ; | ||
1169 | } | 1212 | } |
1170 | 1213 | ||
1171 | // otherwise, insert assuming doesn't already exist | 1214 | // otherwise, insert assuming doesn't already exist |
1172 | QString emailsStr = find( Qtopia::Emails ); | 1215 | QString emailsStr = find( Qtopia::Emails ); |
1173 | if ( emailsStr.contains( e )) | 1216 | if ( emailsStr.contains( e ) ) |
1174 | return; | 1217 | return ; |
1175 | if ( !emailsStr.isEmpty() ) | 1218 | if ( !emailsStr.isEmpty() ) |
1176 | emailsStr += emailSeparator(); | 1219 | emailsStr += emailSeparator(); |
1177 | emailsStr += e; | 1220 | emailsStr += e; |
1178 | replace( Qtopia::Emails, emailsStr ); | 1221 | replace( Qtopia::Emails, emailsStr ); |
1179 | } | 1222 | } |
1180 | 1223 | ||
1181 | void OContact::removeEmail( const QString &v ) | 1224 | |
1225 | void OContact::removeEmail( const QString &v ) | ||
1182 | { | 1226 | { |
1183 | QString e = v.simplifyWhiteSpace(); | 1227 | QString e = v.simplifyWhiteSpace(); |
1184 | QString def = defaultEmail(); | 1228 | QString def = defaultEmail(); |
1185 | QString emailsStr = find( Qtopia::Emails ); | 1229 | QString emailsStr = find( Qtopia::Emails ); |
1186 | QStringList emails = emailList(); | 1230 | QStringList emails = emailList(); |
1187 | 1231 | ||
1188 | // otherwise, must first contain it | 1232 | // otherwise, must first contain it |
1189 | if ( !emailsStr.contains( e ) ) | 1233 | if ( !emailsStr.contains( e ) ) |
1190 | return; | 1234 | return ; |
1191 | 1235 | ||
1192 | // remove it | 1236 | // remove it |
1193 | //qDebug(" removing email from list %s", e.latin1()); | 1237 | //qDebug(" removing email from list %s", e.latin1()); |
1194 | emails.remove( e ); | 1238 | emails.remove( e ); |
1195 | // reset the string | 1239 | // reset the string |
1196 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 1240 | emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator |
1197 | replace( Qtopia::Emails, emailsStr ); | 1241 | replace( Qtopia::Emails, emailsStr ); |
1198 | 1242 | ||
1199 | // if default, then replace the default email with the first one | 1243 | // if default, then replace the default email with the first one |
1200 | if ( def == e ) { | 1244 | if ( def == e ) |
1201 | //qDebug("removeEmail is default; setting new default"); | 1245 | { |
1202 | if ( !emails.count() ) | 1246 | //qDebug("removeEmail is default; setting new default"); |
1203 | clearEmails(); | 1247 | if ( !emails.count() ) |
1204 | else // setDefaultEmail will remove e from the list | 1248 | clearEmails(); |
1205 | setDefaultEmail( emails.first() ); | 1249 | else // setDefaultEmail will remove e from the list |
1250 | setDefaultEmail( emails.first() ); | ||
1206 | } | 1251 | } |
1207 | } | 1252 | } |
1253 | |||
1254 | |||
1208 | void OContact::clearEmails() | 1255 | void OContact::clearEmails() |
1209 | { | 1256 | { |
1210 | mMap.remove( Qtopia::DefaultEmail ); | 1257 | mMap.remove( Qtopia::DefaultEmail ); |
1211 | mMap.remove( Qtopia::Emails ); | 1258 | mMap.remove( Qtopia::Emails ); |
1212 | } | 1259 | } |
1260 | |||
1261 | |||
1213 | void OContact::setDefaultEmail( const QString &v ) | 1262 | void OContact::setDefaultEmail( const QString &v ) |
1214 | { | 1263 | { |
1215 | QString e = v.simplifyWhiteSpace(); | 1264 | QString e = v.simplifyWhiteSpace(); |
1216 | 1265 | ||
1217 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 1266 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
1218 | replace( Qtopia::DefaultEmail, e ); | 1267 | replace( Qtopia::DefaultEmail, e ); |
1219 | 1268 | ||
1220 | if ( !e.isEmpty() ) | 1269 | if ( !e.isEmpty() ) |
1221 | insertEmail( e ); | 1270 | insertEmail( e ); |
1222 | 1271 | ||
1223 | } | 1272 | } |
1224 | 1273 | ||
1274 | |||
1225 | void OContact::insertEmails( const QStringList &v ) | 1275 | void OContact::insertEmails( const QStringList &v ) |
1226 | { | 1276 | { |
1227 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1277 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1228 | insertEmail( *it ); | 1278 | insertEmail( *it ); |
1229 | } | 1279 | } |
1230 | int OContact::rtti() { | 1280 | |
1281 | |||
1282 | int OContact::rtti() | ||
1283 | { | ||
1231 | return OPimResolver::AddressBook; | 1284 | return OPimResolver::AddressBook; |
1232 | } | 1285 | } |
1286 | |||
1287 | |||
1233 | void OContact::setUid( int i ) | 1288 | void OContact::setUid( int i ) |
1234 | { | 1289 | { |
1235 | OPimRecord::setUid(i); | 1290 | OPimRecord::setUid( i ); |
1236 | replace( Qtopia::AddressUid , QString::number(i)); | 1291 | replace( Qtopia::AddressUid , QString::number( i ) ); |
1237 | } | 1292 | } |
1238 | } | 1293 | } |
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index 34888dc..445fd7d 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h | |||
@@ -1,251 +1,256 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef __OCONTACT_H__ | ||
30 | #define __OCONTACT_H__ | ||
31 | 29 | ||
30 | #ifndef OCONTACT_H | ||
31 | #define OCONTACT_H | ||
32 | |||
33 | /* OPIE */ | ||
32 | #include <opie2/opimrecord.h> | 34 | #include <opie2/opimrecord.h> |
33 | #include <qpe/recordfields.h> | 35 | #include <qpe/recordfields.h> |
34 | 36 | ||
37 | /* QT */ | ||
35 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
36 | #include <qstringlist.h> | 39 | #include <qstringlist.h> |
37 | 40 | ||
38 | #if defined(QPC_TEMPLATEDLL) | 41 | #if defined(QPC_TEMPLATEDLL) |
39 | // MOC_SKIP_BEGIN | 42 | // MOC_SKIP_BEGIN |
40 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 43 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
41 | // MOC_SKIP_END | 44 | // MOC_SKIP_END |
42 | #endif | 45 | #endif |
43 | 46 | ||
44 | namespace Opie { | 47 | namespace Opie |
48 | { | ||
45 | class OContactPrivate; | 49 | class OContactPrivate; |
46 | 50 | ||
47 | /** | 51 | /** |
48 | * OContact class represents a specialised PIM Record for contacts. | 52 | * OContact class represents a specialised PIM Record for contacts. |
49 | * It does store all kind of persopn related information. | 53 | * It does store all kind of persopn related information. |
50 | * | 54 | * |
51 | * @short Contact Container | 55 | * @short Contact Container |
52 | * @author TT, Stefan Eiler, Holger Freyther | 56 | * @author TT, Stefan Eiler, Holger Freyther |
53 | */ | 57 | */ |
54 | class QPC_EXPORT OContact : public OPimRecord | 58 | class QPC_EXPORT OContact : public OPimRecord |
55 | { | 59 | { |
56 | friend class DataSet; | 60 | friend class DataSet; |
57 | public: | 61 | |
62 | public: | ||
58 | OContact(); | 63 | OContact(); |
59 | OContact( const QMap<int, QString> &fromMap ); | 64 | OContact( const QMap<int, QString> &fromMap ); |
60 | virtual ~OContact(); | 65 | virtual ~OContact(); |
61 | 66 | ||
62 | enum DateFormat{ | 67 | enum DateFormat{ |
63 | Zip_City_State = 0, | 68 | Zip_City_State = 0, |
64 | City_State_Zip | 69 | City_State_Zip |
65 | }; | 70 | }; |
66 | 71 | ||
67 | /* | 72 | /* |
68 | * do we need to inline them | 73 | * do we need to inline them |
69 | * if yes do we need to inline them this way? | 74 | * if yes do we need to inline them this way? |
70 | * -zecke | 75 | * -zecke |
71 | */ | 76 | */ |
72 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 77 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
73 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 78 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
74 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 79 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
75 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 80 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
76 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 81 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
77 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 82 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
78 | void setFileAs(); | 83 | void setFileAs(); |
79 | 84 | ||
80 | // default email address | 85 | // default email address |
81 | void setDefaultEmail( const QString &v ); | 86 | void setDefaultEmail( const QString &v ); |
82 | // inserts email to list and ensure's doesn't already exist | 87 | // inserts email to list and ensure's doesn't already exist |
83 | void insertEmail( const QString &v ); | 88 | void insertEmail( const QString &v ); |
84 | void removeEmail( const QString &v ); | 89 | void removeEmail( const QString &v ); |
85 | void clearEmails(); | 90 | void clearEmails(); |
86 | void insertEmails( const QStringList &v ); | 91 | void insertEmails( const QStringList &v ); |
87 | 92 | ||
88 | // home | 93 | // home |
89 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 94 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
90 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 95 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
91 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 96 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
92 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 97 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
93 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 98 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
94 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 99 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
95 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 100 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
96 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 101 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
97 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 102 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
98 | 103 | ||
99 | // business | 104 | // business |
100 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 105 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
101 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 106 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
102 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 107 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
103 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 108 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
104 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 109 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
105 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 110 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
106 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 111 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
107 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 112 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
108 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 113 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
109 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 114 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
110 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 115 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
111 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 116 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
112 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 117 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
113 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 118 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
114 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 119 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
115 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 120 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
116 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 121 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
117 | 122 | ||
118 | // personal | 123 | // personal |
119 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 124 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
120 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 125 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
121 | void setBirthday( const QDate &v ); | 126 | void setBirthday( const QDate &v ); |
122 | void setAnniversary( const QDate &v ); | 127 | void setAnniversary( const QDate &v ); |
123 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 128 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
124 | void setChildren( const QString &v ); | 129 | void setChildren( const QString &v ); |
125 | 130 | ||
126 | // other | 131 | // other |
127 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 132 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v ); } |
128 | 133 | ||
129 | virtual bool match( const QRegExp ®exp ) const; | 134 | virtual bool match( const QRegExp ®exp ) const; |
130 | 135 | ||
131 | // // custom | 136 | // // custom |
132 | // void setCustomField( const QString &key, const QString &v ) | 137 | // void setCustomField( const QString &key, const QString &v ) |
133 | // { replace(Custom- + key, v ); } | 138 | // { replace(Custom- + key, v ); } |
134 | 139 | ||
135 | // name | 140 | // name |
136 | QString fullName() const; | 141 | QString fullName() const; |
137 | QString title() const { return find( Qtopia::Title ); } | 142 | QString title() const { return find( Qtopia::Title ); } |
138 | QString firstName() const { return find( Qtopia::FirstName ); } | 143 | QString firstName() const { return find( Qtopia::FirstName ); } |
139 | QString middleName() const { return find( Qtopia::MiddleName ); } | 144 | QString middleName() const { return find( Qtopia::MiddleName ); } |
140 | QString lastName() const { return find( Qtopia::LastName ); } | 145 | QString lastName() const { return find( Qtopia::LastName ); } |
141 | QString suffix() const { return find( Qtopia::Suffix ); } | 146 | QString suffix() const { return find( Qtopia::Suffix ); } |
142 | QString fileAs() const { return find( Qtopia::FileAs ); } | 147 | QString fileAs() const { return find( Qtopia::FileAs ); } |
143 | 148 | ||
144 | 149 | ||
145 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 150 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
146 | QStringList emailList() const; | 151 | QStringList emailList() const; |
147 | 152 | ||
148 | // home | 153 | // home |
149 | /* | 154 | /* |
150 | * OPimAddress address(enum Location)const; | 155 | * OPimAddress address(enum Location)const; |
151 | * would be some how nicer... | 156 | * would be some how nicer... |
152 | * -zecke | 157 | * -zecke |
153 | */ | 158 | */ |
154 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 159 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
155 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 160 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
156 | QString homeState() const { return find( Qtopia::HomeState ); } | 161 | QString homeState() const { return find( Qtopia::HomeState ); } |
157 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 162 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
158 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 163 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
159 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 164 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
160 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 165 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
161 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 166 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
162 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 167 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
163 | /** Multi line string containing all non-empty address info in the form | 168 | /** Multi line string containing all non-empty address info in the form |
164 | * Street | 169 | * Street |
165 | * City, State Zip | 170 | * City, State Zip |
166 | * Country | 171 | * Country |
167 | */ | 172 | */ |
168 | QString displayHomeAddress() const; | 173 | QString displayHomeAddress() const; |
169 | 174 | ||
170 | // business | 175 | // business |
171 | QString company() const { return find( Qtopia::Company ); } | 176 | QString company() const { return find( Qtopia::Company ); } |
172 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 177 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
173 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 178 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
174 | QString businessState() const { return find( Qtopia::BusinessState ); } | 179 | QString businessState() const { return find( Qtopia::BusinessState ); } |
175 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 180 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
176 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 181 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
177 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 182 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
178 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 183 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
179 | QString department() const { return find( Qtopia::Department ); } | 184 | QString department() const { return find( Qtopia::Department ); } |
180 | QString office() const { return find( Qtopia::Office ); } | 185 | QString office() const { return find( Qtopia::Office ); } |
181 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 186 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
182 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 187 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
183 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 188 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
184 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 189 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
185 | QString profession() const { return find( Qtopia::Profession ); } | 190 | QString profession() const { return find( Qtopia::Profession ); } |
186 | QString assistant() const { return find( Qtopia::Assistant ); } | 191 | QString assistant() const { return find( Qtopia::Assistant ); } |
187 | QString manager() const { return find( Qtopia::Manager ); } | 192 | QString manager() const { return find( Qtopia::Manager ); } |
188 | /** Multi line string containing all non-empty address info in the form | 193 | /** Multi line string containing all non-empty address info in the form |
189 | * Street | 194 | * Street |
190 | * City, State Zip | 195 | * City, State Zip |
191 | * Country | 196 | * Country |
192 | */ | 197 | */ |
193 | QString displayBusinessAddress() const; | 198 | QString displayBusinessAddress() const; |
194 | 199 | ||
195 | //personal | 200 | //personal |
196 | QString spouse() const { return find( Qtopia::Spouse ); } | 201 | QString spouse() const { return find( Qtopia::Spouse ); } |
197 | QString gender() const { return find( Qtopia::Gender ); } | 202 | QString gender() const { return find( Qtopia::Gender ); } |
198 | QDate birthday() const; | 203 | QDate birthday() const; |
199 | QDate anniversary() const; | 204 | QDate anniversary() const; |
200 | QString nickname() const { return find( Qtopia::Nickname ); } | 205 | QString nickname() const { return find( Qtopia::Nickname ); } |
201 | QString children() const { return find( Qtopia::Children ); } | 206 | QString children() const { return find( Qtopia::Children ); } |
202 | QStringList childrenList() const; | 207 | QStringList childrenList() const; |
203 | 208 | ||
204 | // other | 209 | // other |
205 | QString notes() const { return find( Qtopia::Notes ); } | 210 | QString notes() const { return find( Qtopia::Notes ); } |
206 | QString groups() const { return find( Qtopia::Groups ); } | 211 | QString groups() const { return find( Qtopia::Groups ); } |
207 | QStringList groupList() const; | 212 | QStringList groupList() const; |
208 | 213 | ||
209 | QString toRichText() const; | 214 | QString toRichText() const; |
210 | QMap<int, QString> toMap() const; | 215 | QMap<int, QString> toMap() const; |
211 | QString field( int key ) const { return find( key ); } | 216 | QString field( int key ) const { return find( key ); } |
212 | 217 | ||
213 | 218 | ||
214 | void setUid( int i ); | 219 | void setUid( int i ); |
215 | 220 | ||
216 | QString toShortText()const; | 221 | QString toShortText() const; |
217 | QString type()const; | 222 | QString type() const; |
218 | class QString recordField(int) const; | 223 | class QString recordField( int ) const; |
219 | 224 | ||
220 | // Why private ? (eilers,se) | 225 | // Why private ? (eilers,se) |
221 | QString emailSeparator() const { return " "; } | 226 | QString emailSeparator() const { return " "; } |
222 | 227 | ||
223 | // the emails should be seperated by a comma | 228 | // the emails should be seperated by a comma |
224 | void setEmails( const QString &v ); | 229 | void setEmails( const QString &v ); |
225 | QString emails() const { return find( Qtopia::Emails ); } | 230 | QString emails() const { return find( Qtopia::Emails ); } |
226 | static int rtti(); | 231 | static int rtti(); |
227 | 232 | ||
228 | private: | 233 | private: |
229 | // The XML Backend needs some access to the private functions | 234 | // The XML Backend needs some access to the private functions |
230 | friend class OContactAccessBackend_XML; | 235 | friend class OContactAccessBackend_XML; |
231 | 236 | ||
232 | void insert( int key, const QString &value ); | 237 | void insert( int key, const QString &value ); |
233 | void replace( int key, const QString &value ); | 238 | void replace( int key, const QString &value ); |
234 | QString find( int key ) const; | 239 | QString find( int key ) const; |
235 | static QStringList fields(); | 240 | static QStringList fields(); |
236 | 241 | ||
237 | void save( QString &buf ) const; | 242 | void save( QString &buf ) const; |
238 | 243 | ||
239 | QString displayAddress( const QString &street, | 244 | QString displayAddress( const QString &street, |
240 | const QString &city, | 245 | const QString &city, |
241 | const QString &state, | 246 | const QString &state, |
242 | const QString &zip, | 247 | const QString &zip, |
243 | const QString &country ) const; | 248 | const QString &country ) const; |
244 | 249 | ||
245 | QMap<int, QString> mMap; | 250 | QMap<int, QString> mMap; |
246 | OContactPrivate *d; | 251 | OContactPrivate *d; |
247 | }; | 252 | }; |
248 | 253 | ||
249 | } | 254 | } |
250 | 255 | ||
251 | #endif | 256 | #endif |
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp index deaa1e5..bec00f7 100644 --- a/libopie2/opiepim/ocontactfields.cpp +++ b/libopie2/opiepim/ocontactfields.cpp | |||
@@ -1,508 +1,518 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <opie2/ocontactfields.h> | 30 | #include "ocontactfields.h" |
31 | 31 | ||
32 | #include <qstringlist.h> | 32 | /* OPIE */ |
33 | #include <opie2/ocontact.h> | ||
34 | #include <qpe/recordfields.h> // We should use our own enum in the future .. | ||
35 | #include <qpe/config.h> | ||
36 | |||
37 | /* QT */ | ||
33 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | #include <qstringlist.h> | ||
34 | 40 | ||
35 | // We should use our own enum in the future .. | ||
36 | #include <qpe/recordfields.h> | ||
37 | #include <qpe/config.h> | ||
38 | #include <opie2/ocontact.h> | ||
39 | 41 | ||
40 | namespace Opie { | 42 | namespace Opie |
43 | { | ||
41 | /*! | 44 | /*! |
42 | \internal | 45 | \internal |
43 | Returns a list of personal field names for a contact. | 46 | Returns a list of personal field names for a contact. |
44 | */ | 47 | */ |
45 | QStringList OContactFields::personalfields( bool sorted, bool translated ) | 48 | QStringList OContactFields::personalfields( bool sorted, bool translated ) |
46 | { | 49 | { |
47 | QStringList list; | 50 | QStringList list; |
48 | QMap<int, QString> mapIdToStr; | 51 | QMap<int, QString> mapIdToStr; |
49 | if ( translated ) | 52 | if ( translated ) |
50 | mapIdToStr = idToTrFields(); | 53 | mapIdToStr = idToTrFields(); |
51 | else | 54 | else |
52 | mapIdToStr = idToUntrFields(); | 55 | mapIdToStr = idToUntrFields(); |
53 | 56 | ||
54 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); | 57 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); |
55 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); | 58 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); |
56 | 59 | ||
57 | list.append( mapIdToStr[ Qtopia::Title ] ); | 60 | list.append( mapIdToStr[ Qtopia::Title ] ); |
58 | list.append( mapIdToStr[ Qtopia::FirstName ] ); | 61 | list.append( mapIdToStr[ Qtopia::FirstName ] ); |
59 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); | 62 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); |
60 | list.append( mapIdToStr[ Qtopia::LastName ] ); | 63 | list.append( mapIdToStr[ Qtopia::LastName ] ); |
61 | list.append( mapIdToStr[ Qtopia::Suffix ] ); | 64 | list.append( mapIdToStr[ Qtopia::Suffix ] ); |
62 | list.append( mapIdToStr[ Qtopia::FileAs ] ); | 65 | list.append( mapIdToStr[ Qtopia::FileAs ] ); |
63 | 66 | ||
64 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); | 67 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); |
65 | list.append( mapIdToStr[ Qtopia::Department ] ); | 68 | list.append( mapIdToStr[ Qtopia::Department ] ); |
66 | list.append( mapIdToStr[ Qtopia::Company ] ); | 69 | list.append( mapIdToStr[ Qtopia::Company ] ); |
67 | 70 | ||
68 | list.append( mapIdToStr[ Qtopia::Notes ] ); | 71 | list.append( mapIdToStr[ Qtopia::Notes ] ); |
69 | list.append( mapIdToStr[ Qtopia::Groups ] ); | 72 | list.append( mapIdToStr[ Qtopia::Groups ] ); |
70 | 73 | ||
71 | if (sorted) list.sort(); | 74 | if ( sorted ) list.sort(); |
72 | return list; | 75 | return list; |
73 | } | 76 | } |
74 | 77 | ||
75 | /*! | 78 | /*! |
76 | \internal | 79 | \internal |
77 | Returns a list of details field names for a contact. | 80 | Returns a list of details field names for a contact. |
78 | */ | 81 | */ |
79 | QStringList OContactFields::detailsfields( bool sorted, bool translated ) | 82 | QStringList OContactFields::detailsfields( bool sorted, bool translated ) |
80 | { | 83 | { |
81 | QStringList list; | 84 | QStringList list; |
82 | QMap<int, QString> mapIdToStr; | 85 | QMap<int, QString> mapIdToStr; |
83 | if ( translated ) | 86 | if ( translated ) |
84 | mapIdToStr = idToTrFields(); | 87 | mapIdToStr = idToTrFields(); |
85 | else | 88 | else |
86 | mapIdToStr = idToUntrFields(); | 89 | mapIdToStr = idToUntrFields(); |
87 | 90 | ||
88 | list.append( mapIdToStr[ Qtopia::Office ] ); | 91 | list.append( mapIdToStr[ Qtopia::Office ] ); |
89 | list.append( mapIdToStr[ Qtopia::Profession ] ); | 92 | list.append( mapIdToStr[ Qtopia::Profession ] ); |
90 | list.append( mapIdToStr[ Qtopia::Assistant ] ); | 93 | list.append( mapIdToStr[ Qtopia::Assistant ] ); |
91 | list.append( mapIdToStr[ Qtopia::Manager ] ); | 94 | list.append( mapIdToStr[ Qtopia::Manager ] ); |
92 | 95 | ||
93 | list.append( mapIdToStr[ Qtopia::Spouse ] ); | 96 | list.append( mapIdToStr[ Qtopia::Spouse ] ); |
94 | list.append( mapIdToStr[ Qtopia::Gender ] ); | 97 | list.append( mapIdToStr[ Qtopia::Gender ] ); |
95 | list.append( mapIdToStr[ Qtopia::Birthday ] ); | 98 | list.append( mapIdToStr[ Qtopia::Birthday ] ); |
96 | list.append( mapIdToStr[ Qtopia::Anniversary ] ); | 99 | list.append( mapIdToStr[ Qtopia::Anniversary ] ); |
97 | list.append( mapIdToStr[ Qtopia::Nickname ] ); | 100 | list.append( mapIdToStr[ Qtopia::Nickname ] ); |
98 | list.append( mapIdToStr[ Qtopia::Children ] ); | 101 | list.append( mapIdToStr[ Qtopia::Children ] ); |
99 | 102 | ||
100 | if (sorted) list.sort(); | 103 | if ( sorted ) list.sort(); |
101 | return list; | 104 | return list; |
102 | } | 105 | } |
103 | 106 | ||
104 | /*! | 107 | /*! |
105 | \internal | 108 | \internal |
106 | Returns a list of phone field names for a contact. | 109 | Returns a list of phone field names for a contact. |
107 | */ | 110 | */ |
108 | QStringList OContactFields::phonefields( bool sorted, bool translated ) | 111 | QStringList OContactFields::phonefields( bool sorted, bool translated ) |
109 | { | 112 | { |
110 | QStringList list; | 113 | QStringList list; |
111 | QMap<int, QString> mapIdToStr; | 114 | QMap<int, QString> mapIdToStr; |
112 | if ( translated ) | 115 | if ( translated ) |
113 | mapIdToStr = idToTrFields(); | 116 | mapIdToStr = idToTrFields(); |
114 | else | 117 | else |
115 | mapIdToStr = idToUntrFields(); | 118 | mapIdToStr = idToUntrFields(); |
116 | 119 | ||
117 | list.append( mapIdToStr[Qtopia::BusinessPhone] ); | 120 | list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); |
118 | list.append( mapIdToStr[Qtopia::BusinessFax] ); | 121 | list.append( mapIdToStr[ Qtopia::BusinessFax ] ); |
119 | list.append( mapIdToStr[Qtopia::BusinessMobile] ); | 122 | list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); |
120 | list.append( mapIdToStr[Qtopia::BusinessPager] ); | 123 | list.append( mapIdToStr[ Qtopia::BusinessPager ] ); |
121 | list.append( mapIdToStr[Qtopia::BusinessWebPage] ); | 124 | list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); |
122 | 125 | ||
123 | list.append( mapIdToStr[Qtopia::DefaultEmail] ); | 126 | list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); |
124 | list.append( mapIdToStr[Qtopia::Emails] ); | 127 | list.append( mapIdToStr[ Qtopia::Emails ] ); |
125 | 128 | ||
126 | list.append( mapIdToStr[Qtopia::HomePhone] ); | 129 | list.append( mapIdToStr[ Qtopia::HomePhone ] ); |
127 | list.append( mapIdToStr[Qtopia::HomeFax] ); | 130 | list.append( mapIdToStr[ Qtopia::HomeFax ] ); |
128 | list.append( mapIdToStr[Qtopia::HomeMobile] ); | 131 | list.append( mapIdToStr[ Qtopia::HomeMobile ] ); |
129 | // list.append( mapIdToStr[Qtopia::HomePager] ); | 132 | // list.append( mapIdToStr[Qtopia::HomePager] ); |
130 | list.append( mapIdToStr[Qtopia::HomeWebPage] ); | 133 | list.append( mapIdToStr[ Qtopia::HomeWebPage ] ); |
131 | 134 | ||
132 | if (sorted) list.sort(); | 135 | if ( sorted ) list.sort(); |
133 | 136 | ||
134 | return list; | 137 | return list; |
135 | } | 138 | } |
136 | 139 | ||
137 | /*! | 140 | /*! |
138 | \internal | 141 | \internal |
139 | Returns a list of field names for a contact. | 142 | Returns a list of field names for a contact. |
140 | */ | 143 | */ |
141 | QStringList OContactFields::fields( bool sorted, bool translated ) | 144 | QStringList OContactFields::fields( bool sorted, bool translated ) |
142 | { | 145 | { |
143 | QStringList list; | 146 | QStringList list; |
144 | QMap<int, QString> mapIdToStr; | 147 | QMap<int, QString> mapIdToStr; |
145 | if ( translated ) | 148 | if ( translated ) |
146 | mapIdToStr = idToTrFields(); | 149 | mapIdToStr = idToTrFields(); |
147 | else | 150 | else |
148 | mapIdToStr = idToUntrFields(); | 151 | mapIdToStr = idToUntrFields(); |
149 | 152 | ||
150 | list += personalfields( sorted, translated ); | 153 | list += personalfields( sorted, translated ); |
151 | 154 | ||
152 | list += phonefields( sorted, translated ); | 155 | list += phonefields( sorted, translated ); |
153 | 156 | ||
154 | list.append( mapIdToStr[Qtopia::BusinessStreet] ); | 157 | list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); |
155 | list.append( mapIdToStr[Qtopia::BusinessCity] ); | 158 | list.append( mapIdToStr[ Qtopia::BusinessCity ] ); |
156 | list.append( mapIdToStr[Qtopia::BusinessState] ); | 159 | list.append( mapIdToStr[ Qtopia::BusinessState ] ); |
157 | list.append( mapIdToStr[Qtopia::BusinessZip] ); | 160 | list.append( mapIdToStr[ Qtopia::BusinessZip ] ); |
158 | list.append( mapIdToStr[Qtopia::BusinessCountry] ); | 161 | list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); |
159 | 162 | ||
160 | list.append( mapIdToStr[Qtopia::HomeStreet] ); | 163 | list.append( mapIdToStr[ Qtopia::HomeStreet ] ); |
161 | list.append( mapIdToStr[Qtopia::HomeCity] ); | 164 | list.append( mapIdToStr[ Qtopia::HomeCity ] ); |
162 | list.append( mapIdToStr[Qtopia::HomeState] ); | 165 | list.append( mapIdToStr[ Qtopia::HomeState ] ); |
163 | list.append( mapIdToStr[Qtopia::HomeZip] ); | 166 | list.append( mapIdToStr[ Qtopia::HomeZip ] ); |
164 | list.append( mapIdToStr[Qtopia::HomeCountry] ); | 167 | list.append( mapIdToStr[ Qtopia::HomeCountry ] ); |
165 | 168 | ||
166 | list += detailsfields( sorted, translated ); | 169 | list += detailsfields( sorted, translated ); |
167 | 170 | ||
168 | if (sorted) list.sort(); | 171 | if ( sorted ) list.sort(); |
169 | 172 | ||
170 | return list; | 173 | return list; |
171 | } | 174 | } |
172 | 175 | ||
173 | 176 | ||
174 | /*! | 177 | /*! |
175 | \internal | 178 | \internal |
176 | Returns an untranslated list of personal field names for a contact. | 179 | Returns an untranslated list of personal field names for a contact. |
177 | */ | 180 | */ |
178 | QStringList OContactFields::untrpersonalfields( bool sorted ) | 181 | QStringList OContactFields::untrpersonalfields( bool sorted ) |
179 | { | 182 | { |
180 | return personalfields( sorted, false ); | 183 | return personalfields( sorted, false ); |
181 | } | 184 | } |
182 | 185 | ||
183 | 186 | ||
184 | /*! | 187 | /*! |
185 | \internal | 188 | \internal |
186 | Returns a translated list of personal field names for a contact. | 189 | Returns a translated list of personal field names for a contact. |
187 | */ | 190 | */ |
188 | QStringList OContactFields::trpersonalfields( bool sorted ) | 191 | QStringList OContactFields::trpersonalfields( bool sorted ) |
189 | { | 192 | { |
190 | return personalfields( sorted, true ); | 193 | return personalfields( sorted, true ); |
191 | } | 194 | } |
192 | 195 | ||
193 | 196 | ||
194 | /*! | 197 | /*! |
195 | \internal | 198 | \internal |
196 | Returns an untranslated list of details field names for a contact. | 199 | Returns an untranslated list of details field names for a contact. |
197 | */ | 200 | */ |
198 | QStringList OContactFields::untrdetailsfields( bool sorted ) | 201 | QStringList OContactFields::untrdetailsfields( bool sorted ) |
199 | { | 202 | { |
200 | return detailsfields( sorted, false ); | 203 | return detailsfields( sorted, false ); |
201 | } | 204 | } |
202 | 205 | ||
203 | 206 | ||
204 | /*! | 207 | /*! |
205 | \internal | 208 | \internal |
206 | Returns a translated list of details field names for a contact. | 209 | Returns a translated list of details field names for a contact. |
207 | */ | 210 | */ |
208 | QStringList OContactFields::trdetailsfields( bool sorted ) | 211 | QStringList OContactFields::trdetailsfields( bool sorted ) |
209 | { | 212 | { |
210 | return detailsfields( sorted, true ); | 213 | return detailsfields( sorted, true ); |
211 | } | 214 | } |
212 | 215 | ||
213 | 216 | ||
214 | /*! | 217 | /*! |
215 | \internal | 218 | \internal |
216 | Returns a translated list of phone field names for a contact. | 219 | Returns a translated list of phone field names for a contact. |
217 | */ | 220 | */ |
218 | QStringList OContactFields::trphonefields( bool sorted ) | 221 | QStringList OContactFields::trphonefields( bool sorted ) |
219 | { | 222 | { |
220 | return phonefields( sorted, true ); | 223 | return phonefields( sorted, true ); |
221 | } | 224 | } |
222 | 225 | ||
223 | /*! | 226 | /*! |
224 | \internal | 227 | \internal |
225 | Returns an untranslated list of phone field names for a contact. | 228 | Returns an untranslated list of phone field names for a contact. |
226 | */ | 229 | */ |
227 | QStringList OContactFields::untrphonefields( bool sorted ) | 230 | QStringList OContactFields::untrphonefields( bool sorted ) |
228 | { | 231 | { |
229 | return phonefields( sorted, false ); | 232 | return phonefields( sorted, false ); |
230 | } | 233 | } |
231 | 234 | ||
232 | 235 | ||
233 | /*! | 236 | /*! |
234 | \internal | 237 | \internal |
235 | Returns a translated list of field names for a contact. | 238 | Returns a translated list of field names for a contact. |
236 | */ | 239 | */ |
237 | QStringList OContactFields::trfields( bool sorted ) | 240 | QStringList OContactFields::trfields( bool sorted ) |
238 | { | 241 | { |
239 | return fields( sorted, true ); | 242 | return fields( sorted, true ); |
240 | } | 243 | } |
241 | 244 | ||
242 | /*! | 245 | /*! |
243 | \internal | 246 | \internal |
244 | Returns an untranslated list of field names for a contact. | 247 | Returns an untranslated list of field names for a contact. |
245 | */ | 248 | */ |
246 | QStringList OContactFields::untrfields( bool sorted ) | 249 | QStringList OContactFields::untrfields( bool sorted ) |
247 | { | 250 | { |
248 | return fields( sorted, false ); | 251 | return fields( sorted, false ); |
249 | } | 252 | } |
250 | 253 | ||
251 | QMap<int, QString> OContactFields::idToTrFields() | 254 | QMap<int, QString> OContactFields::idToTrFields() |
252 | { | 255 | { |
253 | QMap<int, QString> ret_map; | 256 | QMap<int, QString> ret_map; |
254 | 257 | ||
255 | ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) ); | 258 | ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) ); |
256 | ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) ); | 259 | ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) ); |
257 | 260 | ||
258 | ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") ); | 261 | ret_map.insert( Qtopia::Title, QObject::tr( "Name Title" ) ); |
259 | ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) ); | 262 | ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) ); |
260 | ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) ); | 263 | ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) ); |
261 | ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) ); | 264 | ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) ); |
262 | ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" )); | 265 | ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ) ); |
263 | ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) ); | 266 | ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) ); |
264 | 267 | ||
265 | ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) ); | 268 | ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) ); |
266 | ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) ); | 269 | ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) ); |
267 | ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) ); | 270 | ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) ); |
268 | ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) ); | 271 | ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) ); |
269 | ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) ); | 272 | ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) ); |
270 | ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" )); | 273 | ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ) ); |
271 | 274 | ||
272 | 275 | ||
273 | ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) ); | 276 | ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) ); |
274 | ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) ); | 277 | ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) ); |
275 | 278 | ||
276 | ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) ); | 279 | ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) ); |
277 | ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) ); | 280 | ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) ); |
278 | ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) ); | 281 | ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) ); |
279 | 282 | ||
280 | // business | 283 | // business |
281 | ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) ); | 284 | ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) ); |
282 | ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) ); | 285 | ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) ); |
283 | ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) ); | 286 | ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) ); |
284 | ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) ); | 287 | ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) ); |
285 | ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) ); | 288 | ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) ); |
286 | ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) ); | 289 | ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) ); |
287 | ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) ); | 290 | ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) ); |
288 | 291 | ||
289 | ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) ); | 292 | ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) ); |
290 | ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) ); | 293 | ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) ); |
291 | ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) ); | 294 | ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) ); |
292 | ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) ); | 295 | ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) ); |
293 | 296 | ||
294 | // home | 297 | // home |
295 | ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) ); | 298 | ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) ); |
296 | ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) ); | 299 | ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) ); |
297 | ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) ); | 300 | ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) ); |
298 | ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) ); | 301 | ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) ); |
299 | ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) ); | 302 | ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) ); |
300 | ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) ); | 303 | ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) ); |
301 | 304 | ||
302 | //personal | 305 | //personal |
303 | ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) ); | 306 | ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) ); |
304 | ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) ); | 307 | ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) ); |
305 | ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) ); | 308 | ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) ); |
306 | ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) ); | 309 | ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) ); |
307 | ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) ); | 310 | ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) ); |
308 | ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) ); | 311 | ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) ); |
309 | 312 | ||
310 | // other | 313 | // other |
311 | ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) ); | 314 | ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) ); |
312 | 315 | ||
313 | 316 | ||
314 | return ret_map; | 317 | return ret_map; |
315 | } | 318 | } |
316 | 319 | ||
317 | QMap<int, QString> OContactFields::idToUntrFields() | 320 | QMap<int, QString> OContactFields::idToUntrFields() |
318 | { | 321 | { |
319 | QMap<int, QString> ret_map; | 322 | QMap<int, QString> ret_map; |
320 | 323 | ||
321 | ret_map.insert( Qtopia::AddressUid, "User Id" ); | 324 | ret_map.insert( Qtopia::AddressUid, "User Id" ); |
322 | ret_map.insert( Qtopia::AddressCategory, "Categories" ); | 325 | ret_map.insert( Qtopia::AddressCategory, "Categories" ); |
323 | 326 | ||
324 | ret_map.insert( Qtopia::Title, "Name Title" ); | 327 | ret_map.insert( Qtopia::Title, "Name Title" ); |
325 | ret_map.insert( Qtopia::FirstName, "First Name" ); | 328 | ret_map.insert( Qtopia::FirstName, "First Name" ); |
326 | ret_map.insert( Qtopia::MiddleName, "Middle Name" ); | 329 | ret_map.insert( Qtopia::MiddleName, "Middle Name" ); |
327 | ret_map.insert( Qtopia::LastName, "Last Name" ); | 330 | ret_map.insert( Qtopia::LastName, "Last Name" ); |
328 | ret_map.insert( Qtopia::Suffix, "Suffix" ); | 331 | ret_map.insert( Qtopia::Suffix, "Suffix" ); |
329 | ret_map.insert( Qtopia::FileAs, "File As" ); | 332 | ret_map.insert( Qtopia::FileAs, "File As" ); |
330 | 333 | ||
331 | ret_map.insert( Qtopia::JobTitle, "Job Title" ); | 334 | ret_map.insert( Qtopia::JobTitle, "Job Title" ); |
332 | ret_map.insert( Qtopia::Department, "Department" ); | 335 | ret_map.insert( Qtopia::Department, "Department" ); |
333 | ret_map.insert( Qtopia::Company, "Company" ); | 336 | ret_map.insert( Qtopia::Company, "Company" ); |
334 | ret_map.insert( Qtopia::BusinessPhone, "Business Phone" ); | 337 | ret_map.insert( Qtopia::BusinessPhone, "Business Phone" ); |
335 | ret_map.insert( Qtopia::BusinessFax, "Business Fax" ); | 338 | ret_map.insert( Qtopia::BusinessFax, "Business Fax" ); |
336 | ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" ); | 339 | ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" ); |
337 | 340 | ||
338 | 341 | ||
339 | ret_map.insert( Qtopia::DefaultEmail, "Default Email" ); | 342 | ret_map.insert( Qtopia::DefaultEmail, "Default Email" ); |
340 | ret_map.insert( Qtopia::Emails, "Emails" ); | 343 | ret_map.insert( Qtopia::Emails, "Emails" ); |
341 | 344 | ||
342 | ret_map.insert( Qtopia::HomePhone, "Home Phone" ); | 345 | ret_map.insert( Qtopia::HomePhone, "Home Phone" ); |
343 | ret_map.insert( Qtopia::HomeFax, "Home Fax" ); | 346 | ret_map.insert( Qtopia::HomeFax, "Home Fax" ); |
344 | ret_map.insert( Qtopia::HomeMobile, "Home Mobile" ); | 347 | ret_map.insert( Qtopia::HomeMobile, "Home Mobile" ); |
345 | 348 | ||
346 | // business | 349 | // business |
347 | ret_map.insert( Qtopia::BusinessStreet, "Business Street" ); | 350 | ret_map.insert( Qtopia::BusinessStreet, "Business Street" ); |
348 | ret_map.insert( Qtopia::BusinessCity, "Business City" ); | 351 | ret_map.insert( Qtopia::BusinessCity, "Business City" ); |
349 | ret_map.insert( Qtopia::BusinessState, "Business State" ); | 352 | ret_map.insert( Qtopia::BusinessState, "Business State" ); |
350 | ret_map.insert( Qtopia::BusinessZip, "Business Zip" ); | 353 | ret_map.insert( Qtopia::BusinessZip, "Business Zip" ); |
351 | ret_map.insert( Qtopia::BusinessCountry, "Business Country" ); | 354 | ret_map.insert( Qtopia::BusinessCountry, "Business Country" ); |
352 | ret_map.insert( Qtopia::BusinessPager, "Business Pager" ); | 355 | ret_map.insert( Qtopia::BusinessPager, "Business Pager" ); |
353 | ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" ); | 356 | ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" ); |
354 | 357 | ||
355 | ret_map.insert( Qtopia::Office, "Office" ); | 358 | ret_map.insert( Qtopia::Office, "Office" ); |
356 | ret_map.insert( Qtopia::Profession, "Profession" ); | 359 | ret_map.insert( Qtopia::Profession, "Profession" ); |
357 | ret_map.insert( Qtopia::Assistant, "Assistant" ); | 360 | ret_map.insert( Qtopia::Assistant, "Assistant" ); |
358 | ret_map.insert( Qtopia::Manager, "Manager" ); | 361 | ret_map.insert( Qtopia::Manager, "Manager" ); |
359 | 362 | ||
360 | // home | 363 | // home |
361 | ret_map.insert( Qtopia::HomeStreet, "Home Street" ); | 364 | ret_map.insert( Qtopia::HomeStreet, "Home Street" ); |
362 | ret_map.insert( Qtopia::HomeCity, "Home City" ); | 365 | ret_map.insert( Qtopia::HomeCity, "Home City" ); |
363 | ret_map.insert( Qtopia::HomeState, "Home State" ); | 366 | ret_map.insert( Qtopia::HomeState, "Home State" ); |
364 | ret_map.insert( Qtopia::HomeZip, "Home Zip" ); | 367 | ret_map.insert( Qtopia::HomeZip, "Home Zip" ); |
365 | ret_map.insert( Qtopia::HomeCountry, "Home Country" ); | 368 | ret_map.insert( Qtopia::HomeCountry, "Home Country" ); |
366 | ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" ); | 369 | ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" ); |
367 | 370 | ||
368 | //personal | 371 | //personal |
369 | ret_map.insert( Qtopia::Spouse, "Spouse" ); | 372 | ret_map.insert( Qtopia::Spouse, "Spouse" ); |
370 | ret_map.insert( Qtopia::Gender, "Gender" ); | 373 | ret_map.insert( Qtopia::Gender, "Gender" ); |
371 | ret_map.insert( Qtopia::Birthday, "Birthday" ); | 374 | ret_map.insert( Qtopia::Birthday, "Birthday" ); |
372 | ret_map.insert( Qtopia::Anniversary, "Anniversary" ); | 375 | ret_map.insert( Qtopia::Anniversary, "Anniversary" ); |
373 | ret_map.insert( Qtopia::Nickname, "Nickname" ); | 376 | ret_map.insert( Qtopia::Nickname, "Nickname" ); |
374 | ret_map.insert( Qtopia::Children, "Children" ); | 377 | ret_map.insert( Qtopia::Children, "Children" ); |
375 | 378 | ||
376 | // other | 379 | // other |
377 | ret_map.insert( Qtopia::Notes, "Notes" ); | 380 | ret_map.insert( Qtopia::Notes, "Notes" ); |
378 | ret_map.insert( Qtopia::Groups, "Groups" ); | 381 | ret_map.insert( Qtopia::Groups, "Groups" ); |
379 | 382 | ||
380 | 383 | ||
381 | return ret_map; | 384 | return ret_map; |
382 | } | 385 | } |
383 | 386 | ||
384 | QMap<QString, int> OContactFields::trFieldsToId() | 387 | QMap<QString, int> OContactFields::trFieldsToId() |
385 | { | 388 | { |
386 | QMap<int, QString> idtostr = idToTrFields(); | 389 | QMap<int, QString> idtostr = idToTrFields(); |
387 | QMap<QString, int> ret_map; | 390 | QMap<QString, int> ret_map; |
388 | 391 | ||
389 | 392 | ||
390 | QMap<int, QString>::Iterator it; | 393 | QMap<int, QString>::Iterator it; |
391 | for( it = idtostr.begin(); it != idtostr.end(); ++it ) | 394 | for ( it = idtostr.begin(); it != idtostr.end(); ++it ) |
392 | ret_map.insert( *it, it.key() ); | 395 | ret_map.insert( *it, it.key() ); |
393 | 396 | ||
394 | 397 | ||
395 | return ret_map; | 398 | return ret_map; |
396 | } | 399 | } |
397 | 400 | ||
398 | /* ======================================================================= */ | 401 | /* ======================================================================= */ |
399 | 402 | ||
400 | QMap<QString, int> OContactFields::untrFieldsToId() | 403 | QMap<QString, int> OContactFields::untrFieldsToId() |
401 | { | 404 | { |
402 | QMap<int, QString> idtostr = idToUntrFields(); | 405 | QMap<int, QString> idtostr = idToUntrFields(); |
403 | QMap<QString, int> ret_map; | 406 | QMap<QString, int> ret_map; |
404 | 407 | ||
405 | 408 | ||
406 | QMap<int, QString>::Iterator it; | 409 | QMap<int, QString>::Iterator it; |
407 | for( it = idtostr.begin(); it != idtostr.end(); ++it ) | 410 | for ( it = idtostr.begin(); it != idtostr.end(); ++it ) |
408 | ret_map.insert( *it, it.key() ); | 411 | ret_map.insert( *it, it.key() ); |
409 | 412 | ||
410 | 413 | ||
411 | return ret_map; | 414 | return ret_map; |
412 | } | 415 | } |
413 | 416 | ||
414 | 417 | ||
415 | OContactFields::OContactFields(): | 418 | OContactFields::OContactFields() : |
416 | fieldOrder( DEFAULT_FIELD_ORDER ), | 419 | fieldOrder( DEFAULT_FIELD_ORDER ), |
417 | changedFieldOrder( false ) | 420 | changedFieldOrder( false ) |
418 | { | 421 | { |
419 | // Get the global field order from the config file and | 422 | // Get the global field order from the config file and |
420 | // use it as a start pattern | 423 | // use it as a start pattern |
421 | Config cfg ( "AddressBook" ); | 424 | Config cfg ( "AddressBook" ); |
422 | cfg.setGroup( "ContactFieldOrder" ); | 425 | cfg.setGroup( "ContactFieldOrder" ); |
423 | globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); | 426 | globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); |
424 | } | 427 | } |
425 | 428 | ||
426 | OContactFields::~OContactFields(){ | 429 | OContactFields::~OContactFields() |
430 | { | ||
427 | 431 | ||
428 | // We will store the fieldorder into the config file | 432 | // We will store the fieldorder into the config file |
429 | // to reuse it for the future.. | 433 | // to reuse it for the future.. |
430 | if ( changedFieldOrder ){ | 434 | if ( changedFieldOrder ) |
431 | Config cfg ( "AddressBook" ); | 435 | { |
432 | cfg.setGroup( "ContactFieldOrder" ); | 436 | Config cfg ( "AddressBook" ); |
433 | cfg.writeEntry( "General", globalFieldOrder ); | 437 | cfg.setGroup( "ContactFieldOrder" ); |
434 | } | 438 | cfg.writeEntry( "General", globalFieldOrder ); |
439 | } | ||
435 | } | 440 | } |
436 | 441 | ||
437 | 442 | ||
438 | 443 | ||
439 | void OContactFields::saveToRecord( OContact &cnt ){ | 444 | void OContactFields::saveToRecord( OContact &cnt ) |
445 | { | ||
440 | 446 | ||
441 | qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1()); | 447 | qDebug( "ocontactfields saveToRecord: >%s<", fieldOrder.latin1() ); |
442 | 448 | ||
443 | // Store fieldorder into this contact. | 449 | // Store fieldorder into this contact. |
444 | cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); | 450 | cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); |
445 | 451 | ||
446 | globalFieldOrder = fieldOrder; | 452 | globalFieldOrder = fieldOrder; |
447 | changedFieldOrder = true; | 453 | changedFieldOrder = true; |
448 | 454 | ||
449 | } | 455 | } |
450 | 456 | ||
451 | void OContactFields::loadFromRecord( const OContact &cnt ){ | 457 | void OContactFields::loadFromRecord( const OContact &cnt ) |
452 | qDebug("ocontactfields loadFromRecord"); | 458 | { |
453 | qDebug("loading >%s<",cnt.fullName().latin1()); | 459 | qDebug( "ocontactfields loadFromRecord" ); |
460 | qDebug( "loading >%s<", cnt.fullName().latin1() ); | ||
454 | 461 | ||
455 | // Get fieldorder for this contact. If none is defined, | 462 | // Get fieldorder for this contact. If none is defined, |
456 | // we will use the global one from the config file.. | 463 | // we will use the global one from the config file.. |
457 | 464 | ||
458 | fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); | 465 | fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); |
459 | 466 | ||
460 | qDebug("fieldOrder from contact>%s<",fieldOrder.latin1()); | 467 | qDebug( "fieldOrder from contact>%s<", fieldOrder.latin1() ); |
461 | 468 | ||
462 | if (fieldOrder.isEmpty()){ | 469 | if ( fieldOrder.isEmpty() ) |
463 | fieldOrder = globalFieldOrder; | 470 | { |
464 | } | 471 | fieldOrder = globalFieldOrder; |
472 | } | ||
465 | 473 | ||
466 | 474 | ||
467 | qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1()); | 475 | qDebug( "effective fieldOrder in loadFromRecord >%s<", fieldOrder.latin1() ); |
468 | } | 476 | } |
469 | 477 | ||
470 | void OContactFields::setFieldOrder( int num, int index ){ | 478 | void OContactFields::setFieldOrder( int num, int index ) |
471 | qDebug("qcontactfields setfieldorder pos %i -> %i",num,index); | 479 | { |
480 | qDebug( "qcontactfields setfieldorder pos %i -> %i", num, index ); | ||
472 | 481 | ||
473 | fieldOrder[num] = QString::number( index, 16 )[0]; | 482 | fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ]; |
474 | 483 | ||
475 | // We will store this new fieldorder globally to | 484 | // We will store this new fieldorder globally to |
476 | // remember it for contacts which have none | 485 | // remember it for contacts which have none |
477 | globalFieldOrder = fieldOrder; | 486 | globalFieldOrder = fieldOrder; |
478 | changedFieldOrder = true; | 487 | changedFieldOrder = true; |
479 | 488 | ||
480 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | 489 | qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); |
481 | } | 490 | } |
482 | 491 | ||
483 | int OContactFields::getFieldOrder( int num, int defIndex ){ | 492 | int OContactFields::getFieldOrder( int num, int defIndex ) |
484 | qDebug("ocontactfields getFieldOrder"); | 493 | { |
485 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | 494 | qDebug( "ocontactfields getFieldOrder" ); |
495 | qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); | ||
486 | 496 | ||
487 | // Get index of combo as char.. | 497 | // Get index of combo as char.. |
488 | QChar poschar = fieldOrder[num]; | 498 | QChar poschar = fieldOrder[ num ]; |
489 | 499 | ||
490 | bool ok; | 500 | bool ok; |
491 | int ret = 0; | 501 | int ret = 0; |
492 | // Convert char to number.. | 502 | // Convert char to number.. |
493 | if ( !( poschar == QChar::null ) ) | 503 | if ( !( poschar == QChar::null ) ) |
494 | ret = QString( poschar ).toInt(&ok, 16); | 504 | ret = QString( poschar ).toInt( &ok, 16 ); |
495 | else | 505 | else |
496 | ok = false; | 506 | ok = false; |
497 | 507 | ||
498 | // Return default value if index for | 508 | // Return default value if index for |
499 | // num was not set or if anything else happened.. | 509 | // num was not set or if anything else happened.. |
500 | if ( !ok ) ret = defIndex; | 510 | if ( !ok ) ret = defIndex; |
501 | 511 | ||
502 | qDebug("returning >%i<",ret); | 512 | qDebug( "returning >%i<", ret ); |
503 | 513 | ||
504 | return ret; | 514 | return ret; |
505 | 515 | ||
506 | } | 516 | } |
507 | 517 | ||
508 | } | 518 | } |
diff --git a/libopie2/opiepim/ocontactfields.h b/libopie2/opiepim/ocontactfields.h index 993ce3b..9e89532 100644 --- a/libopie2/opiepim/ocontactfields.h +++ b/libopie2/opiepim/ocontactfields.h | |||
@@ -1,96 +1,102 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_CONTACTS_FIELDS | 29 | |
30 | #define OPIE_CONTACTS_FIELDS | 30 | #ifndef OCONTACTFIELDS_H |
31 | #define OCONTACTFIELDS_H | ||
31 | 32 | ||
32 | class QStringList; | 33 | class QStringList; |
33 | 34 | ||
35 | /* OPIE */ | ||
36 | #include <opie2/ocontact.h> | ||
37 | |||
38 | /* QT */ | ||
34 | #include <qmap.h> | 39 | #include <qmap.h> |
35 | #include <qstring.h> | 40 | #include <qstring.h> |
36 | #include <opie2/ocontact.h> | ||
37 | 41 | ||
38 | #define CONTACT_FIELD_ORDER_NAME "opie-contactfield-order" | 42 | #define CONTACT_FIELD_ORDER_NAME "opie-contactfield-order" |
39 | #define DEFAULT_FIELD_ORDER "__________" | 43 | #define DEFAULT_FIELD_ORDER "__________" |
40 | |||
41 | namespace Opie { | ||
42 | class OContactFields{ | ||
43 | 44 | ||
44 | public: | 45 | namespace Opie |
46 | { | ||
47 | class OContactFields | ||
48 | { | ||
49 | |||
50 | public: | ||
45 | OContactFields(); | 51 | OContactFields(); |
46 | ~OContactFields(); | 52 | ~OContactFields(); |
47 | /** Set the index for combo boxes. | 53 | /** Set the index for combo boxes. |
48 | * Sets the <b>index</b> of combo <b>num</b>. | 54 | * Sets the <b>index</b> of combo <b>num</b>. |
49 | * @param num selects the number of the combo | 55 | * @param num selects the number of the combo |
50 | * @param index sets the index in the combo | 56 | * @param index sets the index in the combo |
51 | */ | 57 | */ |
52 | void setFieldOrder( int num, int index ); | 58 | void setFieldOrder( int num, int index ); |
53 | 59 | ||
54 | /** Get the index for combo boxes. | 60 | /** Get the index for combo boxes. |
55 | * Returns the index of combo <b>num</b> or defindex | 61 | * Returns the index of combo <b>num</b> or defindex |
56 | * if none was defined.. | 62 | * if none was defined.. |
57 | * @param num Selects the number of the combo | 63 | * @param num Selects the number of the combo |
58 | * @param defIndex will be returned if none was defined (either | 64 | * @param defIndex will be returned if none was defined (either |
59 | * globally in the config file, nor by the contact which was used | 65 | * globally in the config file, nor by the contact which was used |
60 | * by loadFromRecord() ) | 66 | * by loadFromRecord() ) |
61 | */ | 67 | */ |
62 | int getFieldOrder( int num, int defIndex); | 68 | int getFieldOrder( int num, int defIndex ); |
63 | 69 | ||
64 | /** Store fieldorder to contact. */ | 70 | /** Store fieldorder to contact. */ |
65 | void saveToRecord( OContact& ); | 71 | void saveToRecord( OContact& ); |
66 | /** Get Fieldorder from contact. */ | 72 | /** Get Fieldorder from contact. */ |
67 | void loadFromRecord( const OContact& ); | 73 | void loadFromRecord( const OContact& ); |
68 | 74 | ||
69 | private: | 75 | private: |
70 | QString fieldOrder; | 76 | QString fieldOrder; |
71 | QString globalFieldOrder; | 77 | QString globalFieldOrder; |
72 | bool changedFieldOrder; | 78 | bool changedFieldOrder; |
73 | 79 | ||
74 | public: | 80 | public: |
75 | static QStringList personalfields( bool sorted = true, bool translated = false ); | 81 | static QStringList personalfields( bool sorted = true, bool translated = false ); |
76 | static QStringList phonefields( bool sorted = true, bool translated = false ); | 82 | static QStringList phonefields( bool sorted = true, bool translated = false ); |
77 | static QStringList detailsfields( bool sorted = true, bool translated = false ); | 83 | static QStringList detailsfields( bool sorted = true, bool translated = false ); |
78 | static QStringList fields( bool sorted = true, bool translated = false ); | 84 | static QStringList fields( bool sorted = true, bool translated = false ); |
79 | 85 | ||
80 | static QStringList trpersonalfields( bool sorted = true ); | 86 | static QStringList trpersonalfields( bool sorted = true ); |
81 | static QStringList untrpersonalfields( bool sorted = true ); | 87 | static QStringList untrpersonalfields( bool sorted = true ); |
82 | static QStringList trphonefields( bool sorted = true ); | 88 | static QStringList trphonefields( bool sorted = true ); |
83 | static QStringList untrphonefields( bool sorted = true ); | 89 | static QStringList untrphonefields( bool sorted = true ); |
84 | static QStringList trdetailsfields( bool sorted = true ); | 90 | static QStringList trdetailsfields( bool sorted = true ); |
85 | static QStringList untrdetailsfields( bool sorted = true ); | 91 | static QStringList untrdetailsfields( bool sorted = true ); |
86 | static QStringList trfields( bool sorted = true ); | 92 | static QStringList trfields( bool sorted = true ); |
87 | static QStringList untrfields( bool sorted = true ); | 93 | static QStringList untrfields( bool sorted = true ); |
88 | 94 | ||
89 | static QMap<int, QString> idToTrFields(); | 95 | static QMap<int, QString> idToTrFields(); |
90 | static QMap<QString, int> trFieldsToId(); | 96 | static QMap<QString, int> trFieldsToId(); |
91 | static QMap<int, QString> idToUntrFields(); | 97 | static QMap<int, QString> idToUntrFields(); |
92 | static QMap<QString, int> untrFieldsToId(); | 98 | static QMap<QString, int> untrFieldsToId(); |
93 | 99 | ||
94 | }; | 100 | }; |
95 | } | 101 | } |
96 | #endif | 102 | #endif |
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp index de5e30b..d9cee2b 100644 --- a/libopie2/opiepim/oevent.cpp +++ b/libopie2/opiepim/oevent.cpp | |||
@@ -1,749 +1,1025 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | 3 | Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qshared.h> | ||
30 | #include <qarray.h> | ||
31 | 29 | ||
32 | #include <qpe/palmtopuidgen.h> | 30 | #include "oevent.h" |
33 | #include <qpe/categories.h> | ||
34 | #include <qpe/stringutil.h> | ||
35 | 31 | ||
32 | /* OPIE */ | ||
36 | #include <opie2/orecur.h> | 33 | #include <opie2/orecur.h> |
37 | #include <opie2/opimresolver.h> | 34 | #include <opie2/opimresolver.h> |
38 | #include <opie2/opimnotifymanager.h> | 35 | #include <opie2/opimnotifymanager.h> |
36 | #include <qpe/categories.h> | ||
37 | #include <qpe/palmtopuidgen.h> | ||
38 | #include <qpe/stringutil.h> | ||
39 | 39 | ||
40 | #include <opie2/oevent.h> | 40 | /* QT */ |
41 | #include <qshared.h> | ||
42 | #include <qarray.h> | ||
41 | 43 | ||
42 | namespace Opie { | 44 | namespace Opie |
45 | { | ||
43 | 46 | ||
44 | int OCalendarHelper::week( const QDate& date) { | 47 | int OCalendarHelper::week( const QDate& date ) |
48 | { | ||
45 | // Calculates the week this date is in within that | 49 | // Calculates the week this date is in within that |
46 | // month. Equals the "row" is is in in the month view | 50 | // month. Equals the "row" is is in in the month view |
47 | int week = 1; | 51 | int week = 1; |
48 | QDate tmp( date.year(), date.month(), 1 ); | 52 | QDate tmp( date.year(), date.month(), 1 ); |
49 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) | 53 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) |
50 | ++week; | 54 | ++week; |
51 | 55 | ||
52 | week += ( date.day() - 1 ) / 7; | 56 | week += ( date.day() - 1 ) / 7; |
53 | 57 | ||
54 | return week; | 58 | return week; |
55 | } | 59 | } |
56 | int OCalendarHelper::ocurrence( const QDate& date) { | 60 | |
61 | |||
62 | int OCalendarHelper::ocurrence( const QDate& date ) | ||
63 | { | ||
57 | // calculates the number of occurrances of this day of the | 64 | // calculates the number of occurrances of this day of the |
58 | // week till the given date (e.g 3rd Wednesday of the month) | 65 | // week till the given date (e.g 3rd Wednesday of the month) |
59 | return ( date.day() - 1 ) / 7 + 1; | 66 | return ( date.day() - 1 ) / 7 + 1; |
60 | } | 67 | } |
61 | int OCalendarHelper::dayOfWeek( char day ) { | 68 | |
69 | |||
70 | int OCalendarHelper::dayOfWeek( char day ) | ||
71 | { | ||
62 | int dayOfWeek = 1; | 72 | int dayOfWeek = 1; |
63 | char i = ORecur::MON; | 73 | char i = ORecur::MON; |
64 | while ( !( i & day ) && i <= ORecur::SUN ) { | 74 | while ( !( i & day ) && i <= ORecur::SUN ) |
75 | { | ||
65 | i <<= 1; | 76 | i <<= 1; |
66 | ++dayOfWeek; | 77 | ++dayOfWeek; |
67 | } | 78 | } |
68 | return dayOfWeek; | 79 | return dayOfWeek; |
69 | } | 80 | } |
70 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { | 81 | |
82 | |||
83 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) | ||
84 | { | ||
71 | return ( second.year() - first.year() ) * 12 + | 85 | return ( second.year() - first.year() ) * 12 + |
72 | second.month() - first.month(); | 86 | second.month() - first.month(); |
73 | } | 87 | } |
74 | 88 | ||
75 | struct OEvent::Data : public QShared { | 89 | |
76 | Data() : QShared() { | 90 | struct OEvent::Data : public QShared |
91 | { | ||
92 | Data() : QShared() | ||
93 | { | ||
77 | child = 0; | 94 | child = 0; |
78 | recur = 0; | 95 | recur = 0; |
79 | manager = 0; | 96 | manager = 0; |
80 | isAllDay = false; | 97 | isAllDay = false; |
81 | parent = 0; | 98 | parent = 0; |
82 | } | 99 | } |
83 | ~Data() { | 100 | ~Data() |
101 | { | ||
84 | delete manager; | 102 | delete manager; |
85 | delete recur; | 103 | delete recur; |
86 | } | 104 | } |
87 | QString description; | 105 | QString description; |
88 | QString location; | 106 | QString location; |
89 | OPimNotifyManager* manager; | 107 | OPimNotifyManager* manager; |
90 | ORecur* recur; | 108 | ORecur* recur; |
91 | QString note; | 109 | QString note; |
92 | QDateTime created; | 110 | QDateTime created; |
93 | QDateTime start; | 111 | QDateTime start; |
94 | QDateTime end; | 112 | QDateTime end; |
95 | bool isAllDay : 1; | 113 | bool isAllDay : 1; |
96 | QString timezone; | 114 | QString timezone; |
97 | QArray<int>* child; | 115 | QArray<int>* child; |
98 | int parent; | 116 | int parent; |
99 | }; | 117 | }; |
100 | 118 | ||
119 | |||
101 | OEvent::OEvent( int uid ) | 120 | OEvent::OEvent( int uid ) |
102 | : OPimRecord( uid ) { | 121 | : OPimRecord( uid ) |
122 | { | ||
103 | data = new Data; | 123 | data = new Data; |
104 | } | 124 | } |
105 | OEvent::OEvent( const OEvent& ev) | 125 | |
106 | : OPimRecord( ev ), data( ev.data ) | 126 | |
127 | OEvent::OEvent( const OEvent& ev ) | ||
128 | : OPimRecord( ev ), data( ev.data ) | ||
107 | { | 129 | { |
108 | data->ref(); | 130 | data->ref(); |
109 | } | 131 | } |
110 | 132 | ||
133 | |||
111 | OEvent::OEvent( const QMap<int, QString> map ) | 134 | OEvent::OEvent( const QMap<int, QString> map ) |
112 | : OPimRecord( 0 ) | 135 | : OPimRecord( 0 ) |
113 | { | 136 | { |
114 | data = new Data; | 137 | data = new Data; |
115 | 138 | ||
116 | fromMap( map ); | 139 | fromMap( map ); |
117 | } | 140 | } |
118 | 141 | ||
119 | OEvent::~OEvent() { | 142 | |
120 | if ( data->deref() ) { | 143 | OEvent::~OEvent() |
144 | { | ||
145 | if ( data->deref() ) | ||
146 | { | ||
121 | delete data; | 147 | delete data; |
122 | data = 0; | 148 | data = 0; |
123 | } | 149 | } |
124 | } | 150 | } |
125 | OEvent& OEvent::operator=( const OEvent& ev) { | 151 | |
126 | if ( this == &ev ) return *this; | 152 | |
153 | OEvent& OEvent::operator=( const OEvent& ev ) | ||
154 | { | ||
155 | if ( this == &ev ) return * this; | ||
127 | 156 | ||
128 | OPimRecord::operator=( ev ); | 157 | OPimRecord::operator=( ev ); |
129 | ev.data->ref(); | 158 | ev.data->ref(); |
130 | deref(); | 159 | deref(); |
131 | data = ev.data; | 160 | data = ev.data; |
132 | 161 | ||
133 | 162 | ||
134 | return *this; | 163 | return *this; |
135 | } | 164 | } |
136 | QString OEvent::description()const { | 165 | |
166 | |||
167 | QString OEvent::description() const | ||
168 | { | ||
137 | return data->description; | 169 | return data->description; |
138 | } | 170 | } |
139 | void OEvent::setDescription( const QString& description ) { | 171 | |
172 | |||
173 | void OEvent::setDescription( const QString& description ) | ||
174 | { | ||
140 | changeOrModify(); | 175 | changeOrModify(); |
141 | data->description = description; | 176 | data->description = description; |
142 | } | 177 | } |
143 | void OEvent::setLocation( const QString& loc ) { | 178 | |
179 | |||
180 | void OEvent::setLocation( const QString& loc ) | ||
181 | { | ||
144 | changeOrModify(); | 182 | changeOrModify(); |
145 | data->location = loc; | 183 | data->location = loc; |
146 | } | 184 | } |
147 | QString OEvent::location()const { | 185 | |
186 | |||
187 | QString OEvent::location() const | ||
188 | { | ||
148 | return data->location; | 189 | return data->location; |
149 | } | 190 | } |
150 | OPimNotifyManager &OEvent::notifiers()const { | 191 | |
192 | |||
193 | OPimNotifyManager &OEvent::notifiers() const | ||
194 | { | ||
151 | // I hope we can skip the changeOrModify here | 195 | // I hope we can skip the changeOrModify here |
152 | // the notifier should take care of it | 196 | // the notifier should take care of it |
153 | // and OPimNotify is shared too | 197 | // and OPimNotify is shared too |
154 | if (!data->manager ) | 198 | if ( !data->manager ) |
155 | data->manager = new OPimNotifyManager; | 199 | data->manager = new OPimNotifyManager; |
156 | 200 | ||
157 | return *data->manager; | 201 | return *data->manager; |
158 | } | 202 | } |
159 | bool OEvent::hasNotifiers()const { | 203 | |
160 | if (!data->manager ) | 204 | |
205 | bool OEvent::hasNotifiers() const | ||
206 | { | ||
207 | if ( !data->manager ) | ||
161 | return false; | 208 | return false; |
162 | if (data->manager->reminders().isEmpty() && | 209 | if ( data->manager->reminders().isEmpty() && |
163 | data->manager->alarms().isEmpty() ) | 210 | data->manager->alarms().isEmpty() ) |
164 | return false; | 211 | return false; |
165 | 212 | ||
166 | return true; | 213 | return true; |
167 | } | 214 | } |
168 | ORecur OEvent::recurrence()const { | 215 | |
169 | if (!data->recur) | 216 | |
217 | ORecur OEvent::recurrence() const | ||
218 | { | ||
219 | if ( !data->recur ) | ||
170 | data->recur = new ORecur; | 220 | data->recur = new ORecur; |
171 | 221 | ||
172 | return *data->recur; | 222 | return *data->recur; |
173 | } | 223 | } |
174 | void OEvent::setRecurrence( const ORecur& rec) { | 224 | |
225 | |||
226 | void OEvent::setRecurrence( const ORecur& rec ) | ||
227 | { | ||
175 | changeOrModify(); | 228 | changeOrModify(); |
176 | if (data->recur ) | 229 | if ( data->recur ) |
177 | (*data->recur) = rec; | 230 | ( *data->recur ) = rec; |
178 | else | 231 | else |
179 | data->recur = new ORecur( rec ); | 232 | data->recur = new ORecur( rec ); |
180 | } | 233 | } |
181 | bool OEvent::hasRecurrence()const { | 234 | |
182 | if (!data->recur ) return false; | 235 | |
236 | bool OEvent::hasRecurrence() const | ||
237 | { | ||
238 | if ( !data->recur ) return false; | ||
183 | return data->recur->doesRecur(); | 239 | return data->recur->doesRecur(); |
184 | } | 240 | } |
185 | QString OEvent::note()const { | 241 | |
242 | |||
243 | QString OEvent::note() const | ||
244 | { | ||
186 | return data->note; | 245 | return data->note; |
187 | } | 246 | } |
188 | void OEvent::setNote( const QString& note ) { | 247 | |
248 | |||
249 | void OEvent::setNote( const QString& note ) | ||
250 | { | ||
189 | changeOrModify(); | 251 | changeOrModify(); |
190 | data->note = note; | 252 | data->note = note; |
191 | } | 253 | } |
192 | QDateTime OEvent::createdDateTime()const { | 254 | |
255 | |||
256 | QDateTime OEvent::createdDateTime() const | ||
257 | { | ||
193 | return data->created; | 258 | return data->created; |
194 | } | 259 | } |
195 | void OEvent::setCreatedDateTime( const QDateTime& time ) { | 260 | |
261 | |||
262 | void OEvent::setCreatedDateTime( const QDateTime& time ) | ||
263 | { | ||
196 | changeOrModify(); | 264 | changeOrModify(); |
197 | data->created = time; | 265 | data->created = time; |
198 | } | 266 | } |
199 | QDateTime OEvent::startDateTime()const { | 267 | |
268 | |||
269 | QDateTime OEvent::startDateTime() const | ||
270 | { | ||
200 | if ( data->isAllDay ) | 271 | if ( data->isAllDay ) |
201 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); | 272 | return QDateTime( data->start.date(), QTime( 0, 0, 0 ) ); |
202 | return data->start; | 273 | return data->start; |
203 | } | 274 | } |
204 | QDateTime OEvent::startDateTimeInZone()const { | 275 | |
276 | |||
277 | QDateTime OEvent::startDateTimeInZone() const | ||
278 | { | ||
205 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 279 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
206 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); | 280 | if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); |
207 | 281 | ||
208 | OTimeZone zone(data->timezone ); | 282 | OTimeZone zone( data->timezone ); |
209 | return zone.toDateTime( data->start, OTimeZone::current() ); | 283 | return zone.toDateTime( data->start, OTimeZone::current() ); |
210 | } | 284 | } |
211 | void OEvent::setStartDateTime( const QDateTime& dt ) { | 285 | |
286 | |||
287 | void OEvent::setStartDateTime( const QDateTime& dt ) | ||
288 | { | ||
212 | changeOrModify(); | 289 | changeOrModify(); |
213 | data->start = dt; | 290 | data->start = dt; |
214 | } | 291 | } |
215 | QDateTime OEvent::endDateTime()const { | 292 | |
293 | |||
294 | QDateTime OEvent::endDateTime() const | ||
295 | { | ||
216 | /* | 296 | /* |
217 | * if all Day event the end time needs | 297 | * if all Day event the end time needs |
218 | * to be on the same day as the start | 298 | * to be on the same day as the start |
219 | */ | 299 | */ |
220 | if ( data->isAllDay ) | 300 | if ( data->isAllDay ) |
221 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); | 301 | return QDateTime( data->start.date(), QTime( 23, 59, 59 ) ); |
222 | return data->end; | 302 | return data->end; |
223 | } | 303 | } |
224 | QDateTime OEvent::endDateTimeInZone()const { | 304 | |
305 | |||
306 | QDateTime OEvent::endDateTimeInZone() const | ||
307 | { | ||
225 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 308 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
226 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); | 309 | if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); |
227 | 310 | ||
228 | OTimeZone zone(data->timezone ); | 311 | OTimeZone zone( data->timezone ); |
229 | return zone.toDateTime( data->end, OTimeZone::current() ); | 312 | return zone.toDateTime( data->end, OTimeZone::current() ); |
230 | } | 313 | } |
231 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 314 | |
315 | |||
316 | void OEvent::setEndDateTime( const QDateTime& dt ) | ||
317 | { | ||
232 | changeOrModify(); | 318 | changeOrModify(); |
233 | data->end = dt; | 319 | data->end = dt; |
234 | } | 320 | } |
235 | bool OEvent::isMultipleDay()const { | 321 | |
322 | |||
323 | bool OEvent::isMultipleDay() const | ||
324 | { | ||
236 | return data->end.date().day() - data->start.date().day(); | 325 | return data->end.date().day() - data->start.date().day(); |
237 | } | 326 | } |
238 | bool OEvent::isAllDay()const { | 327 | |
328 | |||
329 | bool OEvent::isAllDay() const | ||
330 | { | ||
239 | return data->isAllDay; | 331 | return data->isAllDay; |
240 | } | 332 | } |
241 | void OEvent::setAllDay( bool allDay ) { | 333 | |
334 | |||
335 | void OEvent::setAllDay( bool allDay ) | ||
336 | { | ||
242 | changeOrModify(); | 337 | changeOrModify(); |
243 | data->isAllDay = allDay; | 338 | data->isAllDay = allDay; |
244 | if (allDay ) data->timezone = "UTC"; | 339 | if ( allDay ) data->timezone = "UTC"; |
245 | } | 340 | } |
246 | void OEvent::setTimeZone( const QString& tz ) { | 341 | |
342 | |||
343 | void OEvent::setTimeZone( const QString& tz ) | ||
344 | { | ||
247 | changeOrModify(); | 345 | changeOrModify(); |
248 | data->timezone = tz; | 346 | data->timezone = tz; |
249 | } | 347 | } |
250 | QString OEvent::timeZone()const { | 348 | |
251 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 349 | |
350 | QString OEvent::timeZone() const | ||
351 | { | ||
352 | if ( data->isAllDay ) return QString::fromLatin1( "UTC" ); | ||
252 | return data->timezone; | 353 | return data->timezone; |
253 | } | 354 | } |
254 | bool OEvent::match( const QRegExp& re )const { | 355 | |
255 | if ( re.match( data->description ) != -1 ){ | 356 | |
357 | bool OEvent::match( const QRegExp& re ) const | ||
358 | { | ||
359 | if ( re.match( data->description ) != -1 ) | ||
360 | { | ||
256 | setLastHitField( Qtopia::DatebookDescription ); | 361 | setLastHitField( Qtopia::DatebookDescription ); |
257 | return true; | 362 | return true; |
258 | } | 363 | } |
259 | if ( re.match( data->note ) != -1 ){ | 364 | if ( re.match( data->note ) != -1 ) |
365 | { | ||
260 | setLastHitField( Qtopia::Note ); | 366 | setLastHitField( Qtopia::Note ); |
261 | return true; | 367 | return true; |
262 | } | 368 | } |
263 | if ( re.match( data->location ) != -1 ){ | 369 | if ( re.match( data->location ) != -1 ) |
370 | { | ||
264 | setLastHitField( Qtopia::Location ); | 371 | setLastHitField( Qtopia::Location ); |
265 | return true; | 372 | return true; |
266 | } | 373 | } |
267 | if ( re.match( data->start.toString() ) != -1 ){ | 374 | if ( re.match( data->start.toString() ) != -1 ) |
375 | { | ||
268 | setLastHitField( Qtopia::StartDateTime ); | 376 | setLastHitField( Qtopia::StartDateTime ); |
269 | return true; | 377 | return true; |
270 | } | 378 | } |
271 | if ( re.match( data->end.toString() ) != -1 ){ | 379 | if ( re.match( data->end.toString() ) != -1 ) |
380 | { | ||
272 | setLastHitField( Qtopia::EndDateTime ); | 381 | setLastHitField( Qtopia::EndDateTime ); |
273 | return true; | 382 | return true; |
274 | } | 383 | } |
275 | return false; | 384 | return false; |
276 | } | 385 | } |
277 | QString OEvent::toRichText()const { | 386 | |
387 | |||
388 | QString OEvent::toRichText() const | ||
389 | { | ||
278 | QString text, value; | 390 | QString text, value; |
279 | 391 | ||
280 | // description | 392 | // description |
281 | text += "<b><h3><img src=\"datebook/DateBook\">"; | 393 | text += "<b><h3><img src=\"datebook/DateBook\">"; |
282 | if ( !description().isEmpty() ) { | 394 | if ( !description().isEmpty() ) |
283 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" ); | 395 | { |
396 | text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "" ); | ||
284 | } | 397 | } |
285 | text += "</h3></b><br><hr><br>"; | 398 | text += "</h3></b><br><hr><br>"; |
286 | 399 | ||
287 | // location | 400 | // location |
288 | if ( !(value = location()).isEmpty() ) { | 401 | if ( !( value = location() ).isEmpty() ) |
402 | { | ||
289 | text += "<b>" + QObject::tr( "Location:" ) + "</b> "; | 403 | text += "<b>" + QObject::tr( "Location:" ) + "</b> "; |
290 | text += Qtopia::escapeString(value) + "<br>"; | 404 | text += Qtopia::escapeString( value ) + "<br>"; |
291 | } | 405 | } |
292 | 406 | ||
293 | // all day event | 407 | // all day event |
294 | if ( isAllDay() ) { | 408 | if ( isAllDay() ) |
409 | { | ||
295 | text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; | 410 | text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; |
296 | } | 411 | } |
297 | // multiple day event | 412 | // multiple day event |
298 | else if ( isMultipleDay () ) { | 413 | else if ( isMultipleDay () ) |
414 | { | ||
299 | text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; | 415 | text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; |
300 | } | 416 | } |
301 | // start & end times | 417 | // start & end times |
302 | else { | 418 | else |
419 | { | ||
303 | // start time | 420 | // start time |
304 | if ( startDateTime().isValid() ) { | 421 | if ( startDateTime().isValid() ) |
305 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | 422 | { |
306 | text += Qtopia::escapeString(startDateTime().toString() ). | 423 | text += "<b>" + QObject::tr( "Start:" ) + "</b> "; |
307 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 424 | text += Qtopia::escapeString( startDateTime().toString() ). |
425 | replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; | ||
308 | } | 426 | } |
309 | 427 | ||
310 | // end time | 428 | // end time |
311 | if ( endDateTime().isValid() ) { | 429 | if ( endDateTime().isValid() ) |
312 | text += "<b>" + QObject::tr( "End:") + "</b> "; | 430 | { |
313 | text += Qtopia::escapeString(endDateTime().toString() ). | 431 | text += "<b>" + QObject::tr( "End:" ) + "</b> "; |
314 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 432 | text += Qtopia::escapeString( endDateTime().toString() ). |
433 | replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; | ||
315 | } | 434 | } |
316 | } | 435 | } |
317 | 436 | ||
318 | // categories | 437 | // categories |
319 | if ( categoryNames("Calendar").count() ){ | 438 | if ( categoryNames( "Calendar" ).count() ) |
320 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 439 | { |
321 | text += categoryNames("Calendar").join(", "); | 440 | text += "<b>" + QObject::tr( "Category:" ) + "</b> "; |
322 | text += "<br>"; | 441 | text += categoryNames( "Calendar" ).join( ", " ); |
442 | text += "<br>"; | ||
323 | } | 443 | } |
324 | 444 | ||
325 | //notes | 445 | //notes |
326 | if ( !note().isEmpty() ) { | 446 | if ( !note().isEmpty() ) |
327 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | 447 | { |
448 | text += "<b>" + QObject::tr( "Note:" ) + "</b><br>"; | ||
328 | text += note(); | 449 | text += note(); |
329 | // text += Qtopia::escapeString(note() ). | 450 | // text += Qtopia::escapeString(note() ). |
330 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 451 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
331 | } | 452 | } |
332 | return text; | 453 | return text; |
333 | } | 454 | } |
334 | QString OEvent::toShortText()const { | 455 | |
456 | |||
457 | QString OEvent::toShortText() const | ||
458 | { | ||
335 | QString text; | 459 | QString text; |
336 | text += QString::number( startDateTime().date().day() ); | 460 | text += QString::number( startDateTime().date().day() ); |
337 | text += "."; | 461 | text += "."; |
338 | text += QString::number( startDateTime().date().month() ); | 462 | text += QString::number( startDateTime().date().month() ); |
339 | text += "."; | 463 | text += "."; |
340 | text += QString::number( startDateTime().date().year() ); | 464 | text += QString::number( startDateTime().date().year() ); |
341 | text += " "; | 465 | text += " "; |
342 | text += QString::number( startDateTime().time().hour() ); | 466 | text += QString::number( startDateTime().time().hour() ); |
343 | text += ":"; | 467 | text += ":"; |
344 | text += QString::number( startDateTime().time().minute() ); | 468 | text += QString::number( startDateTime().time().minute() ); |
345 | text += " - "; | 469 | text += " - "; |
346 | text += description(); | 470 | text += description(); |
347 | return text; | 471 | return text; |
348 | } | 472 | } |
349 | QString OEvent::type()const { | 473 | |
350 | return QString::fromLatin1("OEvent"); | 474 | |
475 | QString OEvent::type() const | ||
476 | { | ||
477 | return QString::fromLatin1( "OEvent" ); | ||
351 | } | 478 | } |
352 | QString OEvent::recordField( int /*id */ )const { | 479 | |
480 | |||
481 | QString OEvent::recordField( int /*id */ ) const | ||
482 | { | ||
353 | return QString::null; | 483 | return QString::null; |
354 | } | 484 | } |
355 | int OEvent::rtti() { | 485 | |
486 | |||
487 | int OEvent::rtti() | ||
488 | { | ||
356 | return OPimResolver::DateBook; | 489 | return OPimResolver::DateBook; |
357 | } | 490 | } |
358 | bool OEvent::loadFromStream( QDataStream& ) { | 491 | |
492 | |||
493 | bool OEvent::loadFromStream( QDataStream& ) | ||
494 | { | ||
359 | return true; | 495 | return true; |
360 | } | 496 | } |
361 | bool OEvent::saveToStream( QDataStream& )const { | 497 | |
498 | |||
499 | bool OEvent::saveToStream( QDataStream& ) const | ||
500 | { | ||
362 | return true; | 501 | return true; |
363 | } | 502 | } |
364 | void OEvent::changeOrModify() { | 503 | |
365 | if ( data->count != 1 ) { | 504 | |
505 | void OEvent::changeOrModify() | ||
506 | { | ||
507 | if ( data->count != 1 ) | ||
508 | { | ||
366 | data->deref(); | 509 | data->deref(); |
367 | Data* d2 = new Data; | 510 | Data* d2 = new Data; |
368 | d2->description = data->description; | 511 | d2->description = data->description; |
369 | d2->location = data->location; | 512 | d2->location = data->location; |
370 | 513 | ||
371 | if (data->manager ) | 514 | if ( data->manager ) |
372 | d2->manager = new OPimNotifyManager( *data->manager ); | 515 | d2->manager = new OPimNotifyManager( *data->manager ); |
373 | 516 | ||
374 | if ( data->recur ) | 517 | if ( data->recur ) |
375 | d2->recur = new ORecur( *data->recur ); | 518 | d2->recur = new ORecur( *data->recur ); |
376 | 519 | ||
377 | d2->note = data->note; | 520 | d2->note = data->note; |
378 | d2->created = data->created; | 521 | d2->created = data->created; |
379 | d2->start = data->start; | 522 | d2->start = data->start; |
380 | d2->end = data->end; | 523 | d2->end = data->end; |
381 | d2->isAllDay = data->isAllDay; | 524 | d2->isAllDay = data->isAllDay; |
382 | d2->timezone = data->timezone; | 525 | d2->timezone = data->timezone; |
383 | d2->parent = data->parent; | 526 | d2->parent = data->parent; |
384 | 527 | ||
385 | if ( data->child ) { | 528 | if ( data->child ) |
529 | { | ||
386 | d2->child = new QArray<int>( *data->child ); | 530 | d2->child = new QArray<int>( *data->child ); |
387 | d2->child->detach(); | 531 | d2->child->detach(); |
388 | } | 532 | } |
389 | 533 | ||
390 | data = d2; | 534 | data = d2; |
391 | } | 535 | } |
392 | } | 536 | } |
393 | void OEvent::deref() { | 537 | |
394 | if ( data->deref() ) { | 538 | |
539 | void OEvent::deref() | ||
540 | { | ||
541 | if ( data->deref() ) | ||
542 | { | ||
395 | delete data; | 543 | delete data; |
396 | data = 0; | 544 | data = 0; |
397 | } | 545 | } |
398 | } | 546 | } |
399 | // Exporting Event data to map. Using the same | 547 | // Exporting Event data to map. Using the same |
400 | // encoding as ODateBookAccessBackend_xml does.. | 548 | // encoding as ODateBookAccessBackend_xml does.. |
401 | // Thus, we could remove the stuff there and use this | 549 | // Thus, we could remove the stuff there and use this |
402 | // for it and for all other places.. | 550 | // for it and for all other places.. |
403 | // Encoding should happen at one place, only ! (eilers) | 551 | // Encoding should happen at one place, only ! (eilers) |
404 | QMap<int, QString> OEvent::toMap()const { | 552 | QMap<int, QString> OEvent::toMap() const |
553 | { | ||
405 | QMap<int, QString> retMap; | 554 | QMap<int, QString> retMap; |
406 | 555 | ||
407 | retMap.insert( OEvent::FUid, QString::number( uid() ) ); | 556 | retMap.insert( OEvent::FUid, QString::number( uid() ) ); |
408 | retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) )); | 557 | retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) ); |
409 | retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) ); | 558 | retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) ); |
410 | retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) ); | 559 | retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) ); |
411 | retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" ); | 560 | retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" ); |
412 | OPimAlarm alarm = notifiers().alarms()[0]; | 561 | OPimAlarm alarm = notifiers().alarms() [ 0 ]; |
413 | retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); | 562 | retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); |
414 | retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" ); | 563 | retMap.insert( OEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); |
415 | 564 | ||
416 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); | 565 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); |
417 | retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) ); | 566 | retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) ); |
418 | retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) ); | 567 | retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) ); |
419 | retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) ); | 568 | retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) ); |
420 | retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); | 569 | retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); |
421 | if( parent() ) | 570 | if ( parent() ) |
422 | retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); | 571 | retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); |
423 | if( children().count() ){ | 572 | if ( children().count() ) |
424 | QArray<int> childr = children(); | 573 | { |
425 | QString buf; | 574 | QArray<int> childr = children(); |
426 | for ( uint i = 0; i < childr.count(); i++ ) { | 575 | QString buf; |
427 | if ( i != 0 ) buf += " "; | 576 | for ( uint i = 0; i < childr.count(); i++ ) |
428 | buf += QString::number( childr[i] ); | 577 | { |
429 | } | 578 | if ( i != 0 ) buf += " "; |
430 | retMap.insert( OEvent::FRecChildren, buf ); | 579 | buf += QString::number( childr[ i ] ); |
431 | } | 580 | } |
432 | 581 | retMap.insert( OEvent::FRecChildren, buf ); | |
582 | } | ||
583 | |||
433 | // Add recurrence stuff | 584 | // Add recurrence stuff |
434 | if( hasRecurrence() ){ | 585 | if ( hasRecurrence() ) |
435 | ORecur recur = recurrence(); | 586 | { |
436 | QMap<int, QString> recFields = recur.toMap(); | 587 | ORecur recur = recurrence(); |
437 | retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); | 588 | QMap<int, QString> recFields = recur.toMap(); |
438 | retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] ); | 589 | retMap.insert( OEvent::FRType, recFields[ ORecur::RType ] ); |
439 | retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] ); | 590 | retMap.insert( OEvent::FRWeekdays, recFields[ ORecur::RWeekdays ] ); |
440 | retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] ); | 591 | retMap.insert( OEvent::FRPosition, recFields[ ORecur::RPosition ] ); |
441 | retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] ); | 592 | retMap.insert( OEvent::FRFreq, recFields[ ORecur::RFreq ] ); |
442 | retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] ); | 593 | retMap.insert( OEvent::FRHasEndDate, recFields[ ORecur::RHasEndDate ] ); |
443 | retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] ); | 594 | retMap.insert( OEvent::FREndDate, recFields[ ORecur::EndDate ] ); |
444 | retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); | 595 | retMap.insert( OEvent::FRCreated, recFields[ ORecur::Created ] ); |
445 | } else { | 596 | retMap.insert( OEvent::FRExceptions, recFields[ ORecur::Exceptions ] ); |
446 | ORecur recur = recurrence(); | 597 | } |
447 | QMap<int, QString> recFields = recur.toMap(); | 598 | else |
448 | retMap.insert( OEvent::FRType, recFields[ORecur::RType] ); | 599 | { |
449 | } | 600 | ORecur recur = recurrence(); |
450 | 601 | QMap<int, QString> recFields = recur.toMap(); | |
602 | retMap.insert( OEvent::FRType, recFields[ ORecur::RType ] ); | ||
603 | } | ||
604 | |||
451 | return retMap; | 605 | return retMap; |
452 | } | 606 | } |
453 | 607 | ||
608 | |||
454 | void OEvent::fromMap( const QMap<int, QString>& map ) | 609 | void OEvent::fromMap( const QMap<int, QString>& map ) |
455 | { | 610 | { |
456 | 611 | ||
457 | // We just want to set the UID if it is really stored. | 612 | // We just want to set the UID if it is really stored. |
458 | if ( !map[OEvent::FUid].isEmpty() ) | 613 | if ( !map[ OEvent::FUid ].isEmpty() ) |
459 | setUid( map[OEvent::FUid].toInt() ); | 614 | setUid( map[ OEvent::FUid ].toInt() ); |
460 | 615 | ||
461 | setCategories( idsFromString( map[OEvent::FCategories] ) ); | 616 | setCategories( idsFromString( map[ OEvent::FCategories ] ) ); |
462 | setDescription( map[OEvent::FDescription] ); | 617 | setDescription( map[ OEvent::FDescription ] ); |
463 | setLocation( map[OEvent::FLocation] ); | 618 | setLocation( map[ OEvent::FLocation ] ); |
464 | 619 | ||
465 | if ( map[OEvent::FType] == "AllDay" ) | 620 | if ( map[ OEvent::FType ] == "AllDay" ) |
466 | setAllDay( true ); | 621 | setAllDay( true ); |
467 | else | 622 | else |
468 | setAllDay( false ); | 623 | setAllDay( false ); |
469 | 624 | ||
470 | int alarmTime = -1; | 625 | int alarmTime = -1; |
471 | if( !map[OEvent::FAlarm].isEmpty() ) | 626 | if ( !map[ OEvent::FAlarm ].isEmpty() ) |
472 | alarmTime = map[OEvent::FAlarm].toInt(); | 627 | alarmTime = map[ OEvent::FAlarm ].toInt(); |
473 | 628 | ||
474 | int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); | 629 | int sound = ( ( map[ OEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); |
475 | if ( ( alarmTime != -1 ) ){ | 630 | if ( ( alarmTime != -1 ) ) |
476 | QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 ); | 631 | { |
477 | OPimAlarm al( sound , dt ); | 632 | QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 ); |
478 | notifiers().add( al ); | 633 | OPimAlarm al( sound , dt ); |
479 | } | 634 | notifiers().add( al ); |
480 | if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){ | 635 | } |
481 | setTimeZone( map[OEvent::FTimeZone] ); | 636 | if ( !map[ OEvent::FTimeZone ].isEmpty() && ( map[ OEvent::FTimeZone ] != "None" ) ) |
482 | } | 637 | { |
483 | 638 | setTimeZone( map[ OEvent::FTimeZone ] ); | |
484 | time_t start = (time_t) map[OEvent::FStart].toLong(); | 639 | } |
485 | time_t end = (time_t) map[OEvent::FEnd].toLong(); | 640 | |
486 | 641 | time_t start = ( time_t ) map[ OEvent::FStart ].toLong(); | |
487 | /* AllDay is always in UTC */ | 642 | time_t end = ( time_t ) map[ OEvent::FEnd ].toLong(); |
488 | if ( isAllDay() ) { | 643 | |
489 | OTimeZone utc = OTimeZone::utc(); | 644 | /* AllDay is always in UTC */ |
490 | setStartDateTime( utc.fromUTCDateTime( start ) ); | 645 | if ( isAllDay() ) |
491 | setEndDateTime ( utc.fromUTCDateTime( end ) ); | 646 | { |
492 | setTimeZone( "UTC"); // make sure it is really utc | 647 | OTimeZone utc = OTimeZone::utc(); |
493 | }else { | 648 | setStartDateTime( utc.fromUTCDateTime( start ) ); |
494 | /* to current date time */ | 649 | setEndDateTime ( utc.fromUTCDateTime( end ) ); |
495 | // qWarning(" Start is %d", start ); | 650 | setTimeZone( "UTC" ); // make sure it is really utc |
496 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); | 651 | } |
497 | QDateTime date = zone.toDateTime( start ); | 652 | else |
498 | qWarning(" Start is %s", date.toString().latin1() ); | 653 | { |
499 | setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 654 | /* to current date time */ |
500 | 655 | // qWarning(" Start is %d", start ); | |
501 | date = zone.toDateTime( end ); | 656 | OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); |
502 | setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 657 | QDateTime date = zone.toDateTime( start ); |
503 | } | 658 | qWarning( " Start is %s", date.toString().latin1() ); |
504 | 659 | setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | |
505 | if ( !map[OEvent::FRecParent].isEmpty() ) | 660 | |
506 | setParent( map[OEvent::FRecParent].toInt() ); | 661 | date = zone.toDateTime( end ); |
507 | 662 | setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | |
508 | if ( !map[OEvent::FRecChildren].isEmpty() ){ | 663 | } |
509 | QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] ); | 664 | |
510 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 665 | if ( !map[ OEvent::FRecParent ].isEmpty() ) |
511 | addChild( (*it).toInt() ); | 666 | setParent( map[ OEvent::FRecParent ].toInt() ); |
512 | } | 667 | |
513 | } | 668 | if ( !map[ OEvent::FRecChildren ].isEmpty() ) |
514 | 669 | { | |
515 | // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. | 670 | QStringList list = QStringList::split( ' ', map[ OEvent::FRecChildren ] ); |
516 | if( !map[OEvent::FRType].isEmpty() ){ | 671 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
517 | QMap<int, QString> recFields; | 672 | { |
518 | recFields.insert( ORecur::RType, map[OEvent::FRType] ); | 673 | addChild( ( *it ).toInt() ); |
519 | recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] ); | 674 | } |
520 | recFields.insert( ORecur::RPosition, map[OEvent::FRPosition] ); | 675 | } |
521 | recFields.insert( ORecur::RFreq, map[OEvent::FRFreq] ); | 676 | |
522 | recFields.insert( ORecur::RHasEndDate, map[OEvent::FRHasEndDate] ); | 677 | // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. |
523 | recFields.insert( ORecur::EndDate, map[OEvent::FREndDate] ); | 678 | if ( !map[ OEvent::FRType ].isEmpty() ) |
524 | recFields.insert( ORecur::Created, map[OEvent::FRCreated] ); | 679 | { |
525 | recFields.insert( ORecur::Exceptions, map[OEvent::FRExceptions] ); | 680 | QMap<int, QString> recFields; |
526 | ORecur recur( recFields ); | 681 | recFields.insert( ORecur::RType, map[ OEvent::FRType ] ); |
527 | setRecurrence( recur ); | 682 | recFields.insert( ORecur::RWeekdays, map[ OEvent::FRWeekdays ] ); |
528 | } | 683 | recFields.insert( ORecur::RPosition, map[ OEvent::FRPosition ] ); |
529 | 684 | recFields.insert( ORecur::RFreq, map[ OEvent::FRFreq ] ); | |
530 | } | 685 | recFields.insert( ORecur::RHasEndDate, map[ OEvent::FRHasEndDate ] ); |
531 | 686 | recFields.insert( ORecur::EndDate, map[ OEvent::FREndDate ] ); | |
532 | 687 | recFields.insert( ORecur::Created, map[ OEvent::FRCreated ] ); | |
533 | int OEvent::parent()const { | 688 | recFields.insert( ORecur::Exceptions, map[ OEvent::FRExceptions ] ); |
689 | ORecur recur( recFields ); | ||
690 | setRecurrence( recur ); | ||
691 | } | ||
692 | |||
693 | } | ||
694 | |||
695 | |||
696 | int OEvent::parent() const | ||
697 | { | ||
534 | return data->parent; | 698 | return data->parent; |
535 | } | 699 | } |
536 | void OEvent::setParent( int uid ) { | 700 | |
701 | |||
702 | void OEvent::setParent( int uid ) | ||
703 | { | ||
537 | changeOrModify(); | 704 | changeOrModify(); |
538 | data->parent = uid; | 705 | data->parent = uid; |
539 | } | 706 | } |
540 | QArray<int> OEvent::children() const{ | 707 | |
541 | if (!data->child) return QArray<int>(); | 708 | |
709 | QArray<int> OEvent::children() const | ||
710 | { | ||
711 | if ( !data->child ) return QArray<int>(); | ||
542 | else | 712 | else |
543 | return data->child->copy(); | 713 | return data->child->copy(); |
544 | } | 714 | } |
545 | void OEvent::setChildren( const QArray<int>& arr ) { | 715 | |
716 | |||
717 | void OEvent::setChildren( const QArray<int>& arr ) | ||
718 | { | ||
546 | changeOrModify(); | 719 | changeOrModify(); |
547 | if (data->child) delete data->child; | 720 | if ( data->child ) delete data->child; |
548 | 721 | ||
549 | data->child = new QArray<int>( arr ); | 722 | data->child = new QArray<int>( arr ); |
550 | data->child->detach(); | 723 | data->child->detach(); |
551 | } | 724 | } |
552 | void OEvent::addChild( int uid ) { | 725 | |
726 | |||
727 | void OEvent::addChild( int uid ) | ||
728 | { | ||
553 | changeOrModify(); | 729 | changeOrModify(); |
554 | if (!data->child ) { | 730 | if ( !data->child ) |
555 | data->child = new QArray<int>(1); | 731 | { |
556 | (*data->child)[0] = uid; | 732 | data->child = new QArray<int>( 1 ); |
557 | }else{ | 733 | ( *data->child ) [ 0 ] = uid; |
734 | } | ||
735 | else | ||
736 | { | ||
558 | int count = data->child->count(); | 737 | int count = data->child->count(); |
559 | data->child->resize( count + 1 ); | 738 | data->child->resize( count + 1 ); |
560 | (*data->child)[count] = uid; | 739 | ( *data->child ) [ count ] = uid; |
561 | } | 740 | } |
562 | } | 741 | } |
563 | void OEvent::removeChild( int uid ) { | 742 | |
564 | if (!data->child || !data->child->contains( uid ) ) return; | 743 | |
744 | void OEvent::removeChild( int uid ) | ||
745 | { | ||
746 | if ( !data->child || !data->child->contains( uid ) ) return ; | ||
565 | changeOrModify(); | 747 | changeOrModify(); |
566 | QArray<int> newAr( data->child->count() - 1 ); | 748 | QArray<int> newAr( data->child->count() - 1 ); |
567 | int j = 0; | 749 | int j = 0; |
568 | uint count = data->child->count(); | 750 | uint count = data->child->count(); |
569 | for ( uint i = 0; i < count; i++ ) { | 751 | for ( uint i = 0; i < count; i++ ) |
570 | if ( (*data->child)[i] != uid ) { | 752 | { |
571 | newAr[j] = (*data->child)[i]; | 753 | if ( ( *data->child ) [ i ] != uid ) |
754 | { | ||
755 | newAr[ j ] = ( *data->child ) [ i ]; | ||
572 | j++; | 756 | j++; |
573 | } | 757 | } |
574 | } | 758 | } |
575 | (*data->child) = newAr; | 759 | ( *data->child ) = newAr; |
576 | } | 760 | } |
577 | struct OEffectiveEvent::Data : public QShared { | 761 | |
578 | Data() : QShared() { | 762 | |
579 | } | 763 | struct OEffectiveEvent::Data : public QShared |
764 | { | ||
765 | Data() : QShared() | ||
766 | {} | ||
580 | OEvent event; | 767 | OEvent event; |
581 | QDate date; | 768 | QDate date; |
582 | QTime start, end; | 769 | QTime start, end; |
583 | QDate startDate, endDate; | 770 | QDate startDate, endDate; |
584 | bool dates : 1; | 771 | bool dates : 1; |
585 | }; | 772 | }; |
586 | 773 | ||
587 | OEffectiveEvent::OEffectiveEvent() { | 774 | |
775 | OEffectiveEvent::OEffectiveEvent() | ||
776 | { | ||
588 | data = new Data; | 777 | data = new Data; |
589 | data->date = QDate::currentDate(); | 778 | data->date = QDate::currentDate(); |
590 | data->start = data->end = QTime::currentTime(); | 779 | data->start = data->end = QTime::currentTime(); |
591 | data->dates = false; | 780 | data->dates = false; |
592 | } | 781 | } |
782 | |||
783 | |||
593 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, | 784 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, |
594 | Position pos ) { | 785 | Position pos ) |
786 | { | ||
595 | data = new Data; | 787 | data = new Data; |
596 | data->event = ev; | 788 | data->event = ev; |
597 | data->date = startDate; | 789 | data->date = startDate; |
598 | if ( pos & Start ) | 790 | if ( pos & Start ) |
599 | data->start = ev.startDateTime().time(); | 791 | data->start = ev.startDateTime().time(); |
600 | else | 792 | else |
601 | data->start = QTime( 0, 0, 0 ); | 793 | data->start = QTime( 0, 0, 0 ); |
602 | 794 | ||
603 | if ( pos & End ) | 795 | if ( pos & End ) |
604 | data->end = ev.endDateTime().time(); | 796 | data->end = ev.endDateTime().time(); |
605 | else | 797 | else |
606 | data->end = QTime( 23, 59, 59 ); | 798 | data->end = QTime( 23, 59, 59 ); |
607 | 799 | ||
608 | data->dates = false; | 800 | data->dates = false; |
609 | } | 801 | } |
610 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { | 802 | |
803 | |||
804 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev ) | ||
805 | { | ||
611 | data = ev.data; | 806 | data = ev.data; |
612 | data->ref(); | 807 | data->ref(); |
613 | } | 808 | } |
614 | OEffectiveEvent::~OEffectiveEvent() { | 809 | |
615 | if ( data->deref() ) { | 810 | |
811 | OEffectiveEvent::~OEffectiveEvent() | ||
812 | { | ||
813 | if ( data->deref() ) | ||
814 | { | ||
616 | delete data; | 815 | delete data; |
617 | data = 0; | 816 | data = 0; |
618 | } | 817 | } |
619 | } | 818 | } |
620 | OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { | 819 | |
621 | if ( *this == ev ) return *this; | 820 | |
821 | OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) | ||
822 | { | ||
823 | if ( *this == ev ) return * this; | ||
622 | 824 | ||
623 | ev.data->ref(); | 825 | ev.data->ref(); |
624 | deref(); | 826 | deref(); |
625 | data = ev.data; | 827 | data = ev.data; |
626 | 828 | ||
627 | return *this; | 829 | return *this; |
628 | } | 830 | } |
629 | 831 | ||
630 | void OEffectiveEvent::setStartTime( const QTime& ti) { | 832 | |
833 | void OEffectiveEvent::setStartTime( const QTime& ti ) | ||
834 | { | ||
631 | changeOrModify(); | 835 | changeOrModify(); |
632 | data->start = ti; | 836 | data->start = ti; |
633 | } | 837 | } |
634 | void OEffectiveEvent::setEndTime( const QTime& en) { | 838 | |
839 | |||
840 | void OEffectiveEvent::setEndTime( const QTime& en ) | ||
841 | { | ||
635 | changeOrModify(); | 842 | changeOrModify(); |
636 | data->end = en; | 843 | data->end = en; |
637 | } | 844 | } |
638 | void OEffectiveEvent::setEvent( const OEvent& ev) { | 845 | |
846 | |||
847 | void OEffectiveEvent::setEvent( const OEvent& ev ) | ||
848 | { | ||
639 | changeOrModify(); | 849 | changeOrModify(); |
640 | data->event = ev; | 850 | data->event = ev; |
641 | } | 851 | } |
642 | void OEffectiveEvent::setDate( const QDate& da) { | 852 | |
853 | |||
854 | void OEffectiveEvent::setDate( const QDate& da ) | ||
855 | { | ||
643 | changeOrModify(); | 856 | changeOrModify(); |
644 | data->date = da; | 857 | data->date = da; |
645 | } | 858 | } |
859 | |||
860 | |||
646 | void OEffectiveEvent::setEffectiveDates( const QDate& from, | 861 | void OEffectiveEvent::setEffectiveDates( const QDate& from, |
647 | const QDate& to ) { | 862 | const QDate& to ) |
648 | if (!from.isValid() ) { | 863 | { |
864 | if ( !from.isValid() ) | ||
865 | { | ||
649 | data->dates = false; | 866 | data->dates = false; |
650 | return; | 867 | return ; |
651 | } | 868 | } |
652 | 869 | ||
653 | data->startDate = from; | 870 | data->startDate = from; |
654 | data->endDate = to; | 871 | data->endDate = to; |
655 | } | 872 | } |
656 | QString OEffectiveEvent::description()const { | 873 | |
874 | |||
875 | QString OEffectiveEvent::description() const | ||
876 | { | ||
657 | return data->event.description(); | 877 | return data->event.description(); |
658 | } | 878 | } |
659 | QString OEffectiveEvent::location()const { | 879 | |
880 | |||
881 | QString OEffectiveEvent::location() const | ||
882 | { | ||
660 | return data->event.location(); | 883 | return data->event.location(); |
661 | } | 884 | } |
662 | QString OEffectiveEvent::note()const { | 885 | |
886 | |||
887 | QString OEffectiveEvent::note() const | ||
888 | { | ||
663 | return data->event.note(); | 889 | return data->event.note(); |
664 | } | 890 | } |
665 | OEvent OEffectiveEvent::event()const { | 891 | |
892 | |||
893 | OEvent OEffectiveEvent::event() const | ||
894 | { | ||
666 | return data->event; | 895 | return data->event; |
667 | } | 896 | } |
668 | QTime OEffectiveEvent::startTime()const { | 897 | |
898 | |||
899 | QTime OEffectiveEvent::startTime() const | ||
900 | { | ||
669 | return data->start; | 901 | return data->start; |
670 | } | 902 | } |
671 | QTime OEffectiveEvent::endTime()const { | 903 | |
904 | |||
905 | QTime OEffectiveEvent::endTime() const | ||
906 | { | ||
672 | return data->end; | 907 | return data->end; |
673 | } | 908 | } |
674 | QDate OEffectiveEvent::date()const { | 909 | |
910 | |||
911 | QDate OEffectiveEvent::date() const | ||
912 | { | ||
675 | return data->date; | 913 | return data->date; |
676 | } | 914 | } |
677 | int OEffectiveEvent::length()const { | 915 | |
678 | return (data->end.hour() * 60 - data->start.hour() * 60) | 916 | |
679 | + QABS(data->start.minute() - data->end.minute() ); | 917 | int OEffectiveEvent::length() const |
918 | { | ||
919 | return ( data->end.hour() * 60 - data->start.hour() * 60 ) | ||
920 | + QABS( data->start.minute() - data->end.minute() ); | ||
680 | } | 921 | } |
681 | int OEffectiveEvent::size()const { | 922 | |
923 | |||
924 | int OEffectiveEvent::size() const | ||
925 | { | ||
682 | return ( data->end.hour() - data->start.hour() ) * 3600 | 926 | return ( data->end.hour() - data->start.hour() ) * 3600 |
683 | + (data->end.minute() - data->start.minute() * 60 | 927 | + ( data->end.minute() - data->start.minute() * 60 |
684 | + data->end.second() - data->start.second() ); | 928 | + data->end.second() - data->start.second() ); |
685 | } | 929 | } |
686 | QDate OEffectiveEvent::startDate()const { | 930 | |
931 | |||
932 | QDate OEffectiveEvent::startDate() const | ||
933 | { | ||
687 | if ( data->dates ) | 934 | if ( data->dates ) |
688 | return data->startDate; | 935 | return data->startDate; |
689 | else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer | 936 | else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer |
690 | return data->date; | 937 | return data->date; |
691 | else | 938 | else |
692 | return data->event.startDateTime().date(); | 939 | return data->event.startDateTime().date(); |
693 | } | 940 | } |
694 | QDate OEffectiveEvent::endDate()const { | 941 | |
942 | |||
943 | QDate OEffectiveEvent::endDate() const | ||
944 | { | ||
695 | if ( data->dates ) | 945 | if ( data->dates ) |
696 | return data->endDate; | 946 | return data->endDate; |
697 | else if ( data->event.hasRecurrence() ) | 947 | else if ( data->event.hasRecurrence() ) |
698 | return data->date; | 948 | return data->date; |
699 | else | 949 | else |
700 | return data->event.endDateTime().date(); | 950 | return data->event.endDateTime().date(); |
701 | } | 951 | } |
702 | void OEffectiveEvent::deref() { | 952 | |
703 | if ( data->deref() ) { | 953 | |
954 | void OEffectiveEvent::deref() | ||
955 | { | ||
956 | if ( data->deref() ) | ||
957 | { | ||
704 | delete data; | 958 | delete data; |
705 | data = 0; | 959 | data = 0; |
706 | } | 960 | } |
707 | } | 961 | } |
708 | void OEffectiveEvent::changeOrModify() { | 962 | |
709 | if ( data->count != 1 ) { | 963 | |
964 | void OEffectiveEvent::changeOrModify() | ||
965 | { | ||
966 | if ( data->count != 1 ) | ||
967 | { | ||
710 | data->deref(); | 968 | data->deref(); |
711 | Data* d2 = new Data; | 969 | Data* d2 = new Data; |
712 | d2->event = data->event; | 970 | d2->event = data->event; |
713 | d2->date = data->date; | 971 | d2->date = data->date; |
714 | d2->start = data->start; | 972 | d2->start = data->start; |
715 | d2->end = data->end; | 973 | d2->end = data->end; |
716 | d2->startDate = data->startDate; | 974 | d2->startDate = data->startDate; |
717 | d2->endDate = data->endDate; | 975 | d2->endDate = data->endDate; |
718 | d2->dates = data->dates; | 976 | d2->dates = data->dates; |
719 | data = d2; | 977 | data = d2; |
720 | } | 978 | } |
721 | } | 979 | } |
722 | bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{ | 980 | |
981 | |||
982 | bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const | ||
983 | { | ||
723 | if ( data->date < e.date() ) | 984 | if ( data->date < e.date() ) |
724 | return TRUE; | 985 | return TRUE; |
725 | if ( data->date == e.date() ) | 986 | if ( data->date == e.date() ) |
726 | return ( startTime() < e.startTime() ); | 987 | return ( startTime() < e.startTime() ); |
727 | else | 988 | else |
728 | return FALSE; | 989 | return FALSE; |
729 | } | 990 | } |
730 | bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{ | 991 | |
731 | return (data->date <= e.date() ); | 992 | |
993 | bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const | ||
994 | { | ||
995 | return ( data->date <= e.date() ); | ||
732 | } | 996 | } |
733 | bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const { | 997 | |
998 | |||
999 | bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const | ||
1000 | { | ||
734 | return ( date() == e.date() | 1001 | return ( date() == e.date() |
735 | && startTime() == e.startTime() | 1002 | && startTime() == e.startTime() |
736 | && endTime()== e.endTime() | 1003 | && endTime() == e.endTime() |
737 | && event() == e.event() ); | 1004 | && event() == e.event() ); |
738 | } | 1005 | } |
739 | bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const { | 1006 | |
740 | return !(*this == e ); | 1007 | |
1008 | bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const | ||
1009 | { | ||
1010 | return !( *this == e ); | ||
741 | } | 1011 | } |
742 | bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const { | 1012 | |
743 | return !(*this <= e ); | 1013 | |
1014 | bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const | ||
1015 | { | ||
1016 | return !( *this <= e ); | ||
744 | } | 1017 | } |
745 | bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const { | 1018 | |
746 | return !(*this < e); | 1019 | |
1020 | bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const | ||
1021 | { | ||
1022 | return !( *this < e ); | ||
747 | } | 1023 | } |
748 | 1024 | ||
749 | } | 1025 | } |
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h index 9502efa..dc5e4d6 100644 --- a/libopie2/opiepim/oevent.h +++ b/libopie2/opiepim/oevent.h | |||
@@ -1,268 +1,275 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | 3 | Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | // CONTAINS GPLed code of TT | 29 | // CONTAINS GPLed code of TT |
30 | 30 | ||
31 | #ifndef OPIE_PIM_EVENT_H | 31 | #ifndef OEVENT_H |
32 | #define OPIE_PIM_EVENT_H | 32 | #define OEVENT_H |
33 | |||
34 | #include <qstring.h> | ||
35 | #include <qdatetime.h> | ||
36 | #include <qvaluelist.h> | ||
37 | 33 | ||
34 | /* OPIE */ | ||
35 | #include <opie2/otimezone.h> | ||
36 | #include <opie2/opimrecord.h> | ||
38 | #include <qpe/recordfields.h> | 37 | #include <qpe/recordfields.h> |
39 | #include <qpe/palmtopuidgen.h> | 38 | #include <qpe/palmtopuidgen.h> |
40 | 39 | ||
41 | #include <opie2/otimezone.h> | 40 | /* QT */ |
42 | #include <opie2/opimrecord.h> | 41 | #include <qstring.h> |
42 | #include <qdatetime.h> | ||
43 | #include <qvaluelist.h> | ||
43 | 44 | ||
44 | namespace Opie { | 45 | namespace Opie |
45 | struct OCalendarHelper { | 46 | { |
47 | struct OCalendarHelper | ||
48 | { | ||
46 | /** calculate the week number of the date */ | 49 | /** calculate the week number of the date */ |
47 | static int week( const QDate& ); | 50 | static int week( const QDate& ); |
48 | /** calculate the occurence of week days since the start of the month */ | 51 | /** calculate the occurence of week days since the start of the month */ |
49 | static int ocurrence( const QDate& ); | 52 | static int ocurrence( const QDate& ); |
50 | 53 | ||
51 | // returns the dayOfWeek for the *first* day it finds (ignores | 54 | // returns the dayOfWeek for the *first* day it finds (ignores |
52 | // any further days!). Returns 1 (Monday) if there isn't any day found | 55 | // any further days!). Returns 1 (Monday) if there isn't any day found |
53 | static int dayOfWeek( char day ); | 56 | static int dayOfWeek( char day ); |
54 | 57 | ||
55 | /** returns the diff of month */ | 58 | /** returns the diff of month */ |
56 | static int monthDiff( const QDate& first, const QDate& second ); | 59 | static int monthDiff( const QDate& first, const QDate& second ); |
57 | 60 | ||
58 | }; | 61 | }; |
59 | 62 | ||
60 | class OPimNotifyManager; | 63 | class OPimNotifyManager; |
61 | class ORecur; | 64 | class ORecur; |
62 | 65 | ||
63 | /** | 66 | /** |
64 | * This is the container for all Events. It encapsules all | 67 | * This is the container for all Events. It encapsules all |
65 | * available information for a single Event | 68 | * available information for a single Event |
66 | * @short container for events. | 69 | * @short container for events. |
67 | */ | 70 | */ |
68 | class OEvent : public OPimRecord { | 71 | class OEvent : public OPimRecord |
69 | public: | 72 | { |
73 | public: | ||
70 | typedef QValueList<OEvent> ValueList; | 74 | typedef QValueList<OEvent> ValueList; |
71 | /** | 75 | /** |
72 | * RecordFields contain possible attributes | 76 | * RecordFields contain possible attributes |
73 | * used in the Results of toMap().. | 77 | * used in the Results of toMap().. |
74 | */ | 78 | */ |
75 | enum RecordFields { | 79 | enum RecordFields { |
76 | FUid = Qtopia::UID_ID, | 80 | FUid = Qtopia::UID_ID, |
77 | FCategories = Qtopia::CATEGORY_ID, | 81 | FCategories = Qtopia::CATEGORY_ID, |
78 | FDescription = 0, | 82 | FDescription = 0, |
79 | FLocation, | 83 | FLocation, |
80 | FType, | 84 | FType, |
81 | FAlarm, | 85 | FAlarm, |
82 | FSound, | 86 | FSound, |
83 | FRType, | 87 | FRType, |
84 | FRWeekdays, | 88 | FRWeekdays, |
85 | FRPosition, | 89 | FRPosition, |
86 | FRFreq, | 90 | FRFreq, |
87 | FRHasEndDate, | 91 | FRHasEndDate, |
88 | FREndDate, | 92 | FREndDate, |
89 | FRCreated, | 93 | FRCreated, |
90 | FRExceptions, | 94 | FRExceptions, |
91 | FStart, | 95 | FStart, |
92 | FEnd, | 96 | FEnd, |
93 | FNote, | 97 | FNote, |
94 | FTimeZone, | 98 | FTimeZone, |
95 | FRecParent, | 99 | FRecParent, |
96 | FRecChildren, | 100 | FRecChildren, |
97 | }; | 101 | }; |
98 | 102 | ||
99 | /** | 103 | /** |
100 | * Start with an Empty OEvent. UID == 0 means that it is empty | 104 | * Start with an Empty OEvent. UID == 0 means that it is empty |
101 | */ | 105 | */ |
102 | OEvent(int uid = 0); | 106 | OEvent( int uid = 0 ); |
103 | 107 | ||
104 | /** | 108 | /** |
105 | * copy c'tor | 109 | * copy c'tor |
106 | */ | 110 | */ |
107 | OEvent( const OEvent& ); | 111 | OEvent( const OEvent& ); |
108 | 112 | ||
109 | /** | 113 | /** |
110 | * Create OEvent, initialized by map | 114 | * Create OEvent, initialized by map |
111 | * @see enum RecordFields | 115 | * @see enum RecordFields |
112 | */ | 116 | */ |
113 | OEvent( const QMap<int, QString> map ); | 117 | OEvent( const QMap<int, QString> map ); |
114 | ~OEvent(); | 118 | ~OEvent(); |
115 | OEvent &operator=( const OEvent& ); | 119 | OEvent &operator=( const OEvent& ); |
116 | 120 | ||
117 | QString description()const; | 121 | QString description() const; |
118 | void setDescription( const QString& description ); | 122 | void setDescription( const QString& description ); |
119 | 123 | ||
120 | QString location()const; | 124 | QString location() const; |
121 | void setLocation( const QString& loc ); | 125 | void setLocation( const QString& loc ); |
122 | 126 | ||
123 | bool hasNotifiers()const; | 127 | bool hasNotifiers() const; |
124 | OPimNotifyManager ¬ifiers()const; | 128 | OPimNotifyManager ¬ifiers() const; |
125 | 129 | ||
126 | ORecur recurrence()const; | 130 | ORecur recurrence() const; |
127 | void setRecurrence( const ORecur& ); | 131 | void setRecurrence( const ORecur& ); |
128 | bool hasRecurrence()const; | 132 | bool hasRecurrence() const; |
129 | 133 | ||
130 | QString note()const; | 134 | QString note() const; |
131 | void setNote( const QString& note ); | 135 | void setNote( const QString& note ); |
132 | 136 | ||
133 | 137 | ||
134 | QDateTime createdDateTime()const; | 138 | QDateTime createdDateTime() const; |
135 | void setCreatedDateTime( const QDateTime& dt); | 139 | void setCreatedDateTime( const QDateTime& dt ); |
136 | 140 | ||
137 | /** set the date to dt. dt is the QDateTime in localtime */ | 141 | /** set the date to dt. dt is the QDateTime in localtime */ |
138 | void setStartDateTime( const QDateTime& ); | 142 | void setStartDateTime( const QDateTime& ); |
139 | /** returns the datetime in the local timeZone */ | 143 | /** returns the datetime in the local timeZone */ |
140 | QDateTime startDateTime()const; | 144 | QDateTime startDateTime() const; |
141 | 145 | ||
142 | /** returns the start datetime in the current zone */ | 146 | /** returns the start datetime in the current zone */ |
143 | QDateTime startDateTimeInZone()const; | 147 | QDateTime startDateTimeInZone() const; |
144 | 148 | ||
145 | /** in current timezone */ | 149 | /** in current timezone */ |
146 | void setEndDateTime( const QDateTime& ); | 150 | void setEndDateTime( const QDateTime& ); |
147 | /** in current timezone */ | 151 | /** in current timezone */ |
148 | QDateTime endDateTime()const; | 152 | QDateTime endDateTime() const; |
149 | QDateTime endDateTimeInZone()const; | 153 | QDateTime endDateTimeInZone() const; |
150 | 154 | ||
151 | bool isMultipleDay()const; | 155 | bool isMultipleDay() const; |
152 | bool isAllDay()const; | 156 | bool isAllDay() const; |
153 | void setAllDay( bool isAllDay ); | 157 | void setAllDay( bool isAllDay ); |
154 | 158 | ||
155 | /* pin this event to a timezone! FIXME */ | 159 | /* pin this event to a timezone! FIXME */ |
156 | void setTimeZone( const QString& timeZone ); | 160 | void setTimeZone( const QString& timeZone ); |
157 | QString timeZone()const; | 161 | QString timeZone() const; |
158 | 162 | ||
159 | 163 | ||
160 | virtual bool match( const QRegExp& )const; | 164 | virtual bool match( const QRegExp& ) const; |
161 | 165 | ||
162 | /** For exception to recurrence here is a list of children... */ | 166 | /** For exception to recurrence here is a list of children... */ |
163 | QArray<int> children()const; | 167 | QArray<int> children() const; |
164 | void setChildren( const QArray<int>& ); | 168 | void setChildren( const QArray<int>& ); |
165 | void addChild( int uid ); | 169 | void addChild( int uid ); |
166 | void removeChild( int uid ); | 170 | void removeChild( int uid ); |
167 | 171 | ||
168 | /** return the parent OEvent */ | 172 | /** return the parent OEvent */ |
169 | int parent()const; | 173 | int parent() const; |
170 | void setParent( int uid ); | 174 | void setParent( int uid ); |
171 | 175 | ||
172 | 176 | ||
173 | /* needed reimp */ | 177 | /* needed reimp */ |
174 | QString toRichText()const; | 178 | QString toRichText() const; |
175 | QString toShortText()const; | 179 | QString toShortText() const; |
176 | QString type()const; | 180 | QString type() const; |
177 | 181 | ||
178 | QMap<int, QString> toMap()const; | 182 | QMap<int, QString> toMap() const; |
179 | void fromMap( const QMap<int, QString>& map ); | 183 | void fromMap( const QMap<int, QString>& map ); |
180 | QString recordField(int )const; | 184 | QString recordField( int ) const; |
181 | 185 | ||
182 | static int rtti(); | 186 | static int rtti(); |
183 | 187 | ||
184 | bool loadFromStream( QDataStream& ); | 188 | bool loadFromStream( QDataStream& ); |
185 | bool saveToStream( QDataStream& )const; | 189 | bool saveToStream( QDataStream& ) const; |
186 | 190 | ||
187 | /* bool operator==( const OEvent& ); | 191 | /* bool operator==( const OEvent& ); |
188 | bool operator!=( const OEvent& ); | 192 | bool operator!=( const OEvent& ); |
189 | bool operator<( const OEvent& ); | 193 | bool operator<( const OEvent& ); |
190 | bool operator<=( const OEvent& ); | 194 | bool operator<=( const OEvent& ); |
191 | bool operator>( const OEvent& ); | 195 | bool operator>( const OEvent& ); |
192 | bool operator>=(const OEvent& ); | 196 | bool operator>=(const OEvent& ); |
193 | */ | 197 | */ |
194 | private: | 198 | |
199 | private: | ||
195 | inline void changeOrModify(); | 200 | inline void changeOrModify(); |
196 | void deref(); | 201 | void deref(); |
197 | struct Data; | 202 | struct Data; |
198 | Data* data; | 203 | Data* data; |
199 | class Private; | 204 | class Private; |
200 | Private* priv; | 205 | Private* priv; |
201 | 206 | ||
202 | }; | 207 | }; |
203 | 208 | ||
204 | /** | 209 | /** |
205 | * AN Event can span through multiple days. We split up a multiday eve | 210 | * AN Event can span through multiple days. We split up a multiday eve |
206 | */ | 211 | */ |
207 | class OEffectiveEvent { | 212 | class OEffectiveEvent |
208 | public: | 213 | { |
214 | |||
215 | public: | ||
209 | typedef QValueList<OEffectiveEvent> ValueList; | 216 | typedef QValueList<OEffectiveEvent> ValueList; |
210 | enum Position { MidWay, Start, End, StartEnd }; | 217 | enum Position { MidWay, Start, End, StartEnd }; |
211 | // If we calculate the effective event of a multi-day event | 218 | // If we calculate the effective event of a multi-day event |
212 | // we have to figure out whether we are at the first day, | 219 | // we have to figure out whether we are at the first day, |
213 | // at the end, or anywhere else ("middle"). This is important | 220 | // at the end, or anywhere else ("middle"). This is important |
214 | // for the start/end times (00:00/23:59) | 221 | // for the start/end times (00:00/23:59) |
215 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | 222 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- |
216 | // day event | 223 | // day event |
217 | // Start: start time -> 23:59 | 224 | // Start: start time -> 23:59 |
218 | // End: 00:00 -> end time | 225 | // End: 00:00 -> end time |
219 | // Start | End == StartEnd: for single-day events (default) | 226 | // Start | End == StartEnd: for single-day events (default) |
220 | // here we draw start time -> end time | 227 | // here we draw start time -> end time |
221 | OEffectiveEvent(); | 228 | OEffectiveEvent(); |
222 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); | 229 | OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); |
223 | OEffectiveEvent( const OEffectiveEvent& ); | 230 | OEffectiveEvent( const OEffectiveEvent& ); |
224 | OEffectiveEvent &operator=(const OEffectiveEvent& ); | 231 | OEffectiveEvent &operator=( const OEffectiveEvent& ); |
225 | ~OEffectiveEvent(); | 232 | ~OEffectiveEvent(); |
226 | 233 | ||
227 | void setStartTime( const QTime& ); | 234 | void setStartTime( const QTime& ); |
228 | void setEndTime( const QTime& ); | 235 | void setEndTime( const QTime& ); |
229 | void setEvent( const OEvent& ); | 236 | void setEvent( const OEvent& ); |
230 | void setDate( const QDate& ); | 237 | void setDate( const QDate& ); |
231 | 238 | ||
232 | void setEffectiveDates( const QDate& from, const QDate& to ); | 239 | void setEffectiveDates( const QDate& from, const QDate& to ); |
233 | 240 | ||
234 | QString description()const; | 241 | QString description() const; |
235 | QString location()const; | 242 | QString location() const; |
236 | QString note()const; | 243 | QString note() const; |
237 | OEvent event()const; | 244 | OEvent event() const; |
238 | QTime startTime()const; | 245 | QTime startTime() const; |
239 | QTime endTime()const; | 246 | QTime endTime() const; |
240 | QDate date()const; | 247 | QDate date() const; |
241 | 248 | ||
242 | /* return the length in hours */ | 249 | /* return the length in hours */ |
243 | int length()const; | 250 | int length() const; |
244 | int size()const; | 251 | int size() const; |
245 | 252 | ||
246 | QDate startDate()const; | 253 | QDate startDate() const; |
247 | QDate endDate()const; | 254 | QDate endDate() const; |
248 | 255 | ||
249 | bool operator<( const OEffectiveEvent &e ) const; | 256 | bool operator<( const OEffectiveEvent &e ) const; |
250 | bool operator<=( const OEffectiveEvent &e ) const; | 257 | bool operator<=( const OEffectiveEvent &e ) const; |
251 | bool operator==( const OEffectiveEvent &e ) const; | 258 | bool operator==( const OEffectiveEvent &e ) const; |
252 | bool operator!=( const OEffectiveEvent &e ) const; | 259 | bool operator!=( const OEffectiveEvent &e ) const; |
253 | bool operator>( const OEffectiveEvent &e ) const; | 260 | bool operator>( const OEffectiveEvent &e ) const; |
254 | bool operator>= ( const OEffectiveEvent &e ) const; | 261 | bool operator>= ( const OEffectiveEvent &e ) const; |
255 | 262 | ||
256 | private: | 263 | private: |
257 | void deref(); | 264 | void deref(); |
258 | inline void changeOrModify(); | 265 | inline void changeOrModify(); |
259 | class Private; | 266 | class Private; |
260 | Private* priv; | 267 | Private* priv; |
261 | struct Data; | 268 | struct Data; |
262 | Data* data; | 269 | Data* data; |
263 | 270 | ||
264 | }; | 271 | }; |
265 | 272 | ||
266 | } | 273 | } |
267 | 274 | ||
268 | #endif | 275 | #endif |
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index 8f0011b..1742dcc 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h | |||
@@ -1,336 +1,402 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OPIE_RECORD_LIST_H | 30 | #ifndef ORECORDLIST_H |
31 | #define OPIE_RECORD_LIST_H | 31 | #define ORECORDLIST_H |
32 | |||
33 | #include <qarray.h> | ||
34 | 32 | ||
33 | /* OPIE */ | ||
35 | #include <opie2/otemplatebase.h> | 34 | #include <opie2/otemplatebase.h> |
36 | #include <opie2/opimrecord.h> | 35 | #include <opie2/opimrecord.h> |
37 | 36 | ||
38 | namespace Opie { | 37 | /* QT */ |
38 | #include <qarray.h> | ||
39 | |||
40 | namespace Opie | ||
41 | { | ||
39 | 42 | ||
40 | class ORecordListIteratorPrivate; | 43 | class ORecordListIteratorPrivate; |
41 | /** | 44 | /** |
42 | * Our List Iterator | 45 | * Our List Iterator |
43 | * it behaves like STL or Qt | 46 | * it behaves like STL or Qt |
44 | * | 47 | * |
45 | * for(it = list.begin(); it != list.end(); ++it ) | 48 | * for(it = list.begin(); it != list.end(); ++it ) |
46 | * doSomeCoolStuff( (*it) ); | 49 | * doSomeCoolStuff( (*it) ); |
47 | */ | 50 | */ |
48 | template <class T> class ORecordList; | 51 | template <class T> class ORecordList; |
49 | template <class T = OPimRecord> | 52 | template <class T = OPimRecord> |
50 | class ORecordListIterator { | 53 | class ORecordListIterator |
54 | { | ||
51 | friend class ORecordList<T>; | 55 | friend class ORecordList<T>; |
52 | public: | 56 | |
57 | public: | ||
53 | typedef OTemplateBase<T> Base; | 58 | typedef OTemplateBase<T> Base; |
54 | 59 | ||
55 | /** | 60 | /** |
56 | * The c'tor used internally from | 61 | * The c'tor used internally from |
57 | * ORecordList | 62 | * ORecordList |
58 | */ | 63 | */ |
59 | ORecordListIterator( const QArray<int>, const Base* ); | 64 | ORecordListIterator( const QArray<int>, const Base* ); |
60 | 65 | ||
61 | /** | 66 | /** |
62 | * The standard c'tor | 67 | * The standard c'tor |
63 | */ | 68 | */ |
64 | ORecordListIterator(); | 69 | ORecordListIterator(); |
65 | ~ORecordListIterator(); | 70 | ~ORecordListIterator(); |
66 | 71 | ||
67 | ORecordListIterator( const ORecordListIterator& ); | 72 | ORecordListIterator( const ORecordListIterator& ); |
68 | ORecordListIterator &operator=(const ORecordListIterator& ); | 73 | ORecordListIterator &operator=( const ORecordListIterator& ); |
69 | 74 | ||
70 | /** | 75 | /** |
71 | * a * operator ;) | 76 | * a * operator ;) |
72 | * use it like this T = (*it); | 77 | * use it like this T = (*it); |
73 | */ | 78 | */ |
74 | T operator*(); | 79 | T operator*(); |
75 | ORecordListIterator &operator++(); | 80 | ORecordListIterator &operator++(); |
76 | ORecordListIterator &operator--(); | 81 | ORecordListIterator &operator--(); |
77 | 82 | ||
78 | bool operator==( const ORecordListIterator& it ); | 83 | bool operator==( const ORecordListIterator& it ); |
79 | bool operator!=( const ORecordListIterator& it ); | 84 | bool operator!=( const ORecordListIterator& it ); |
80 | 85 | ||
81 | /** | 86 | /** |
82 | * the current item | 87 | * the current item |
83 | */ | 88 | */ |
84 | uint current()const; | 89 | uint current() const; |
85 | 90 | ||
86 | /** | 91 | /** |
87 | * the number of items | 92 | * the number of items |
88 | */ | 93 | */ |
89 | uint count()const; | 94 | uint count() const; |
90 | 95 | ||
91 | /** | 96 | /** |
92 | * sets the current item | 97 | * sets the current item |
93 | */ | 98 | */ |
94 | void setCurrent( uint cur ); | 99 | void setCurrent( uint cur ); |
95 | 100 | ||
96 | private: | 101 | private: |
97 | QArray<int> m_uids; | 102 | QArray<int> m_uids; |
98 | uint m_current; | 103 | uint m_current; |
99 | const Base* m_temp; | 104 | const Base* m_temp; |
100 | bool m_end : 1; | 105 | bool m_end : 1; |
101 | T m_record; | 106 | T m_record; |
102 | bool m_direction :1; | 107 | bool m_direction : 1; |
103 | 108 | ||
104 | /* d pointer for future versions */ | 109 | /* d pointer for future versions */ |
105 | ORecordListIteratorPrivate *d; | 110 | ORecordListIteratorPrivate *d; |
106 | }; | 111 | }; |
107 | 112 | ||
113 | |||
108 | class ORecordListPrivate; | 114 | class ORecordListPrivate; |
109 | /** | 115 | /** |
110 | * The recordlist used as a return type | 116 | * The recordlist used as a return type |
111 | * from OPimAccessTemplate | 117 | * from OPimAccessTemplate |
112 | */ | 118 | */ |
113 | template <class T = OPimRecord > | 119 | template <class T = OPimRecord > |
114 | class ORecordList { | 120 | class ORecordList |
115 | public: | 121 | { |
122 | public: | ||
116 | typedef OTemplateBase<T> Base; | 123 | typedef OTemplateBase<T> Base; |
117 | typedef ORecordListIterator<T> Iterator; | 124 | typedef ORecordListIterator<T> Iterator; |
118 | 125 | ||
119 | /** | 126 | /** |
120 | * c'tor | 127 | * c'tor |
121 | */ | 128 | */ |
122 | ORecordList () { | 129 | ORecordList () |
123 | } | 130 | {} |
124 | ORecordList( const QArray<int>& ids, | 131 | ORecordList( const QArray<int>& ids, |
125 | const Base* ); | 132 | const Base* ); |
126 | ~ORecordList(); | 133 | ~ORecordList(); |
127 | 134 | ||
128 | /** | 135 | /** |
129 | * the first iterator | 136 | * the first iterator |
130 | */ | 137 | */ |
131 | Iterator begin(); | 138 | Iterator begin(); |
132 | 139 | ||
133 | /** | 140 | /** |
134 | * the end | 141 | * the end |
135 | */ | 142 | */ |
136 | Iterator end(); | 143 | Iterator end(); |
137 | 144 | ||
138 | /** | 145 | /** |
139 | * the number of items in the list | 146 | * the number of items in the list |
140 | */ | 147 | */ |
141 | uint count()const; | 148 | uint count() const; |
142 | 149 | ||
143 | T operator[]( uint i ); | 150 | T operator[] ( uint i ); |
144 | int uidAt(uint i ); | 151 | int uidAt( uint i ); |
145 | 152 | ||
146 | /** | 153 | /** |
147 | * Remove the contact with given uid | 154 | * Remove the contact with given uid |
148 | */ | 155 | */ |
149 | bool remove( int uid ); | 156 | bool remove( int uid ); |
150 | 157 | ||
151 | /* | 158 | /* |
152 | ConstIterator begin()const; | 159 | ConstIterator begin()const; |
153 | ConstIterator end()const; | 160 | ConstIterator end()const; |
154 | */ | 161 | */ |
155 | private: | 162 | private: |
156 | QArray<int> m_ids; | 163 | QArray<int> m_ids; |
157 | const Base* m_acc; | 164 | const Base* m_acc; |
158 | ORecordListPrivate *d; | 165 | ORecordListPrivate *d; |
159 | }; | 166 | }; |
160 | 167 | ||
168 | |||
161 | /* ok now implement it */ | 169 | /* ok now implement it */ |
162 | template <class T> | 170 | template <class T> |
163 | ORecordListIterator<T>::ORecordListIterator() { | 171 | ORecordListIterator<T>::ORecordListIterator() |
172 | { | ||
164 | m_current = 0; | 173 | m_current = 0; |
165 | m_temp = 0l; | 174 | m_temp = 0l; |
166 | m_end = true; | 175 | m_end = true; |
167 | m_record = T(); | 176 | m_record = T(); |
168 | /* forward */ | 177 | /* forward */ |
169 | m_direction = TRUE; | 178 | m_direction = TRUE; |
170 | } | 179 | } |
180 | |||
181 | |||
171 | template <class T> | 182 | template <class T> |
172 | ORecordListIterator<T>::~ORecordListIterator() { | 183 | ORecordListIterator<T>::~ORecordListIterator() |
173 | /* nothing to delete */ | 184 | { |
185 | /* nothing to delete */ | ||
174 | } | 186 | } |
175 | 187 | ||
188 | |||
176 | template <class T> | 189 | template <class T> |
177 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { | 190 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it ) |
178 | // qWarning("ORecordListIterator copy c'tor"); | 191 | { |
192 | // qWarning("ORecordListIterator copy c'tor"); | ||
179 | m_uids = it.m_uids; | 193 | m_uids = it.m_uids; |
180 | m_current = it.m_current; | 194 | m_current = it.m_current; |
181 | m_temp = it.m_temp; | 195 | m_temp = it.m_temp; |
182 | m_end = it.m_end; | 196 | m_end = it.m_end; |
183 | m_record = it.m_record; | 197 | m_record = it.m_record; |
184 | m_direction = it.m_direction; | 198 | m_direction = it.m_direction; |
185 | } | 199 | } |
186 | 200 | ||
201 | |||
187 | template <class T> | 202 | template <class T> |
188 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { | 203 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it ) |
204 | { | ||
189 | m_uids = it.m_uids; | 205 | m_uids = it.m_uids; |
190 | m_current = it.m_current; | 206 | m_current = it.m_current; |
191 | m_temp = it.m_temp; | 207 | m_temp = it.m_temp; |
192 | m_end = it.m_end; | 208 | m_end = it.m_end; |
193 | m_record = it.m_record; | 209 | m_record = it.m_record; |
194 | 210 | ||
195 | return *this; | 211 | return *this; |
196 | } | 212 | } |
197 | 213 | ||
214 | |||
198 | template <class T> | 215 | template <class T> |
199 | T ORecordListIterator<T>::operator*() { | 216 | T ORecordListIterator<T>::operator*() |
200 | //qWarning("operator* %d %d", m_current, m_uids[m_current] ); | 217 | { |
201 | if (!m_end ) | 218 | //qWarning("operator* %d %d", m_current, m_uids[m_current] ); |
202 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, | 219 | if ( !m_end ) |
220 | m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current, | ||
203 | m_direction ? Base::Forward : | 221 | m_direction ? Base::Forward : |
204 | Base::Reverse ); | 222 | Base::Reverse ); |
205 | else | 223 | else |
206 | m_record = T(); | 224 | m_record = T(); |
207 | 225 | ||
208 | return m_record; | 226 | return m_record; |
209 | } | 227 | } |
210 | 228 | ||
229 | |||
211 | template <class T> | 230 | template <class T> |
212 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 231 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() |
232 | { | ||
213 | m_direction = true; | 233 | m_direction = true; |
214 | if (m_current < m_uids.count() ) { | 234 | if ( m_current < m_uids.count() ) |
235 | { | ||
215 | m_end = false; | 236 | m_end = false; |
216 | ++m_current; | 237 | ++m_current; |
217 | }else | 238 | } |
239 | else | ||
218 | m_end = true; | 240 | m_end = true; |
219 | 241 | ||
220 | return *this; | 242 | return *this; |
221 | } | 243 | } |
244 | |||
245 | |||
222 | template <class T> | 246 | template <class T> |
223 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { | 247 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() |
248 | { | ||
224 | m_direction = false; | 249 | m_direction = false; |
225 | if ( m_current > 0 ) { | 250 | if ( m_current > 0 ) |
251 | { | ||
226 | --m_current; | 252 | --m_current; |
227 | m_end = false; | 253 | m_end = false; |
228 | } else | 254 | } |
255 | else | ||
229 | m_end = true; | 256 | m_end = true; |
230 | 257 | ||
231 | return *this; | 258 | return *this; |
232 | } | 259 | } |
233 | 260 | ||
261 | |||
234 | template <class T> | 262 | template <class T> |
235 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { | 263 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) |
264 | { | ||
236 | 265 | ||
237 | /* if both are at we're the same.... */ | 266 | /* if both are at we're the same.... */ |
238 | if ( m_end == it.m_end ) return true; | 267 | if ( m_end == it.m_end ) return true; |
239 | 268 | ||
240 | if ( m_uids != it.m_uids ) return false; | 269 | if ( m_uids != it.m_uids ) return false; |
241 | if ( m_current != it.m_current ) return false; | 270 | if ( m_current != it.m_current ) return false; |
242 | if ( m_temp != it.m_temp ) return false; | 271 | if ( m_temp != it.m_temp ) return false; |
243 | 272 | ||
244 | return true; | 273 | return true; |
245 | } | 274 | } |
275 | |||
276 | |||
246 | template <class T> | 277 | template <class T> |
247 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { | 278 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) |
248 | return !(*this == it ); | 279 | { |
280 | return !( *this == it ); | ||
249 | } | 281 | } |
282 | |||
283 | |||
250 | template <class T> | 284 | template <class T> |
251 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | 285 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, |
252 | const Base* t ) | 286 | const Base* t ) |
253 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), | 287 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), |
254 | m_direction( false ) | 288 | m_direction( false ) |
255 | { | 289 | { |
256 | /* if the list is empty we're already at the end of the list */ | 290 | /* if the list is empty we're already at the end of the list */ |
257 | if (uids.count() == 0 ) | 291 | if ( uids.count() == 0 ) |
258 | m_end = true; | 292 | m_end = true; |
259 | } | 293 | } |
294 | |||
295 | |||
260 | template <class T> | 296 | template <class T> |
261 | uint ORecordListIterator<T>::current()const { | 297 | uint ORecordListIterator<T>::current() const |
298 | { | ||
262 | return m_current; | 299 | return m_current; |
263 | } | 300 | } |
301 | |||
302 | |||
264 | template <class T> | 303 | template <class T> |
265 | void ORecordListIterator<T>::setCurrent( uint cur ) { | 304 | void ORecordListIterator<T>::setCurrent( uint cur ) |
266 | if( cur < m_uids.count() ) { | 305 | { |
267 | m_end = false; | 306 | if ( cur < m_uids.count() ) |
268 | m_current= cur; | 307 | { |
308 | m_end = false; | ||
309 | m_current = cur; | ||
269 | } | 310 | } |
270 | } | 311 | } |
271 | template <class T> | 312 | template <class T> |
272 | uint ORecordListIterator<T>::count()const { | 313 | uint ORecordListIterator<T>::count() const |
314 | { | ||
273 | return m_uids.count(); | 315 | return m_uids.count(); |
274 | } | 316 | } |
317 | |||
318 | |||
275 | template <class T> | 319 | template <class T> |
276 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 320 | ORecordList<T>::ORecordList( const QArray<int>& ids, |
277 | const Base* acc ) | 321 | const Base* acc ) |
278 | : m_ids( ids ), m_acc( acc ) | 322 | : m_ids( ids ), m_acc( acc ) |
279 | { | 323 | {} |
280 | } | 324 | |
325 | |||
281 | template <class T> | 326 | template <class T> |
282 | ORecordList<T>::~ORecordList() { | 327 | ORecordList<T>::~ORecordList() |
283 | /* nothing to do here */ | 328 | { |
329 | /* nothing to do here */ | ||
284 | } | 330 | } |
331 | |||
332 | |||
285 | template <class T> | 333 | template <class T> |
286 | typename ORecordList<T>::Iterator ORecordList<T>::begin() { | 334 | typename ORecordList<T>::Iterator ORecordList<T>::begin() |
335 | { | ||
287 | Iterator it( m_ids, m_acc ); | 336 | Iterator it( m_ids, m_acc ); |
288 | return it; | 337 | return it; |
289 | } | 338 | } |
339 | |||
340 | |||
290 | template <class T> | 341 | template <class T> |
291 | typename ORecordList<T>::Iterator ORecordList<T>::end() { | 342 | typename ORecordList<T>::Iterator ORecordList<T>::end() |
343 | { | ||
292 | Iterator it( m_ids, m_acc ); | 344 | Iterator it( m_ids, m_acc ); |
293 | it.m_end = true; | 345 | it.m_end = true; |
294 | it.m_current = m_ids.count(); | 346 | it.m_current = m_ids.count(); |
295 | 347 | ||
296 | return it; | 348 | return it; |
297 | } | 349 | } |
350 | |||
351 | |||
298 | template <class T> | 352 | template <class T> |
299 | uint ORecordList<T>::count()const { | 353 | uint ORecordList<T>::count() const |
300 | return m_ids.count(); | 354 | { |
355 | return m_ids.count(); | ||
301 | } | 356 | } |
357 | |||
358 | |||
302 | template <class T> | 359 | template <class T> |
303 | T ORecordList<T>::operator[]( uint i ) { | 360 | T ORecordList<T>::operator[] ( uint i ) |
361 | { | ||
304 | if ( i >= m_ids.count() ) | 362 | if ( i >= m_ids.count() ) |
305 | return T(); | 363 | return T(); |
306 | /* forward */ | 364 | /* forward */ |
307 | return m_acc->find( m_ids[i], m_ids, i ); | 365 | return m_acc->find( m_ids[ i ], m_ids, i ); |
308 | } | ||
309 | template <class T> | ||
310 | int ORecordList<T>::uidAt( uint i ) { | ||
311 | return m_ids[i]; | ||
312 | } | 366 | } |
313 | 367 | ||
368 | |||
314 | template <class T> | 369 | template <class T> |
315 | bool ORecordList<T>::remove( int uid ) { | 370 | int ORecordList<T>::uidAt( uint i ) |
316 | QArray<int> copy( m_ids.count() ); | 371 | { |
317 | int counter = 0; | 372 | return m_ids[ i ]; |
318 | bool ret_val = false; | 373 | } |
319 | 374 | ||
320 | for (uint i = 0; i < m_ids.count(); i++){ | ||
321 | if ( m_ids[i] != uid ){ | ||
322 | copy[counter++] = m_ids[i]; | ||
323 | 375 | ||
324 | }else | 376 | template <class T> |
325 | ret_val = true; | 377 | bool ORecordList<T>::remove( int uid ) |
326 | } | 378 | { |
379 | QArray<int> copy( m_ids.count() ); | ||
380 | int counter = 0; | ||
381 | bool ret_val = false; | ||
382 | |||
383 | for ( uint i = 0; i < m_ids.count(); i++ ) | ||
384 | { | ||
385 | if ( m_ids[ i ] != uid ) | ||
386 | { | ||
387 | copy[ counter++ ] = m_ids[ i ]; | ||
388 | |||
389 | } | ||
390 | else | ||
391 | ret_val = true; | ||
392 | } | ||
327 | 393 | ||
328 | copy.resize( counter ); | 394 | copy.resize( counter ); |
329 | m_ids = copy; | 395 | m_ids = copy; |
330 | 396 | ||
331 | 397 | ||
332 | return ret_val; | 398 | return ret_val; |
333 | } | 399 | } |
334 | 400 | ||
335 | } | 401 | } |
336 | #endif | 402 | #endif |
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index 3eb0026..f534067 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -1,550 +1,712 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qobject.h> | ||
30 | #include <qshared.h> | ||
31 | |||
32 | 29 | ||
30 | #include "otodo.h" | ||
33 | 31 | ||
32 | /* OPIE */ | ||
33 | #include <opie2/opimstate.h> | ||
34 | #include <opie2/orecur.h> | ||
35 | #include <opie2/opimmaintainer.h> | ||
36 | #include <opie2/opimnotifymanager.h> | ||
37 | #include <opie2/opimresolver.h> | ||
34 | #include <qpe/palmtopuidgen.h> | 38 | #include <qpe/palmtopuidgen.h> |
35 | #include <qpe/stringutil.h> | 39 | #include <qpe/stringutil.h> |
36 | #include <qpe/palmtoprecord.h> | 40 | #include <qpe/palmtoprecord.h> |
37 | #include <qpe/stringutil.h> | 41 | #include <qpe/stringutil.h> |
38 | #include <qpe/categories.h> | 42 | #include <qpe/categories.h> |
39 | #include <qpe/categoryselect.h> | 43 | #include <qpe/categoryselect.h> |
40 | 44 | ||
45 | /* QT */ | ||
46 | #include <qobject.h> | ||
47 | #include <qshared.h> | ||
41 | 48 | ||
42 | #include <opie2/opimstate.h> | 49 | namespace Opie |
43 | #include <opie2/orecur.h> | 50 | { |
44 | #include <opie2/opimmaintainer.h> | ||
45 | #include <opie2/opimnotifymanager.h> | ||
46 | #include <opie2/opimresolver.h> | ||
47 | |||
48 | #include <opie2/otodo.h> | ||
49 | |||
50 | namespace Opie { | ||
51 | 51 | ||
52 | struct OTodo::OTodoData : public QShared { | 52 | struct OTodo::OTodoData : public QShared |
53 | OTodoData() : QShared() { | 53 | { |
54 | OTodoData() : QShared() | ||
55 | { | ||
54 | recur = 0; | 56 | recur = 0; |
55 | state = 0; | 57 | state = 0; |
56 | maintainer = 0; | 58 | maintainer = 0; |
57 | notifiers = 0; | 59 | notifiers = 0; |
58 | }; | 60 | }; |
59 | ~OTodoData() { | 61 | ~OTodoData() |
62 | { | ||
60 | delete recur; | 63 | delete recur; |
61 | delete maintainer; | 64 | delete maintainer; |
62 | delete notifiers; | 65 | delete notifiers; |
63 | } | 66 | } |
64 | 67 | ||
65 | QDate date; | 68 | QDate date; |
66 | bool isCompleted:1; | 69 | bool isCompleted: 1; |
67 | bool hasDate:1; | 70 | bool hasDate: 1; |
68 | int priority; | 71 | int priority; |
69 | QString desc; | 72 | QString desc; |
70 | QString sum; | 73 | QString sum; |
71 | QMap<QString, QString> extra; | 74 | QMap<QString, QString> extra; |
72 | ushort prog; | 75 | ushort prog; |
73 | OPimState *state; | 76 | OPimState *state; |
74 | ORecur *recur; | 77 | ORecur *recur; |
75 | OPimMaintainer *maintainer; | 78 | OPimMaintainer *maintainer; |
76 | QDate start; | 79 | QDate start; |
77 | QDate completed; | 80 | QDate completed; |
78 | OPimNotifyManager *notifiers; | 81 | OPimNotifyManager *notifiers; |
79 | }; | 82 | }; |
80 | 83 | ||
81 | OTodo::OTodo(const OTodo &event ) | 84 | |
82 | : OPimRecord( event ), data( event.data ) | 85 | OTodo::OTodo( const OTodo &event ) |
86 | : OPimRecord( event ), data( event.data ) | ||
83 | { | 87 | { |
84 | data->ref(); | 88 | data->ref(); |
85 | // qWarning("ref up"); | 89 | // qWarning("ref up"); |
86 | } | 90 | } |
87 | OTodo::~OTodo() { | ||
88 | 91 | ||
89 | // qWarning("~OTodo " ); | 92 | |
90 | if ( data->deref() ) { | 93 | OTodo::~OTodo() |
91 | // qWarning("OTodo::dereffing"); | 94 | { |
95 | |||
96 | // qWarning("~OTodo " ); | ||
97 | if ( data->deref() ) | ||
98 | { | ||
99 | // qWarning("OTodo::dereffing"); | ||
92 | delete data; | 100 | delete data; |
93 | data = 0l; | 101 | data = 0l; |
94 | } | 102 | } |
95 | } | 103 | } |
96 | OTodo::OTodo(bool completed, int priority, | 104 | |
97 | const QArray<int> &category, | 105 | |
98 | const QString& summary, | 106 | OTodo::OTodo( bool completed, int priority, |
99 | const QString &description, | 107 | const QArray<int> &category, |
100 | ushort progress, | 108 | const QString& summary, |
101 | bool hasDate, QDate date, int uid ) | 109 | const QString &description, |
102 | : OPimRecord( uid ) | 110 | ushort progress, |
111 | bool hasDate, QDate date, int uid ) | ||
112 | : OPimRecord( uid ) | ||
103 | { | 113 | { |
104 | // qWarning("OTodoData " + summary); | 114 | // qWarning("OTodoData " + summary); |
105 | setCategories( category ); | 115 | setCategories( category ); |
106 | 116 | ||
107 | data = new OTodoData; | 117 | data = new OTodoData; |
108 | 118 | ||
109 | data->date = date; | 119 | data->date = date; |
110 | data->isCompleted = completed; | 120 | data->isCompleted = completed; |
111 | data->hasDate = hasDate; | 121 | data->hasDate = hasDate; |
112 | data->priority = priority; | 122 | data->priority = priority; |
113 | data->sum = summary; | 123 | data->sum = summary; |
114 | data->prog = progress; | 124 | data->prog = progress; |
115 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 125 | data->desc = Qtopia::simplifyMultiLineSpace( description ); |
116 | } | 126 | } |
117 | OTodo::OTodo(bool completed, int priority, | 127 | |
118 | const QStringList &category, | 128 | |
119 | const QString& summary, | 129 | OTodo::OTodo( bool completed, int priority, |
120 | const QString &description, | 130 | const QStringList &category, |
121 | ushort progress, | 131 | const QString& summary, |
122 | bool hasDate, QDate date, int uid ) | 132 | const QString &description, |
123 | : OPimRecord( uid ) | 133 | ushort progress, |
134 | bool hasDate, QDate date, int uid ) | ||
135 | : OPimRecord( uid ) | ||
124 | { | 136 | { |
125 | // qWarning("OTodoData" + summary); | 137 | // qWarning("OTodoData" + summary); |
126 | setCategories( idsFromString( category.join(";") ) ); | 138 | setCategories( idsFromString( category.join( ";" ) ) ); |
127 | 139 | ||
128 | data = new OTodoData; | 140 | data = new OTodoData; |
129 | 141 | ||
130 | data->date = date; | 142 | data->date = date; |
131 | data->isCompleted = completed; | 143 | data->isCompleted = completed; |
132 | data->hasDate = hasDate; | 144 | data->hasDate = hasDate; |
133 | data->priority = priority; | 145 | data->priority = priority; |
134 | data->sum = summary; | 146 | data->sum = summary; |
135 | data->prog = progress; | 147 | data->prog = progress; |
136 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 148 | data->desc = Qtopia::simplifyMultiLineSpace( description ); |
137 | } | 149 | } |
138 | bool OTodo::match( const QRegExp ®Exp )const | 150 | |
151 | |||
152 | bool OTodo::match( const QRegExp ®Exp ) const | ||
139 | { | 153 | { |
140 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 154 | if ( QString::number( data->priority ).find( regExp ) != -1 ) |
141 | setLastHitField( Priority ); | 155 | { |
142 | return true; | 156 | setLastHitField( Priority ); |
143 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 157 | return true; |
144 | setLastHitField( HasDate ); | 158 | } |
145 | return true; | 159 | else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) |
146 | }else if(data->desc.find( regExp ) != -1 ){ | 160 | { |
161 | setLastHitField( HasDate ); | ||
162 | return true; | ||
163 | } | ||
164 | else if ( data->desc.find( regExp ) != -1 ) | ||
165 | { | ||
147 | setLastHitField( Description ); | 166 | setLastHitField( Description ); |
148 | return true; | 167 | return true; |
149 | }else if(data->sum.find( regExp ) != -1 ) { | 168 | } |
169 | else if ( data->sum.find( regExp ) != -1 ) | ||
170 | { | ||
150 | setLastHitField( Summary ); | 171 | setLastHitField( Summary ); |
151 | return true; | 172 | return true; |
152 | } | 173 | } |
153 | return false; | 174 | return false; |
154 | } | 175 | } |
176 | |||
177 | |||
155 | bool OTodo::isCompleted() const | 178 | bool OTodo::isCompleted() const |
156 | { | 179 | { |
157 | return data->isCompleted; | 180 | return data->isCompleted; |
158 | } | 181 | } |
182 | |||
183 | |||
159 | bool OTodo::hasDueDate() const | 184 | bool OTodo::hasDueDate() const |
160 | { | 185 | { |
161 | return data->hasDate; | 186 | return data->hasDate; |
162 | } | 187 | } |
163 | bool OTodo::hasStartDate()const { | 188 | |
189 | |||
190 | bool OTodo::hasStartDate() const | ||
191 | { | ||
164 | return data->start.isValid(); | 192 | return data->start.isValid(); |
165 | } | 193 | } |
166 | bool OTodo::hasCompletedDate()const { | 194 | |
195 | |||
196 | bool OTodo::hasCompletedDate() const | ||
197 | { | ||
167 | return data->completed.isValid(); | 198 | return data->completed.isValid(); |
168 | } | 199 | } |
169 | int OTodo::priority()const | 200 | |
201 | |||
202 | int OTodo::priority() const | ||
170 | { | 203 | { |
171 | return data->priority; | 204 | return data->priority; |
172 | } | 205 | } |
206 | |||
207 | |||
173 | QString OTodo::summary() const | 208 | QString OTodo::summary() const |
174 | { | 209 | { |
175 | return data->sum; | 210 | return data->sum; |
176 | } | 211 | } |
212 | |||
213 | |||
177 | ushort OTodo::progress() const | 214 | ushort OTodo::progress() const |
178 | { | 215 | { |
179 | return data->prog; | 216 | return data->prog; |
180 | } | 217 | } |
181 | QDate OTodo::dueDate()const | 218 | |
219 | |||
220 | QDate OTodo::dueDate() const | ||
182 | { | 221 | { |
183 | return data->date; | 222 | return data->date; |
184 | } | 223 | } |
185 | QDate OTodo::startDate()const { | 224 | |
225 | |||
226 | QDate OTodo::startDate() const | ||
227 | { | ||
186 | return data->start; | 228 | return data->start; |
187 | } | 229 | } |
188 | QDate OTodo::completedDate()const { | 230 | |
231 | |||
232 | QDate OTodo::completedDate() const | ||
233 | { | ||
189 | return data->completed; | 234 | return data->completed; |
190 | } | 235 | } |
191 | QString OTodo::description()const | 236 | |
237 | |||
238 | QString OTodo::description() const | ||
192 | { | 239 | { |
193 | return data->desc; | 240 | return data->desc; |
194 | } | 241 | } |
195 | bool OTodo::hasState() const{ | 242 | |
196 | if (!data->state ) return false; | 243 | |
244 | bool OTodo::hasState() const | ||
245 | { | ||
246 | if ( !data->state ) return false; | ||
197 | return ( data->state->state() != OPimState::Undefined ); | 247 | return ( data->state->state() != OPimState::Undefined ); |
198 | } | 248 | } |
199 | OPimState OTodo::state()const { | 249 | |
200 | if (!data->state ) { | 250 | |
251 | OPimState OTodo::state() const | ||
252 | { | ||
253 | if ( !data->state ) | ||
254 | { | ||
201 | OPimState state; | 255 | OPimState state; |
202 | return state; | 256 | return state; |
203 | } | 257 | } |
204 | 258 | ||
205 | return (*data->state); | 259 | return ( *data->state ); |
206 | } | 260 | } |
207 | bool OTodo::hasRecurrence()const { | 261 | |
208 | if (!data->recur) return false; | 262 | |
263 | bool OTodo::hasRecurrence() const | ||
264 | { | ||
265 | if ( !data->recur ) return false; | ||
209 | return data->recur->doesRecur(); | 266 | return data->recur->doesRecur(); |
210 | } | 267 | } |
211 | ORecur OTodo::recurrence()const { | ||
212 | if (!data->recur) return ORecur(); | ||
213 | 268 | ||
214 | return (*data->recur); | 269 | |
270 | ORecur OTodo::recurrence() const | ||
271 | { | ||
272 | if ( !data->recur ) return ORecur(); | ||
273 | |||
274 | return ( *data->recur ); | ||
215 | } | 275 | } |
216 | bool OTodo::hasMaintainer()const { | ||
217 | if (!data->maintainer) return false; | ||
218 | 276 | ||
219 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); | 277 | |
278 | bool OTodo::hasMaintainer() const | ||
279 | { | ||
280 | if ( !data->maintainer ) return false; | ||
281 | |||
282 | return ( data->maintainer->mode() != OPimMaintainer::Undefined ); | ||
220 | } | 283 | } |
221 | OPimMaintainer OTodo::maintainer()const { | ||
222 | if (!data->maintainer) return OPimMaintainer(); | ||
223 | 284 | ||
224 | return (*data->maintainer); | 285 | |
286 | OPimMaintainer OTodo::maintainer() const | ||
287 | { | ||
288 | if ( !data->maintainer ) return OPimMaintainer(); | ||
289 | |||
290 | return ( *data->maintainer ); | ||
225 | } | 291 | } |
292 | |||
293 | |||
226 | void OTodo::setCompleted( bool completed ) | 294 | void OTodo::setCompleted( bool completed ) |
227 | { | 295 | { |
228 | changeOrModify(); | 296 | changeOrModify(); |
229 | data->isCompleted = completed; | 297 | data->isCompleted = completed; |
230 | } | 298 | } |
299 | |||
300 | |||
231 | void OTodo::setHasDueDate( bool hasDate ) | 301 | void OTodo::setHasDueDate( bool hasDate ) |
232 | { | 302 | { |
233 | changeOrModify(); | 303 | changeOrModify(); |
234 | data->hasDate = hasDate; | 304 | data->hasDate = hasDate; |
235 | } | 305 | } |
236 | void OTodo::setDescription(const QString &desc ) | 306 | |
307 | |||
308 | void OTodo::setDescription( const QString &desc ) | ||
237 | { | 309 | { |
238 | // qWarning( "desc " + desc ); | 310 | // qWarning( "desc " + desc ); |
239 | changeOrModify(); | 311 | changeOrModify(); |
240 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 312 | data->desc = Qtopia::simplifyMultiLineSpace( desc ); |
241 | } | 313 | } |
314 | |||
315 | |||
242 | void OTodo::setSummary( const QString& sum ) | 316 | void OTodo::setSummary( const QString& sum ) |
243 | { | 317 | { |
244 | changeOrModify(); | 318 | changeOrModify(); |
245 | data->sum = sum; | 319 | data->sum = sum; |
246 | } | 320 | } |
247 | void OTodo::setPriority(int prio ) | 321 | |
322 | |||
323 | void OTodo::setPriority( int prio ) | ||
248 | { | 324 | { |
249 | changeOrModify(); | 325 | changeOrModify(); |
250 | data->priority = prio; | 326 | data->priority = prio; |
251 | } | 327 | } |
328 | |||
329 | |||
252 | void OTodo::setDueDate( const QDate& date ) | 330 | void OTodo::setDueDate( const QDate& date ) |
253 | { | 331 | { |
254 | changeOrModify(); | 332 | changeOrModify(); |
255 | data->date = date; | 333 | data->date = date; |
256 | } | 334 | } |
257 | void OTodo::setStartDate( const QDate& date ) { | 335 | |
336 | |||
337 | void OTodo::setStartDate( const QDate& date ) | ||
338 | { | ||
258 | changeOrModify(); | 339 | changeOrModify(); |
259 | data->start = date; | 340 | data->start = date; |
260 | } | 341 | } |
261 | void OTodo::setCompletedDate( const QDate& date ) { | 342 | |
343 | |||
344 | void OTodo::setCompletedDate( const QDate& date ) | ||
345 | { | ||
262 | changeOrModify(); | 346 | changeOrModify(); |
263 | data->completed = date; | 347 | data->completed = date; |
264 | } | 348 | } |
265 | void OTodo::setState( const OPimState& state ) { | 349 | |
350 | |||
351 | void OTodo::setState( const OPimState& state ) | ||
352 | { | ||
266 | changeOrModify(); | 353 | changeOrModify(); |
267 | if (data->state ) | 354 | if ( data->state ) |
268 | (*data->state) = state; | 355 | ( *data->state ) = state; |
269 | else | 356 | else |
270 | data->state = new OPimState( state ); | 357 | data->state = new OPimState( state ); |
271 | } | 358 | } |
272 | void OTodo::setRecurrence( const ORecur& rec) { | 359 | |
360 | |||
361 | void OTodo::setRecurrence( const ORecur& rec ) | ||
362 | { | ||
273 | changeOrModify(); | 363 | changeOrModify(); |
274 | if (data->recur ) | 364 | if ( data->recur ) |
275 | (*data->recur) = rec; | 365 | ( *data->recur ) = rec; |
276 | else | 366 | else |
277 | data->recur = new ORecur( rec ); | 367 | data->recur = new ORecur( rec ); |
278 | } | 368 | } |
279 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 369 | |
370 | |||
371 | void OTodo::setMaintainer( const OPimMaintainer& pim ) | ||
372 | { | ||
280 | changeOrModify(); | 373 | changeOrModify(); |
281 | 374 | ||
282 | if (data->maintainer ) | 375 | if ( data->maintainer ) |
283 | (*data->maintainer) = pim; | 376 | ( *data->maintainer ) = pim; |
284 | else | 377 | else |
285 | data->maintainer = new OPimMaintainer( pim ); | 378 | data->maintainer = new OPimMaintainer( pim ); |
286 | } | 379 | } |
380 | |||
381 | |||
287 | bool OTodo::isOverdue( ) | 382 | bool OTodo::isOverdue( ) |
288 | { | 383 | { |
289 | if( data->hasDate && !data->isCompleted) | 384 | if ( data->hasDate && !data->isCompleted ) |
290 | return QDate::currentDate() > data->date; | 385 | return QDate::currentDate() > data->date; |
291 | return false; | 386 | return false; |
292 | } | 387 | } |
293 | void OTodo::setProgress(ushort progress ) | 388 | |
389 | |||
390 | void OTodo::setProgress( ushort progress ) | ||
294 | { | 391 | { |
295 | changeOrModify(); | 392 | changeOrModify(); |
296 | data->prog = progress; | 393 | data->prog = progress; |
297 | } | 394 | } |
298 | QString OTodo::toShortText() const { | 395 | |
299 | return summary(); | 396 | |
397 | QString OTodo::toShortText() const | ||
398 | { | ||
399 | return summary(); | ||
300 | } | 400 | } |
401 | |||
402 | |||
301 | /*! | 403 | /*! |
302 | Returns a richt text string | 404 | Returns a richt text string |
303 | */ | 405 | */ |
304 | QString OTodo::toRichText() const | 406 | QString OTodo::toRichText() const |
305 | { | 407 | { |
306 | QString text; | 408 | QString text; |
307 | QStringList catlist; | 409 | QStringList catlist; |
308 | 410 | ||
309 | // summary | 411 | // summary |
310 | text += "<b><h3><img src=\"todo/TodoList\"> "; | 412 | text += "<b><h3><img src=\"todo/TodoList\"> "; |
311 | if ( !summary().isEmpty() ) { | 413 | if ( !summary().isEmpty() ) |
312 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); | 414 | { |
313 | } | 415 | text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" ); |
314 | text += "</h3></b><br><hr><br>"; | 416 | } |
315 | 417 | text += "</h3></b><br><hr><br>"; | |
316 | // description | 418 | |
317 | if( !description().isEmpty() ){ | 419 | // description |
318 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 420 | if ( !description().isEmpty() ) |
319 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 421 | { |
320 | } | 422 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
321 | 423 | text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; | |
322 | // priority | 424 | } |
323 | int priorityval = priority(); | 425 | |
324 | text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + | 426 | // priority |
325 | QString::number( priorityval ) + "\"> "; | 427 | int priorityval = priority(); |
326 | 428 | text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" + | |
327 | switch ( priorityval ) | 429 | QString::number( priorityval ) + "\"> "; |
328 | { | 430 | |
431 | switch ( priorityval ) | ||
432 | { | ||
329 | case 1 : text += QObject::tr( "Very high" ); | 433 | case 1 : text += QObject::tr( "Very high" ); |
330 | break; | 434 | break; |
331 | case 2 : text += QObject::tr( "High" ); | 435 | case 2 : text += QObject::tr( "High" ); |
332 | break; | 436 | break; |
333 | case 3 : text += QObject::tr( "Normal" ); | 437 | case 3 : text += QObject::tr( "Normal" ); |
334 | break; | 438 | break; |
335 | case 4 : text += QObject::tr( "Low" ); | 439 | case 4 : text += QObject::tr( "Low" ); |
336 | break; | 440 | break; |
337 | case 5 : text += QObject::tr( "Very low" ); | 441 | case 5 : text += QObject::tr( "Very low" ); |
338 | break; | 442 | break; |
339 | }; | 443 | }; |
340 | text += "<br>"; | 444 | text += "<br>"; |
341 | 445 | ||
342 | // progress | 446 | // progress |
343 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 447 | text += "<b>" + QObject::tr( "Progress:" ) + " </b>" |
344 | + QString::number( progress() ) + " %<br>"; | 448 | + QString::number( progress() ) + " %<br>"; |
345 | 449 | ||
346 | // due date | 450 | // due date |
347 | if (hasDueDate() ){ | 451 | if ( hasDueDate() ) |
348 | QDate dd = dueDate(); | 452 | { |
349 | int off = QDate::currentDate().daysTo( dd ); | 453 | QDate dd = dueDate(); |
350 | 454 | int off = QDate::currentDate().daysTo( dd ); | |
351 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; | 455 | |
352 | if ( off < 0 ) | 456 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; |
353 | text += "#FF0000"; | 457 | if ( off < 0 ) |
354 | else if ( off == 0 ) | 458 | text += "#FF0000"; |
355 | text += "#FFFF00"; | 459 | else if ( off == 0 ) |
356 | else if ( off > 0 ) | 460 | text += "#FFFF00"; |
357 | text += "#00FF00"; | 461 | else if ( off > 0 ) |
358 | 462 | text += "#00FF00"; | |
359 | text += "\">" + dd.toString() + "</font><br>"; | 463 | |
360 | } | 464 | text += "\">" + dd.toString() + "</font><br>"; |
361 | 465 | } | |
362 | // categories | 466 | |
363 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 467 | // categories |
364 | text += categoryNames( "Todo List" ).join(", "); | 468 | text += "<b>" + QObject::tr( "Category:" ) + "</b> "; |
365 | text += "<br>"; | 469 | text += categoryNames( "Todo List" ).join( ", " ); |
366 | 470 | text += "<br>"; | |
367 | return text; | 471 | |
368 | } | 472 | return text; |
369 | bool OTodo::hasNotifiers()const { | 473 | } |
370 | if (!data->notifiers) return false; | 474 | |
475 | |||
476 | bool OTodo::hasNotifiers() const | ||
477 | { | ||
478 | if ( !data->notifiers ) return false; | ||
371 | return !data->notifiers->isEmpty(); | 479 | return !data->notifiers->isEmpty(); |
372 | } | 480 | } |
373 | OPimNotifyManager& OTodo::notifiers() { | 481 | |
374 | if (!data->notifiers ) | 482 | |
483 | OPimNotifyManager& OTodo::notifiers() | ||
484 | { | ||
485 | if ( !data->notifiers ) | ||
375 | data->notifiers = new OPimNotifyManager; | 486 | data->notifiers = new OPimNotifyManager; |
376 | return (*data->notifiers); | 487 | return ( *data->notifiers ); |
377 | } | 488 | } |
378 | const OPimNotifyManager& OTodo::notifiers()const{ | 489 | |
379 | if (!data->notifiers ) | 490 | |
491 | const OPimNotifyManager& OTodo::notifiers() const | ||
492 | { | ||
493 | if ( !data->notifiers ) | ||
380 | data->notifiers = new OPimNotifyManager; | 494 | data->notifiers = new OPimNotifyManager; |
381 | 495 | ||
382 | return (*data->notifiers); | 496 | return ( *data->notifiers ); |
383 | } | 497 | } |
384 | 498 | ||
385 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 499 | |
386 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 500 | bool OTodo::operator<( const OTodo &toDoEvent ) const |
387 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 501 | { |
388 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 502 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
389 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 503 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
390 | return priority() < toDoEvent.priority(); | 504 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
391 | }else{ | 505 | { |
392 | return dueDate() < toDoEvent.dueDate(); | 506 | if ( dueDate() == toDoEvent.dueDate() ) |
393 | } | 507 | { // let's the priority decide |
508 | return priority() < toDoEvent.priority(); | ||
509 | } | ||
510 | else | ||
511 | { | ||
512 | return dueDate() < toDoEvent.dueDate(); | ||
513 | } | ||
394 | } | 514 | } |
395 | return false; | 515 | return false; |
396 | } | 516 | } |
397 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 517 | |
518 | |||
519 | bool OTodo::operator<=( const OTodo &toDoEvent ) const | ||
398 | { | 520 | { |
399 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 521 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
400 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 522 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
401 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 523 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
402 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 524 | { |
403 | return priority() <= toDoEvent.priority(); | 525 | if ( dueDate() == toDoEvent.dueDate() ) |
404 | }else{ | 526 | { // let's the priority decide |
405 | return dueDate() <= toDoEvent.dueDate(); | 527 | return priority() <= toDoEvent.priority(); |
406 | } | 528 | } |
529 | else | ||
530 | { | ||
531 | return dueDate() <= toDoEvent.dueDate(); | ||
532 | } | ||
407 | } | 533 | } |
408 | return true; | 534 | return true; |
409 | } | 535 | } |
410 | bool OTodo::operator>(const OTodo &toDoEvent )const | 536 | |
537 | |||
538 | bool OTodo::operator>( const OTodo &toDoEvent ) const | ||
411 | { | 539 | { |
412 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 540 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
413 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 541 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
414 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 542 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
415 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 543 | { |
416 | return priority() > toDoEvent.priority(); | 544 | if ( dueDate() == toDoEvent.dueDate() ) |
417 | }else{ | 545 | { // let's the priority decide |
418 | return dueDate() > toDoEvent.dueDate(); | 546 | return priority() > toDoEvent.priority(); |
419 | } | 547 | } |
548 | else | ||
549 | { | ||
550 | return dueDate() > toDoEvent.dueDate(); | ||
551 | } | ||
420 | } | 552 | } |
421 | return false; | 553 | return false; |
422 | } | 554 | } |
423 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 555 | |
556 | |||
557 | bool OTodo::operator>=( const OTodo &toDoEvent ) const | ||
424 | { | 558 | { |
425 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 559 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
426 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 560 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
427 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 561 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
428 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 562 | { |
429 | return priority() > toDoEvent.priority(); | 563 | if ( dueDate() == toDoEvent.dueDate() ) |
430 | }else{ | 564 | { // let's the priority decide |
431 | return dueDate() > toDoEvent.dueDate(); | 565 | return priority() > toDoEvent.priority(); |
432 | } | 566 | } |
567 | else | ||
568 | { | ||
569 | return dueDate() > toDoEvent.dueDate(); | ||
570 | } | ||
433 | } | 571 | } |
434 | return true; | 572 | return true; |
435 | } | 573 | } |
436 | bool OTodo::operator==(const OTodo &toDoEvent )const | 574 | |
575 | |||
576 | bool OTodo::operator==( const OTodo &toDoEvent ) const | ||
437 | { | 577 | { |
438 | if ( data->priority != toDoEvent.data->priority ) return false; | 578 | if ( data->priority != toDoEvent.data->priority ) return false; |
439 | if ( data->priority != toDoEvent.data->prog ) return false; | 579 | if ( data->priority != toDoEvent.data->prog ) return false; |
440 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; | 580 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; |
441 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; | 581 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; |
442 | if ( data->date != toDoEvent.data->date ) return false; | 582 | if ( data->date != toDoEvent.data->date ) return false; |
443 | if ( data->sum != toDoEvent.data->sum ) return false; | 583 | if ( data->sum != toDoEvent.data->sum ) return false; |
444 | if ( data->desc != toDoEvent.data->desc ) return false; | 584 | if ( data->desc != toDoEvent.data->desc ) return false; |
445 | if ( data->maintainer != toDoEvent.data->maintainer ) | 585 | if ( data->maintainer != toDoEvent.data->maintainer ) |
446 | return false; | 586 | return false; |
447 | 587 | ||
448 | return OPimRecord::operator==( toDoEvent ); | 588 | return OPimRecord::operator==( toDoEvent ); |
449 | } | 589 | } |
450 | void OTodo::deref() { | ||
451 | 590 | ||
452 | // qWarning("deref in ToDoEvent"); | 591 | |
453 | if ( data->deref() ) { | 592 | void OTodo::deref() |
454 | // qWarning("deleting"); | 593 | { |
594 | |||
595 | // qWarning("deref in ToDoEvent"); | ||
596 | if ( data->deref() ) | ||
597 | { | ||
598 | // qWarning("deleting"); | ||
455 | delete data; | 599 | delete data; |
456 | data= 0; | 600 | data = 0; |
457 | } | 601 | } |
458 | } | 602 | } |
459 | OTodo &OTodo::operator=(const OTodo &item ) | 603 | |
604 | |||
605 | OTodo &OTodo::operator=( const OTodo &item ) | ||
460 | { | 606 | { |
461 | if ( this == &item ) return *this; | 607 | if ( this == &item ) return * this; |
462 | 608 | ||
463 | OPimRecord::operator=( item ); | 609 | OPimRecord::operator=( item ); |
464 | //qWarning("operator= ref "); | 610 | //qWarning("operator= ref "); |
465 | item.data->ref(); | 611 | item.data->ref(); |
466 | deref(); | 612 | deref(); |
467 | data = item.data; | 613 | data = item.data; |
468 | 614 | ||
469 | return *this; | 615 | return *this; |
470 | } | 616 | } |
471 | 617 | ||
472 | QMap<int, QString> OTodo::toMap() const { | 618 | |
619 | QMap<int, QString> OTodo::toMap() const | ||
620 | { | ||
473 | QMap<int, QString> map; | 621 | QMap<int, QString> map; |
474 | 622 | ||
475 | map.insert( Uid, QString::number( uid() ) ); | 623 | map.insert( Uid, QString::number( uid() ) ); |
476 | map.insert( Category, idsToString( categories() ) ); | 624 | map.insert( Category, idsToString( categories() ) ); |
477 | map.insert( HasDate, QString::number( data->hasDate ) ); | 625 | map.insert( HasDate, QString::number( data->hasDate ) ); |
478 | map.insert( Completed, QString::number( data->isCompleted ) ); | 626 | map.insert( Completed, QString::number( data->isCompleted ) ); |
479 | map.insert( Description, data->desc ); | 627 | map.insert( Description, data->desc ); |
480 | map.insert( Summary, data->sum ); | 628 | map.insert( Summary, data->sum ); |
481 | map.insert( Priority, QString::number( data->priority ) ); | 629 | map.insert( Priority, QString::number( data->priority ) ); |
482 | map.insert( DateDay, QString::number( data->date.day() ) ); | 630 | map.insert( DateDay, QString::number( data->date.day() ) ); |
483 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 631 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
484 | map.insert( DateYear, QString::number( data->date.year() ) ); | 632 | map.insert( DateYear, QString::number( data->date.year() ) ); |
485 | map.insert( Progress, QString::number( data->prog ) ); | 633 | map.insert( Progress, QString::number( data->prog ) ); |
486 | // map.insert( CrossReference, crossToString() ); | 634 | // map.insert( CrossReference, crossToString() ); |
487 | /* FIXME!!! map.insert( State, ); | 635 | /* FIXME!!! map.insert( State, ); |
488 | map.insert( Recurrence, ); | 636 | map.insert( Recurrence, ); |
489 | map.insert( Reminders, ); | 637 | map.insert( Reminders, ); |
490 | map. | 638 | map. |
491 | */ | 639 | */ |
492 | return map; | 640 | return map; |
493 | } | 641 | } |
494 | 642 | ||
643 | |||
495 | /** | 644 | /** |
496 | * change or modify looks at the ref count and either | 645 | * change or modify looks at the ref count and either |
497 | * creates a new QShared Object or it can modify it | 646 | * creates a new QShared Object or it can modify it |
498 | * right in place | 647 | * right in place |
499 | */ | 648 | */ |
500 | void OTodo::changeOrModify() { | 649 | void OTodo::changeOrModify() |
501 | if ( data->count != 1 ) { | 650 | { |
502 | qWarning("changeOrModify"); | 651 | if ( data->count != 1 ) |
652 | { | ||
653 | qWarning( "changeOrModify" ); | ||
503 | data->deref(); | 654 | data->deref(); |
504 | OTodoData* d2 = new OTodoData(); | 655 | OTodoData* d2 = new OTodoData(); |
505 | copy(data, d2 ); | 656 | copy( data, d2 ); |
506 | data = d2; | 657 | data = d2; |
507 | } | 658 | } |
508 | } | 659 | } |
660 | |||
661 | |||
509 | // WATCHOUT | 662 | // WATCHOUT |
510 | /* | 663 | /* |
511 | * if you add something to the Data struct | 664 | * if you add something to the Data struct |
512 | * be sure to copy it here | 665 | * be sure to copy it here |
513 | */ | 666 | */ |
514 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 667 | void OTodo::copy( OTodoData* src, OTodoData* dest ) |
668 | { | ||
515 | dest->date = src->date; | 669 | dest->date = src->date; |
516 | dest->isCompleted = src->isCompleted; | 670 | dest->isCompleted = src->isCompleted; |
517 | dest->hasDate = src->hasDate; | 671 | dest->hasDate = src->hasDate; |
518 | dest->priority = src->priority; | 672 | dest->priority = src->priority; |
519 | dest->desc = src->desc; | 673 | dest->desc = src->desc; |
520 | dest->sum = src->sum; | 674 | dest->sum = src->sum; |
521 | dest->extra = src->extra; | 675 | dest->extra = src->extra; |
522 | dest->prog = src->prog; | 676 | dest->prog = src->prog; |
523 | 677 | ||
524 | if (src->state ) | 678 | if ( src->state ) |
525 | dest->state = new OPimState( *src->state ); | 679 | dest->state = new OPimState( *src->state ); |
526 | 680 | ||
527 | if (src->recur ) | 681 | if ( src->recur ) |
528 | dest->recur = new ORecur( *src->recur ); | 682 | dest->recur = new ORecur( *src->recur ); |
529 | 683 | ||
530 | if (src->maintainer ) | 684 | if ( src->maintainer ) |
531 | dest->maintainer = new OPimMaintainer( *src->maintainer ) | 685 | dest->maintainer = new OPimMaintainer( *src->maintainer ) |
532 | ; | 686 | ; |
533 | dest->start = src->start; | 687 | dest->start = src->start; |
534 | dest->completed = src->completed; | 688 | dest->completed = src->completed; |
535 | 689 | ||
536 | if (src->notifiers ) | 690 | if ( src->notifiers ) |
537 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); | 691 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); |
538 | } | 692 | } |
539 | QString OTodo::type() const { | 693 | |
540 | return QString::fromLatin1("OTodo"); | 694 | |
695 | QString OTodo::type() const | ||
696 | { | ||
697 | return QString::fromLatin1( "OTodo" ); | ||
541 | } | 698 | } |
542 | QString OTodo::recordField(int /*id*/ )const { | 699 | |
700 | |||
701 | QString OTodo::recordField( int /*id*/ ) const | ||
702 | { | ||
543 | return QString::null; | 703 | return QString::null; |
544 | } | 704 | } |
545 | 705 | ||
546 | int OTodo::rtti(){ | 706 | |
707 | int OTodo::rtti() | ||
708 | { | ||
547 | return OPimResolver::TodoList; | 709 | return OPimResolver::TodoList; |
548 | } | 710 | } |
549 | 711 | ||
550 | } | 712 | } |
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h index 61add04..04dd269 100644 --- a/libopie2/opiepim/otodo.h +++ b/libopie2/opiepim/otodo.h | |||
@@ -1,315 +1,320 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_TODO_EVENT_H | ||
30 | #define OPIE_TODO_EVENT_H | ||
31 | 29 | ||
30 | #ifndef OTODOEVENT_H | ||
31 | #define OTODOEVENT_H | ||
32 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <opie2/opimrecord.h> | ||
35 | #include <qpe/recordfields.h> | ||
36 | #include <qpe/palmtopuidgen.h> | ||
37 | |||
38 | /* QT */ | ||
33 | #include <qarray.h> | 39 | #include <qarray.h> |
34 | #include <qmap.h> | 40 | #include <qmap.h> |
35 | #include <qregexp.h> | 41 | #include <qregexp.h> |
36 | #include <qstringlist.h> | 42 | #include <qstringlist.h> |
37 | #include <qdatetime.h> | 43 | #include <qdatetime.h> |
38 | #include <qvaluelist.h> | 44 | #include <qvaluelist.h> |
39 | 45 | ||
40 | #include <qpe/recordfields.h> | 46 | namespace Opie |
41 | #include <qpe/palmtopuidgen.h> | 47 | { |
42 | |||
43 | #include <opie2/opimrecord.h> | ||
44 | |||
45 | |||
46 | namespace Opie { | ||
47 | 48 | ||
48 | class OPimState; | 49 | class OPimState; |
49 | class ORecur; | 50 | class ORecur; |
50 | class OPimMaintainer; | 51 | class OPimMaintainer; |
51 | class OPimNotifyManager; | 52 | class OPimNotifyManager; |
52 | class OTodo : public OPimRecord { | 53 | class OTodo : public OPimRecord |
53 | public: | 54 | { |
55 | public: | ||
54 | typedef QValueList<OTodo> ValueList; | 56 | typedef QValueList<OTodo> ValueList; |
55 | enum RecordFields { | 57 | enum RecordFields { |
56 | Uid = Qtopia::UID_ID, | 58 | Uid = Qtopia::UID_ID, |
57 | Category = Qtopia::CATEGORY_ID, | 59 | Category = Qtopia::CATEGORY_ID, |
58 | HasDate, | 60 | HasDate, |
59 | Completed, | 61 | Completed, |
60 | Description, | 62 | Description, |
61 | Summary, | 63 | Summary, |
62 | Priority, | 64 | Priority, |
63 | DateDay, | 65 | DateDay, |
64 | DateMonth, | 66 | DateMonth, |
65 | DateYear, | 67 | DateYear, |
66 | Progress, | 68 | Progress, |
67 | CrossReference, | 69 | CrossReference, |
68 | State, | 70 | State, |
69 | Recurrence, | 71 | Recurrence, |
70 | Alarms, | 72 | Alarms, |
71 | Reminders, | 73 | Reminders, |
72 | Notifiers, | 74 | Notifiers, |
73 | Maintainer, | 75 | Maintainer, |
74 | StartDate, | 76 | StartDate, |
75 | CompletedDate | 77 | CompletedDate |
76 | }; | 78 | }; |
77 | public: | 79 | public: |
78 | // priorities from Very low to very high | 80 | // priorities from Very low to very high |
79 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; | 81 | enum TaskPriority { VeryHigh = 1, High, Normal, Low, VeryLow }; |
80 | 82 | ||
81 | /* Constructs a new ToDoEvent | 83 | /* Constructs a new ToDoEvent |
82 | @param completed Is the TodoEvent completed | 84 | @param completed Is the TodoEvent completed |
83 | @param priority What is the priority of this ToDoEvent | 85 | @param priority What is the priority of this ToDoEvent |
84 | @param category Which category does it belong( uid ) | 86 | @param category Which category does it belong( uid ) |
85 | @param summary A small summary of the todo | 87 | @param summary A small summary of the todo |
86 | @param description What is this ToDoEvent about | 88 | @param description What is this ToDoEvent about |
87 | @param hasDate Does this Event got a deadline | 89 | @param hasDate Does this Event got a deadline |
88 | @param date what is the deadline? | 90 | @param date what is the deadline? |
89 | @param uid what is the UUID of this Event | 91 | @param uid what is the UUID of this Event |
90 | **/ | 92 | **/ |
91 | OTodo( bool completed = false, int priority = Normal, | 93 | OTodo( bool completed = false, int priority = Normal, |
92 | const QStringList &category = QStringList(), | 94 | const QStringList &category = QStringList(), |
93 | const QString &summary = QString::null , | 95 | const QString &summary = QString::null , |
94 | const QString &description = QString::null, | 96 | const QString &description = QString::null, |
95 | ushort progress = 0, | 97 | ushort progress = 0, |
96 | bool hasDate = false, QDate date = QDate::currentDate(), | 98 | bool hasDate = false, QDate date = QDate::currentDate(), |
97 | int uid = 0 /*empty*/ ); | 99 | int uid = 0 /*empty*/ ); |
98 | 100 | ||
99 | OTodo( bool completed, int priority, | 101 | OTodo( bool completed, int priority, |
100 | const QArray<int>& category, | 102 | const QArray<int>& category, |
101 | const QString& summary = QString::null, | 103 | const QString& summary = QString::null, |
102 | const QString& description = QString::null, | 104 | const QString& description = QString::null, |
103 | ushort progress = 0, | 105 | ushort progress = 0, |
104 | bool hasDate = false, QDate date = QDate::currentDate(), | 106 | bool hasDate = false, QDate date = QDate::currentDate(), |
105 | int uid = 0 /* empty */ ); | 107 | int uid = 0 /* empty */ ); |
106 | 108 | ||
107 | /** Copy c'tor | 109 | /** Copy c'tor |
108 | * | 110 | * |
109 | */ | 111 | */ |
110 | OTodo(const OTodo & ); | 112 | OTodo( const OTodo & ); |
111 | 113 | ||
112 | /** | 114 | /** |
113 | *destructor | 115 | *destructor |
114 | */ | 116 | */ |
115 | ~OTodo(); | 117 | ~OTodo(); |
116 | 118 | ||
117 | /** | 119 | /** |
118 | * Is this event completed? | 120 | * Is this event completed? |
119 | */ | 121 | */ |
120 | bool isCompleted() const; | 122 | bool isCompleted() const; |
121 | 123 | ||
122 | /** | 124 | /** |
123 | * Does this Event have a deadline | 125 | * Does this Event have a deadline |
124 | */ | 126 | */ |
125 | bool hasDueDate() const; | 127 | bool hasDueDate() const; |
126 | bool hasStartDate()const; | 128 | bool hasStartDate() const; |
127 | bool hasCompletedDate()const; | 129 | bool hasCompletedDate() const; |
128 | 130 | ||
129 | /** | 131 | /** |
130 | * What is the priority? | 132 | * What is the priority? |
131 | */ | 133 | */ |
132 | int priority()const ; | 134 | int priority() const ; |
133 | 135 | ||
134 | /** | 136 | /** |
135 | * progress as ushort 0, 20, 40, 60, 80 or 100% | 137 | * progress as ushort 0, 20, 40, 60, 80 or 100% |
136 | */ | 138 | */ |
137 | ushort progress() const; | 139 | ushort progress() const; |
138 | 140 | ||
139 | /** | 141 | /** |
140 | * The due Date | 142 | * The due Date |
141 | */ | 143 | */ |
142 | QDate dueDate()const; | 144 | QDate dueDate() const; |
143 | 145 | ||
144 | /** | 146 | /** |
145 | * When did it start? | 147 | * When did it start? |
146 | */ | 148 | */ |
147 | QDate startDate()const; | 149 | QDate startDate() const; |
148 | 150 | ||
149 | /** | 151 | /** |
150 | * When was it completed? | 152 | * When was it completed? |
151 | */ | 153 | */ |
152 | QDate completedDate()const; | 154 | QDate completedDate() const; |
153 | 155 | ||
154 | /** | 156 | /** |
155 | * does it have a state? | 157 | * does it have a state? |
156 | */ | 158 | */ |
157 | bool hasState()const; | 159 | bool hasState() const; |
158 | 160 | ||
159 | /** | 161 | /** |
160 | * What is the state of this OTodo? | 162 | * What is the state of this OTodo? |
161 | */ | 163 | */ |
162 | OPimState state()const; | 164 | OPimState state() const; |
163 | 165 | ||
164 | /** | 166 | /** |
165 | * has recurrence? | 167 | * has recurrence? |
166 | */ | 168 | */ |
167 | bool hasRecurrence()const; | 169 | bool hasRecurrence() const; |
168 | 170 | ||
169 | /** | 171 | /** |
170 | * the recurrance of this | 172 | * the recurrance of this |
171 | */ | 173 | */ |
172 | ORecur recurrence()const; | 174 | ORecur recurrence() const; |
173 | 175 | ||
174 | /** | 176 | /** |
175 | * does this OTodo have a maintainer? | 177 | * does this OTodo have a maintainer? |
176 | */ | 178 | */ |
177 | bool hasMaintainer()const; | 179 | bool hasMaintainer() const; |
178 | 180 | ||
179 | /** | 181 | /** |
180 | * the Maintainer of this OTodo | 182 | * the Maintainer of this OTodo |
181 | */ | 183 | */ |
182 | OPimMaintainer maintainer()const; | 184 | OPimMaintainer maintainer() const; |
183 | 185 | ||
184 | /** | 186 | /** |
185 | * The description of the todo | 187 | * The description of the todo |
186 | */ | 188 | */ |
187 | QString description()const; | 189 | QString description() const; |
188 | 190 | ||
189 | /** | 191 | /** |
190 | * A small summary of the todo | 192 | * A small summary of the todo |
191 | */ | 193 | */ |
192 | QString summary() const; | 194 | QString summary() const; |
193 | 195 | ||
194 | /** | 196 | /** |
195 | * @reimplemented | 197 | * @reimplemented |
196 | * Return this todoevent in a RichText formatted QString | 198 | * Return this todoevent in a RichText formatted QString |
197 | */ | 199 | */ |
198 | QString toRichText() const; | 200 | QString toRichText() const; |
199 | 201 | ||
200 | bool hasNotifiers()const; | 202 | bool hasNotifiers() const; |
201 | /* | 203 | /* |
202 | * FIXME check if the sharing is still fine!! -zecke | 204 | * FIXME check if the sharing is still fine!! -zecke |
203 | * ### CHECK If API is fine | 205 | * ### CHECK If API is fine |
204 | */ | 206 | */ |
205 | /** | 207 | /** |
206 | * return a reference to our notifiers... | 208 | * return a reference to our notifiers... |
207 | */ | 209 | */ |
208 | OPimNotifyManager ¬ifiers(); | 210 | OPimNotifyManager ¬ifiers(); |
209 | 211 | ||
210 | /** | 212 | /** |
211 | * | 213 | * |
212 | */ | 214 | */ |
213 | const OPimNotifyManager ¬ifiers()const; | 215 | const OPimNotifyManager ¬ifiers() const; |
214 | 216 | ||
215 | /** | 217 | /** |
216 | * reimplementations | 218 | * reimplementations |
217 | */ | 219 | */ |
218 | QString type()const; | 220 | QString type() const; |
219 | QString toShortText()const; | 221 | QString toShortText() const; |
220 | QString recordField(int id )const; | 222 | QString recordField( int id ) const; |
221 | 223 | ||
222 | /** | 224 | /** |
223 | * toMap puts all data into the map. int relates | 225 | * toMap puts all data into the map. int relates |
224 | * to ToDoEvent RecordFields enum | 226 | * to ToDoEvent RecordFields enum |
225 | */ | 227 | */ |
226 | QMap<int, QString> toMap()const; | 228 | QMap<int, QString> toMap() const; |
227 | 229 | ||
228 | /** | 230 | /** |
229 | * Set if this Todo is completed | 231 | * Set if this Todo is completed |
230 | */ | 232 | */ |
231 | void setCompleted(bool completed ); | 233 | void setCompleted( bool completed ); |
232 | 234 | ||
233 | /** | 235 | /** |
234 | * set if this todo got an end data | 236 | * set if this todo got an end data |
235 | */ | 237 | */ |
236 | void setHasDueDate( bool hasDate ); | 238 | void setHasDueDate( bool hasDate ); |
237 | // FIXME we do not have these for start, completed | 239 | // FIXME we do not have these for start, completed |
238 | // cause we'll use the isNull() of QDate for figuring | 240 | // cause we'll use the isNull() of QDate for figuring |
239 | // out if it's has a date... | 241 | // out if it's has a date... |
240 | // decide what to do here? -zecke | 242 | // decide what to do here? -zecke |
241 | 243 | ||
242 | /** | 244 | /** |
243 | * Set the priority of the Todo | 245 | * Set the priority of the Todo |
244 | */ | 246 | */ |
245 | void setPriority(int priority ); | 247 | void setPriority( int priority ); |
246 | 248 | ||
247 | /** | 249 | /** |
248 | * Set the progress. | 250 | * Set the progress. |
249 | */ | 251 | */ |
250 | void setProgress( ushort progress ); | 252 | void setProgress( ushort progress ); |
251 | 253 | ||
252 | /** | 254 | /** |
253 | * set the end date | 255 | * set the end date |
254 | */ | 256 | */ |
255 | void setDueDate( const QDate& date ); | 257 | void setDueDate( const QDate& date ); |
256 | 258 | ||
257 | /** | 259 | /** |
258 | * set the start date | 260 | * set the start date |
259 | */ | 261 | */ |
260 | void setStartDate( const QDate& date ); | 262 | void setStartDate( const QDate& date ); |
261 | 263 | ||
262 | /** | 264 | /** |
263 | * set the completed date | 265 | * set the completed date |
264 | */ | 266 | */ |
265 | void setCompletedDate( const QDate& date ); | 267 | void setCompletedDate( const QDate& date ); |
266 | 268 | ||
267 | void setRecurrence( const ORecur& ); | 269 | void setRecurrence( const ORecur& ); |
268 | 270 | ||
269 | void setDescription(const QString& ); | 271 | void setDescription( const QString& ); |
270 | void setSummary(const QString& ); | 272 | void setSummary( const QString& ); |
271 | 273 | ||
272 | /** | 274 | /** |
273 | * set the state of a Todo | 275 | * set the state of a Todo |
274 | * @param state State what the todo should take | 276 | * @param state State what the todo should take |
275 | */ | 277 | */ |
276 | void setState( const OPimState& state); | 278 | void setState( const OPimState& state ); |
277 | 279 | ||
278 | /** | 280 | /** |
279 | * set the Maintainer Mode | 281 | * set the Maintainer Mode |
280 | */ | 282 | */ |
281 | void setMaintainer( const OPimMaintainer& ); | 283 | void setMaintainer( const OPimMaintainer& ); |
282 | 284 | ||
283 | bool isOverdue(); | 285 | bool isOverdue(); |
284 | 286 | ||
285 | 287 | ||
286 | virtual bool match( const QRegExp &r )const; | 288 | virtual bool match( const QRegExp &r ) const; |
287 | 289 | ||
288 | bool operator<(const OTodo &toDoEvent )const; | 290 | bool operator<( const OTodo &toDoEvent ) const; |
289 | bool operator<=(const OTodo &toDoEvent )const; | 291 | bool operator<=( const OTodo &toDoEvent ) const; |
290 | bool operator!=(const OTodo &toDoEvent )const; | 292 | bool operator!=( const OTodo &toDoEvent ) const; |
291 | bool operator>(const OTodo &toDoEvent )const; | 293 | bool operator>( const OTodo &toDoEvent ) const; |
292 | bool operator>=(const OTodo &toDoEvent)const; | 294 | bool operator>=( const OTodo &toDoEvent ) const; |
293 | bool operator==(const OTodo &toDoEvent )const; | 295 | bool operator==( const OTodo &toDoEvent ) const; |
294 | OTodo &operator=(const OTodo &toDoEvent ); | 296 | OTodo &operator=( const OTodo &toDoEvent ); |
295 | 297 | ||
296 | static int rtti(); | 298 | static int rtti(); |
297 | 299 | ||
298 | private: | 300 | private: |
299 | class OTodoPrivate; | 301 | class OTodoPrivate; |
300 | struct OTodoData; | 302 | struct OTodoData; |
301 | 303 | ||
302 | void deref(); | 304 | void deref(); |
303 | inline void changeOrModify(); | 305 | inline void changeOrModify(); |
304 | void copy( OTodoData* src, OTodoData* dest ); | 306 | void copy( OTodoData* src, OTodoData* dest ); |
305 | OTodoPrivate *d; | 307 | OTodoPrivate *d; |
306 | OTodoData *data; | 308 | OTodoData *data; |
307 | 309 | ||
308 | }; | 310 | }; |
309 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | 311 | |
310 | return !(*this == toDoEvent); | 312 | |
313 | inline bool OTodo::operator!=( const OTodo &toDoEvent ) const | ||
314 | { | ||
315 | return !( *this == toDoEvent ); | ||
311 | } | 316 | } |
312 | 317 | ||
313 | } | 318 | } |
314 | 319 | ||
315 | #endif | 320 | #endif |