-rw-r--r-- | library/backend/categories.cpp | 146 | ||||
-rw-r--r-- | library/backend/categories.h | 12 | ||||
-rw-r--r-- | library/backend/contact.cpp | 107 | ||||
-rw-r--r-- | library/backend/contact.h | 7 | ||||
-rw-r--r-- | library/backend/event.h | 5 | ||||
-rw-r--r-- | library/backend/recordfields.h | 46 | ||||
-rw-r--r-- | library/backend/task.h | 4 | ||||
-rw-r--r-- | library/backend/vobject.cpp | 9 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 3 |
9 files changed, 182 insertions, 157 deletions
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp index 91331db..6e011c4 100644 --- a/library/backend/categories.cpp +++ b/library/backend/categories.cpp | |||
@@ -110,158 +110,128 @@ bool CategoryGroup::rename( int uid, const QString &newLabel ) | |||
110 | mLabelIdMap[newLabel] = uid; | 110 | mLabelIdMap[newLabel] = uid; |
111 | *idIt = newLabel; | 111 | *idIt = newLabel; |
112 | 112 | ||
113 | return TRUE; | 113 | return TRUE; |
114 | } | 114 | } |
115 | 115 | ||
116 | bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) | 116 | bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) |
117 | { | 117 | { |
118 | return rename( id(oldLabel), newLabel ); | 118 | return rename( id(oldLabel), newLabel ); |
119 | } | 119 | } |
120 | 120 | ||
121 | bool CategoryGroup::contains(int uid) const | 121 | bool CategoryGroup::contains(int uid) const |
122 | { | 122 | { |
123 | return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() ); | 123 | return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() ); |
124 | } | 124 | } |
125 | 125 | ||
126 | bool CategoryGroup::contains(const QString &label) const | 126 | bool CategoryGroup::contains(const QString &label) const |
127 | { | 127 | { |
128 | return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); | 128 | return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); |
129 | } | 129 | } |
130 | 130 | ||
131 | /** Returns label associated with the uid or QString::null if | 131 | /** Returns label associated with the uid or QString::null if |
132 | * not found | 132 | * not found |
133 | */ | 133 | */ |
134 | const QString &CategoryGroup::label(int uid) const | 134 | const QString &CategoryGroup::label(int uid) const |
135 | { | 135 | { |
136 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); | 136 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); |
137 | if ( idIt == mIdLabelMap.end() ) | 137 | if ( idIt == mIdLabelMap.end() ) |
138 | return QString::null; | 138 | return QString::null; |
139 | return *idIt; | 139 | return *idIt; |
140 | } | 140 | } |
141 | 141 | ||
142 | /** Returns the uid associated with label or 0 if not found */ | 142 | /** Returns the uid associated with label or 0 if not found */ |
143 | int CategoryGroup::id(const QString &label) const | 143 | int CategoryGroup::id(const QString &label) const |
144 | { | 144 | { |
145 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); | 145 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); |
146 | if ( labelIt == mLabelIdMap.end() ) | 146 | if ( labelIt == mLabelIdMap.end() ) |
147 | return 0; | 147 | return 0; |
148 | return *labelIt; | 148 | return *labelIt; |
149 | } | 149 | } |
150 | 150 | ||
151 | QStringList CategoryGroup::labels() const | 151 | QStringList CategoryGroup::labels() const |
152 | { | 152 | { |
153 | QStringList labels; | 153 | QStringList labels; |
154 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); | 154 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); |
155 | it != mIdLabelMap.end(); ++it ) | 155 | it != mIdLabelMap.end(); ++it ) |
156 | labels += *it; | 156 | labels += *it; |
157 | // ### I don't think this is the place for this... | 157 | // ### I don't think this is the place for this... |
158 | // labels.sort(); | 158 | // labels.sort(); |
159 | return labels; | 159 | return labels; |
160 | } | 160 | } |
161 | 161 | ||
162 | QStringList CategoryGroup::labels(const QArray<int> &catids ) const | 162 | QStringList CategoryGroup::labels(const QArray<int> &catids ) const |
163 | { | 163 | { |
164 | QStringList labels; | 164 | QStringList labels; |
165 | if ( catids.count() == 0 ) | 165 | if ( catids.count() == 0 ) |
166 | return labels; | 166 | return labels; |
167 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); | 167 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); |
168 | it != mIdLabelMap.end(); ++it ) | 168 | it != mIdLabelMap.end(); ++it ) |
169 | if ( catids.find( it.key() ) != -1 ) | 169 | if ( catids.find( it.key() ) != -1 ) |
170 | labels += *it; | 170 | labels += *it; |
171 | return labels; | 171 | return labels; |
172 | } | 172 | } |
173 | 173 | ||
174 | QArray<int> CategoryGroup::ids( const QStringList &cats ) const | ||
175 | { | ||
176 | QArray<int> results; | ||
177 | |||
178 | for ( QStringList::ConstIterator catIt = cats.begin(); | ||
179 | catIt != cats.end(); ++catIt ) { | ||
180 | if ( *catIt == QObject::tr("All") || *catIt == QObject::tr("Unfiled") ) | ||
181 | continue; | ||
182 | int value = id( *catIt ); | ||
183 | if ( value != 0 ) { | ||
184 | int tmp = results.size(); | ||
185 | results.resize( tmp + 1 ); | ||
186 | results[ tmp ] = value; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | return results; | ||
191 | } | ||
192 | |||
193 | QArray<int> CategoryGroup::ids() const | ||
194 | { | ||
195 | QArray<int> results( mIdLabelMap.count() ); | ||
196 | int i = 0; | ||
197 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); | ||
198 | it != mIdLabelMap.end(); ++it ) | ||
199 | results[i++] = it.key(); | ||
200 | |||
201 | return results; | ||
202 | } | ||
203 | |||
204 | /*********************************************************** | 174 | /*********************************************************** |
205 | * | 175 | * |
206 | * Categories | 176 | * Categories |
207 | * | 177 | * |
208 | **********************************************************/ | 178 | **********************************************************/ |
209 | 179 | ||
210 | /** Add the category name as long as it doesn't already exist locally | 180 | /** Add the category name as long as it doesn't already exist locally |
211 | * or globally. Return TRUE if added, FALSE if conflicts. | 181 | * or globally. Return TRUE if added, FALSE if conflicts. |
212 | */ | 182 | */ |
213 | int Categories::addCategory( const QString &appname, | 183 | int Categories::addCategory( const QString &appname, |
214 | const QString &catname, | 184 | const QString &catname, |
215 | int uid ) | 185 | int uid ) |
216 | { | 186 | { |
217 | if ( mGlobalCats.contains(catname) ) | 187 | if ( mGlobalCats.contains(catname) ) |
218 | return 0; | 188 | return 0; |
219 | 189 | ||
220 | QMap< QString, CategoryGroup >::Iterator | 190 | QMap< QString, CategoryGroup >::Iterator |
221 | appIt = mAppCats.find( appname ); | 191 | appIt = mAppCats.find( appname ); |
222 | 192 | ||
223 | if ( appIt == mAppCats.end() ) { | 193 | if ( appIt == mAppCats.end() ) { |
224 | CategoryGroup newgroup; | 194 | CategoryGroup newgroup; |
225 | newgroup.add( uid, catname ); | 195 | newgroup.add( uid, catname ); |
226 | mAppCats.insert( appname, newgroup ); | 196 | mAppCats.insert( appname, newgroup ); |
227 | emit categoryAdded( *this, appname, uid ); | 197 | emit categoryAdded( *this, appname, uid ); |
228 | return uid; | 198 | return uid; |
229 | } | 199 | } |
230 | 200 | ||
231 | CategoryGroup &cats = *appIt; | 201 | CategoryGroup &cats = *appIt; |
232 | cats.add( uid, catname ); | 202 | cats.add( uid, catname ); |
233 | emit categoryAdded( *this, appname, uid ); | 203 | emit categoryAdded( *this, appname, uid ); |
234 | return uid; | 204 | return uid; |
235 | } | 205 | } |
236 | 206 | ||
237 | int Categories::addCategory( const QString &appname, | 207 | int Categories::addCategory( const QString &appname, |
238 | const QString &catname ) | 208 | const QString &catname ) |
239 | { | 209 | { |
240 | if ( mGlobalCats.contains(catname) ) | 210 | if ( mGlobalCats.contains(catname) ) |
241 | return 0; | 211 | return 0; |
242 | 212 | ||
243 | QMap< QString, CategoryGroup >::Iterator | 213 | QMap< QString, CategoryGroup >::Iterator |
244 | appIt = mAppCats.find( appname ); | 214 | appIt = mAppCats.find( appname ); |
245 | 215 | ||
246 | if ( appIt == mAppCats.end() ) { | 216 | if ( appIt == mAppCats.end() ) { |
247 | CategoryGroup newgroup; | 217 | CategoryGroup newgroup; |
248 | int uid = newgroup.add( catname ); | 218 | int uid = newgroup.add( catname ); |
249 | mAppCats.insert( appname, newgroup ); | 219 | mAppCats.insert( appname, newgroup ); |
250 | emit categoryAdded( *this, appname, uid ); | 220 | emit categoryAdded( *this, appname, uid ); |
251 | return uid; | 221 | return uid; |
252 | } | 222 | } |
253 | 223 | ||
254 | CategoryGroup &cats = *appIt; | 224 | CategoryGroup &cats = *appIt; |
255 | int uid = cats.add( catname ); | 225 | int uid = cats.add( catname ); |
256 | if ( !uid ) | 226 | if ( !uid ) |
257 | return 0; | 227 | return 0; |
258 | emit categoryAdded( *this, appname, uid ); | 228 | emit categoryAdded( *this, appname, uid ); |
259 | return uid; | 229 | return uid; |
260 | } | 230 | } |
261 | 231 | ||
262 | int Categories::addGlobalCategory( const QString &catname, int uid ) | 232 | int Categories::addGlobalCategory( const QString &catname, int uid ) |
263 | { | 233 | { |
264 | mGlobalCats.add( uid, catname ); | 234 | mGlobalCats.add( uid, catname ); |
265 | emit categoryAdded( *this, QString::null, uid ); | 235 | emit categoryAdded( *this, QString::null, uid ); |
266 | return uid; | 236 | return uid; |
267 | } | 237 | } |
@@ -282,363 +252,369 @@ int Categories::addGlobalCategory( const QString &catname ) | |||
282 | bool Categories::removeCategory( const QString &appname, | 252 | bool Categories::removeCategory( const QString &appname, |
283 | const QString &catname, | 253 | const QString &catname, |
284 | bool checkGlobal ) | 254 | bool checkGlobal ) |
285 | { | 255 | { |
286 | QMap< QString, CategoryGroup >::Iterator | 256 | QMap< QString, CategoryGroup >::Iterator |
287 | appIt = mAppCats.find( appname ); | 257 | appIt = mAppCats.find( appname ); |
288 | if ( appIt != mAppCats.end() ) { | 258 | if ( appIt != mAppCats.end() ) { |
289 | CategoryGroup &cats = *appIt; | 259 | CategoryGroup &cats = *appIt; |
290 | int uid = cats.id( catname ); | 260 | int uid = cats.id( catname ); |
291 | if ( cats.remove( uid ) ) { | 261 | if ( cats.remove( uid ) ) { |
292 | emit categoryRemoved( *this, appname, uid ); | 262 | emit categoryRemoved( *this, appname, uid ); |
293 | return TRUE; | 263 | return TRUE; |
294 | } | 264 | } |
295 | } | 265 | } |
296 | if ( !checkGlobal ) | 266 | if ( !checkGlobal ) |
297 | return FALSE; | 267 | return FALSE; |
298 | return removeGlobalCategory( catname ); | 268 | return removeGlobalCategory( catname ); |
299 | } | 269 | } |
300 | 270 | ||
301 | bool Categories::removeCategory( const QString &appname, int uid ) | 271 | bool Categories::removeCategory( const QString &appname, int uid ) |
302 | { | 272 | { |
303 | QMap< QString, CategoryGroup >::Iterator | 273 | QMap< QString, CategoryGroup >::Iterator |
304 | appIt = mAppCats.find( appname ); | 274 | appIt = mAppCats.find( appname ); |
305 | if ( appIt != mAppCats.end() ) { | 275 | if ( appIt != mAppCats.end() ) { |
306 | CategoryGroup &cats = *appIt; | 276 | CategoryGroup &cats = *appIt; |
307 | if ( cats.remove( uid ) ) { | 277 | if ( cats.remove( uid ) ) { |
308 | emit categoryRemoved( *this, appname, uid ); | 278 | emit categoryRemoved( *this, appname, uid ); |
309 | return TRUE; | 279 | return TRUE; |
310 | } | 280 | } |
311 | } | 281 | } |
312 | return FALSE; | 282 | return FALSE; |
313 | } | 283 | } |
314 | 284 | ||
315 | bool Categories::removeGlobalCategory( const QString &catname ) | 285 | bool Categories::removeGlobalCategory( const QString &catname ) |
316 | { | 286 | { |
317 | int uid = mGlobalCats.id( catname ); | 287 | int uid = mGlobalCats.id( catname ); |
318 | if ( mGlobalCats.remove( uid ) ) { | 288 | if ( mGlobalCats.remove( uid ) ) { |
319 | emit categoryRemoved( *this, QString::null, uid ); | 289 | emit categoryRemoved( *this, QString::null, uid ); |
320 | return TRUE; | 290 | return TRUE; |
321 | } | 291 | } |
322 | return FALSE; | 292 | return FALSE; |
323 | } | 293 | } |
324 | 294 | ||
325 | 295 | ||
326 | bool Categories::removeGlobalCategory( int uid ) | 296 | bool Categories::removeGlobalCategory( int uid ) |
327 | { | 297 | { |
328 | if ( mGlobalCats.remove( uid ) ) { | 298 | if ( mGlobalCats.remove( uid ) ) { |
329 | emit categoryRemoved( *this, QString::null, uid ); | 299 | emit categoryRemoved( *this, QString::null, uid ); |
330 | return TRUE; | 300 | return TRUE; |
331 | } | 301 | } |
332 | return FALSE; | 302 | return FALSE; |
333 | } | 303 | } |
334 | 304 | ||
335 | /** Returns the sorted list of all categories that are associated with | 305 | /** Returns the sorted list of all categories that are associated with |
336 | * the app. If includeGlobal parameter is TRUE then the returned | 306 | * the app. If includeGlobal parameter is TRUE then the returned |
337 | * categories will include the global category items. | 307 | * categories will include the global category items. |
338 | */ | 308 | */ |
339 | QStringList Categories::labels( const QString &app, | 309 | QStringList Categories::labels( const QString &app, |
340 | bool includeGlobal, | 310 | bool includeGlobal, |
341 | ExtraLabels extra ) const | 311 | ExtraLabels extra ) const |
342 | { | 312 | { |
343 | QMap< QString, CategoryGroup >::ConstIterator | 313 | QMap< QString, CategoryGroup >::ConstIterator |
344 | appIt = mAppCats.find( app ); | 314 | appIt = mAppCats.find( app ); |
345 | QStringList cats; | 315 | QStringList cats; |
316 | |||
317 | if ( appIt != mAppCats.end() ) | ||
318 | cats += (*appIt).labels(); | ||
319 | else qDebug("Categories::labels didn't find app %s", app.latin1() ); | ||
320 | if ( includeGlobal ) | ||
321 | cats += mGlobalCats.labels(); | ||
322 | |||
323 | cats.sort(); | ||
346 | switch ( extra ) { | 324 | switch ( extra ) { |
347 | case NoExtra: break; | 325 | case NoExtra: break; |
348 | case AllUnfiled: | 326 | case AllUnfiled: |
349 | cats.append( tr("All") ); | 327 | cats.append( tr("All") ); |
350 | cats.append( tr("Unfiled") ); | 328 | cats.append( tr("Unfiled") ); |
351 | break; | 329 | break; |
352 | case AllLabel: | 330 | case AllLabel: |
353 | cats.append( tr("All") ); | 331 | cats.append( tr("All") ); |
354 | break; | 332 | break; |
355 | case UnfiledLabel: | 333 | case UnfiledLabel: |
356 | cats.append( tr("Unfiled") ); | 334 | cats.append( tr("Unfiled") ); |
357 | break; | 335 | break; |
358 | } | 336 | } |
359 | if ( appIt != mAppCats.end() ) | 337 | |
360 | cats += (*appIt).labels(); | ||
361 | else qDebug("Categories::labels didn't find app %s", app.latin1() ); | ||
362 | if ( includeGlobal ) | ||
363 | cats += mGlobalCats.labels(); | ||
364 | // I don't think a sorted list is useful, the user might find prefer | ||
365 | // it in the original order. | ||
366 | // cats.sort(); | ||
367 | return cats; | 338 | return cats; |
368 | } | 339 | } |
369 | 340 | ||
370 | QString Categories::label( const QString &app, int id ) const | 341 | QString Categories::label( const QString &app, int id ) const |
371 | { | 342 | { |
372 | if ( mGlobalCats.contains( id ) ) | 343 | if ( mGlobalCats.contains( id ) ) |
373 | return mGlobalCats.label( id ); | 344 | return mGlobalCats.label( id ); |
374 | QMap< QString, CategoryGroup >::ConstIterator | 345 | QMap< QString, CategoryGroup >::ConstIterator |
375 | appIt = mAppCats.find( app ); | 346 | appIt = mAppCats.find( app ); |
376 | if ( appIt == mAppCats.end() ) | 347 | if ( appIt == mAppCats.end() ) |
377 | return QString::null; | 348 | return QString::null; |
378 | return (*appIt).label( id ); | 349 | return (*appIt).label( id ); |
379 | } | 350 | } |
380 | 351 | ||
381 | QStringList Categories::labels( const QString & app, | ||
382 | const QArray<int> &catids ) const | ||
383 | { | ||
384 | QStringList strs = mGlobalCats.labels( catids ); | ||
385 | strs += mAppCats[app].labels( catids ); | ||
386 | return strs; | ||
387 | } | ||
388 | |||
389 | /** Returns a single string associated with the cat ids for display in | 352 | /** Returns a single string associated with the cat ids for display in |
390 | * a combobox or any area that requires one string. If catids are empty | 353 | * a combobox or any area that requires one string. If catids are empty |
391 | * then "Unfiled" will be returned. If multiple categories are assigned | 354 | * then "Unfiled" will be returned. If multiple categories are assigned |
392 | * the first cat id is shown with " (multi)" appended to the string. | 355 | * the first cat id is shown with " (multi)" appended to the string. |
393 | */ | 356 | */ |
394 | QString Categories::displaySingle( const QString &app, | 357 | QString Categories::displaySingle( const QString &app, |
395 | const QArray<int> &catids, | 358 | const QArray<int> &catids, |
396 | DisplaySingle display ) const | 359 | DisplaySingle display ) const |
397 | { | 360 | { |
398 | QStringList strs = labels( app, catids ); | 361 | QStringList strs = labels( app, catids ); |
399 | if ( !strs.count() ) | 362 | if ( !strs.count() ) |
400 | return tr("Unfiled"); | 363 | return tr("Unfiled"); |
401 | strs.sort(); | 364 | strs.sort(); |
402 | QString r; | 365 | QString r; |
403 | if ( strs.count() > 1 ) { | 366 | if ( strs.count() > 1 ) { |
404 | switch ( display ) { | 367 | switch ( display ) { |
405 | case ShowFirst: | 368 | case ShowFirst: |
406 | r = strs.first(); | 369 | r = strs.first(); |
407 | break; | 370 | break; |
408 | case ShowMulti: | 371 | case ShowMulti: |
409 | r = strs.first() + tr(" (multi.)"); | 372 | r = strs.first() + tr(" (multi.)"); |
410 | break; | 373 | break; |
411 | case ShowAll: | 374 | case ShowAll: |
412 | r = strs.join(" "); | 375 | r = strs.join(" "); |
413 | break; | 376 | break; |
414 | } | 377 | } |
415 | } | 378 | } |
416 | else r = strs.first(); | 379 | else r = strs.first(); |
417 | return r; | 380 | return r; |
418 | } | 381 | } |
419 | 382 | ||
420 | QArray<int> Categories::ids( const QString &app ) const | 383 | QArray<int> Categories::ids( const QString &app, const QStringList &labels) const |
421 | { | ||
422 | QArray<int> allIds = mGlobalCats.ids(); | ||
423 | QArray<int> appIds = mAppCats[app].ids(); | ||
424 | |||
425 | // we should make the guarentee that the ids are in the | ||
426 | // same order as the labels, (i.e. app cats then global) | ||
427 | // otherwise there is no point in having these two separate functions. | ||
428 | uint appSize = appIds.size(); | ||
429 | appIds.resize( appSize + allIds.size() ); | ||
430 | for ( uint i = appSize; i < appIds.size(); ++i ) | ||
431 | appIds[int(i)] = allIds[int(i - appSize)]; | ||
432 | |||
433 | return appIds; | ||
434 | } | ||
435 | |||
436 | QArray<int> Categories::ids( const QString &app, const QStringList &cats ) const | ||
437 | { | 384 | { |
438 | QArray<int> allIds = mGlobalCats.ids( cats ); | 385 | QArray<int> results; |
439 | QArray<int> appIds = mAppCats[app].ids( cats ); | 386 | QStringList::ConstIterator it; |
440 | 387 | int i; | |
441 | uint appSize = appIds.size(); | 388 | |
442 | appIds.resize( appSize + allIds.size() ); | 389 | for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) { |
443 | for ( uint i = appSize; i < appIds.size(); ++i ) | 390 | int value = id( app, *it ); |
444 | appIds[int(i)] = allIds[int(i - appSize)]; | 391 | if ( value != 0 ) { |
445 | 392 | int tmp = results.size(); | |
446 | return appIds; | 393 | results.resize( tmp + 1 ); |
394 | results[ tmp ] = value; | ||
395 | } | ||
396 | } | ||
397 | return results; | ||
447 | } | 398 | } |
448 | 399 | ||
449 | int Categories::id( const QString &app, const QString &cat ) const | 400 | int Categories::id( const QString &app, const QString &cat ) const |
450 | { | 401 | { |
451 | if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) | 402 | if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) |
452 | return 0; | 403 | return 0; |
453 | int uid = mGlobalCats.id( cat ); | 404 | int uid = mGlobalCats.id( cat ); |
454 | if ( uid != 0 ) | 405 | if ( uid != 0 ) |
455 | return uid; | 406 | return uid; |
456 | return mAppCats[app].id( cat ); | 407 | return mAppCats[app].id( cat ); |
457 | } | 408 | } |
458 | 409 | ||
459 | 410 | ||
460 | /** Return TRUE if renaming succeeded; FALSE if app name not found, | 411 | /** Return TRUE if renaming succeeded; FALSE if app name not found, |
461 | * or if there was a name conflict | 412 | * or if there was a name conflict |
462 | */ | 413 | */ |
463 | bool Categories::renameCategory( const QString &appname, | 414 | bool Categories::renameCategory( const QString &appname, |
464 | const QString &oldName, | 415 | const QString &oldName, |
465 | const QString &newName ) | 416 | const QString &newName ) |
466 | { | 417 | { |
467 | QMap< QString, CategoryGroup >::Iterator | 418 | QMap< QString, CategoryGroup >::Iterator |
468 | appIt = mAppCats.find( appname ); | 419 | appIt = mAppCats.find( appname ); |
469 | 420 | ||
470 | if ( appIt != mAppCats.end() ) { | 421 | if ( appIt != mAppCats.end() ) { |
471 | CategoryGroup &cats = *appIt; | 422 | CategoryGroup &cats = *appIt; |
472 | int id = cats.id( oldName ); | 423 | int id = cats.id( oldName ); |
473 | if ( id != 0 && cats.rename( id, newName ) ) { | 424 | if ( id != 0 && cats.rename( id, newName ) ) { |
474 | emit categoryRenamed( *this, appname, id ); | 425 | emit categoryRenamed( *this, appname, id ); |
475 | return TRUE; | 426 | return TRUE; |
476 | } | 427 | } |
477 | } | 428 | } |
478 | return renameGlobalCategory( oldName, newName ); | 429 | return renameGlobalCategory( oldName, newName ); |
479 | } | 430 | } |
480 | 431 | ||
481 | bool Categories::renameGlobalCategory( const QString &oldName, | 432 | bool Categories::renameGlobalCategory( const QString &oldName, |
482 | const QString &newName ) | 433 | const QString &newName ) |
483 | { | 434 | { |
484 | int uid = mGlobalCats.id( oldName ); | 435 | int uid = mGlobalCats.id( oldName ); |
485 | if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) { | 436 | if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) { |
486 | emit categoryRenamed( *this, QString::null, uid ); | 437 | emit categoryRenamed( *this, QString::null, uid ); |
487 | return TRUE; | 438 | return TRUE; |
488 | } | 439 | } |
489 | return FALSE; | 440 | return FALSE; |
490 | } | 441 | } |
491 | 442 | ||
492 | void Categories::setGlobal( const QString &appname, | 443 | void Categories::setGlobal( const QString &appname, |
493 | const QString &catname, | 444 | const QString &catname, |
494 | bool global ) | 445 | bool global ) |
495 | { | 446 | { |
496 | // if in global and should be in app; then move it | 447 | // if in global and should be in app; then move it |
497 | if ( mGlobalCats.contains( catname ) && !global ) { | 448 | if ( mGlobalCats.contains( catname ) && !global ) { |
498 | mGlobalCats.remove( catname ); | 449 | mGlobalCats.remove( catname ); |
499 | addCategory( appname, catname ); | 450 | addCategory( appname, catname ); |
500 | return ; | 451 | return ; |
501 | } | 452 | } |
502 | 453 | ||
503 | // if in app and should be in global, then move it | 454 | // if in app and should be in global, then move it |
504 | if ( !global ) | 455 | if ( !global ) |
505 | return; | 456 | return; |
506 | if ( removeCategory( appname, catname, FALSE ) ) | 457 | if ( removeCategory( appname, catname, FALSE ) ) |
507 | addGlobalCategory( catname ); | 458 | addGlobalCategory( catname ); |
508 | } | 459 | } |
509 | 460 | ||
510 | bool Categories::isGlobal( const QString &catname ) const | 461 | bool Categories::isGlobal( const QString &catname ) const |
511 | { | 462 | { |
512 | return mGlobalCats.contains( catname ); | 463 | return mGlobalCats.contains( catname ); |
513 | } | 464 | } |
514 | 465 | ||
515 | 466 | ||
516 | /** Returns true if the catname is associated with any application | 467 | /** Returns true if the catname is associated with any application |
517 | */ | 468 | */ |
518 | bool Categories::exists( const QString &catname ) const | 469 | bool Categories::exists( const QString &catname ) const |
519 | { | 470 | { |
520 | if ( isGlobal(catname) ) | 471 | if ( isGlobal(catname) ) |
521 | return TRUE; | 472 | return TRUE; |
522 | 473 | ||
523 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) | 474 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) |
524 | if ( exists( appsIt.key(), catname ) ) | 475 | if ( exists( appsIt.key(), catname ) ) |
525 | return TRUE; | 476 | return TRUE; |
526 | 477 | ||
527 | return FALSE; | 478 | return FALSE; |
528 | } | 479 | } |
529 | 480 | ||
530 | bool Categories::exists( const QString &appname, | 481 | bool Categories::exists( const QString &appname, |
531 | const QString &catname) const | 482 | const QString &catname) const |
532 | { | 483 | { |
533 | QMap< QString, CategoryGroup >::ConstIterator | 484 | QMap< QString, CategoryGroup >::ConstIterator |
534 | appIt = mAppCats.find( appname ); | 485 | appIt = mAppCats.find( appname ); |
535 | 486 | ||
536 | if ( appIt == mAppCats.end() ) | 487 | if ( appIt == mAppCats.end() ) |
537 | return FALSE; | 488 | return FALSE; |
538 | 489 | ||
539 | return (*appIt).contains( catname ); | 490 | return (*appIt).contains( catname ); |
540 | } | 491 | } |
541 | 492 | ||
493 | |||
542 | bool Categories::save( const QString &fname ) const | 494 | bool Categories::save( const QString &fname ) const |
543 | { | 495 | { |
544 | QFile file( fname ); | 496 | QString strNewFile = fname + ".new"; |
545 | if ( !file.open( IO_WriteOnly ) ) { | 497 | QFile f( strNewFile ); |
498 | QString out; | ||
499 | int total_written; | ||
500 | |||
501 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) { | ||
546 | qWarning("Unable to write to %s", fname.latin1()); | 502 | qWarning("Unable to write to %s", fname.latin1()); |
547 | return FALSE; | 503 | return FALSE; |
548 | } | 504 | } |
549 | 505 | ||
550 | QTextStream ts( &file ); | 506 | out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
551 | ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | 507 | out += "<!DOCTYPE CategoryList>\n"; |
552 | ts << "<!DOCTYPE CategoryList>" << endl; | 508 | |
509 | out += "<Categories>\n"; | ||
553 | 510 | ||
554 | ts << "<Categories>" << endl; | ||
555 | for ( QMap<int, QString>::ConstIterator git = mGlobalCats.idMap().begin(); | 511 | for ( QMap<int, QString>::ConstIterator git = mGlobalCats.idMap().begin(); |
556 | git != mGlobalCats.idMap().end(); ++git ) | 512 | git != mGlobalCats.idMap().end(); ++git ) |
557 | ts << "<Category id=\"" << git.key() << "\"" | 513 | out += "<Category id=\"" + QString::number(git.key()) + "\"" + |
558 | << " name=\"" << escapeString(*git) << "\" />" << endl; | 514 | " name=\"" + escapeString(*git) + "\" />\n"; |
559 | 515 | ||
560 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt=mAppCats.begin(); | 516 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt=mAppCats.begin(); |
561 | appsIt != mAppCats.end(); ++appsIt ) { | 517 | appsIt != mAppCats.end(); ++appsIt ) { |
562 | const QString &app = appsIt.key(); | 518 | const QString &app = appsIt.key(); |
563 | const QMap<int, QString> &appcats = (*appsIt).idMap(); | 519 | const QMap<int, QString> &appcats = (*appsIt).idMap(); |
564 | for ( QMap<int, QString>::ConstIterator appcatit = appcats.begin(); | 520 | for ( QMap<int, QString>::ConstIterator appcatit = appcats.begin(); |
565 | appcatit != appcats.end(); ++appcatit ) | 521 | appcatit != appcats.end(); ++appcatit ) |
566 | ts << "<Category id=\"" << appcatit.key() << "\"" | 522 | out += "<Category id=\"" + QString::number(appcatit.key()) + "\"" + |
567 | << " app=\"" << escapeString(app) << "\"" | 523 | " app=\"" + escapeString(app) + "\"" + |
568 | << " name=\"" << escapeString(*appcatit) << "\" />" << endl; | 524 | " name=\"" + escapeString(*appcatit) + "\" />\n"; |
525 | } | ||
526 | out += "</Categories>\n"; | ||
527 | |||
528 | QCString cstr = out.utf8(); | ||
529 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | ||
530 | if ( total_written != int(cstr.length()) ) { | ||
531 | f.close(); | ||
532 | QFile::remove( strNewFile ); | ||
533 | return FALSE; | ||
534 | } | ||
535 | f.close(); | ||
536 | |||
537 | if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) { | ||
538 | qWarning( "problem renaming file %s to %s", | ||
539 | strNewFile.latin1(), fname.latin1()); | ||
540 | // remove the tmp file... | ||
541 | QFile::remove( strNewFile ); | ||
569 | } | 542 | } |
570 | ts << "</Categories>" << endl; | ||
571 | 543 | ||
572 | file.close(); | ||
573 | return TRUE; | 544 | return TRUE; |
574 | } | 545 | } |
575 | 546 | ||
576 | bool Categories::load( const QString &fname ) | 547 | bool Categories::load( const QString &fname ) |
577 | { | 548 | { |
578 | QFile file( fname ); | 549 | QFile file( fname ); |
579 | if ( !file.open( IO_ReadOnly ) ) { | 550 | if ( !file.open( IO_ReadOnly ) ) { |
580 | qWarning("Unable to open %s", fname.latin1()); | 551 | qWarning("Unable to open %s", fname.latin1()); |
552 | |||
553 | addGlobalCategory(tr("Business")); | ||
554 | addGlobalCategory(tr("Personal")); | ||
555 | save(fname); | ||
556 | |||
581 | return FALSE; | 557 | return FALSE; |
582 | } | 558 | } |
583 | 559 | ||
584 | clear(); | 560 | clear(); |
585 | QByteArray ba = file.readAll(); | 561 | QByteArray ba = file.readAll(); |
586 | QString data = QString::fromUtf8( ba.data(), ba.size() ); | 562 | QString data = QString::fromUtf8( ba.data(), ba.size() ); |
587 | QChar *uc = (QChar *)data.unicode(); | 563 | QChar *uc = (QChar *)data.unicode(); |
588 | int len = data.length(); | 564 | int len = data.length(); |
589 | 565 | ||
590 | // QTime t; | 566 | // QTime t; |
591 | // t.start(); | 567 | // t.start(); |
592 | QString name; | 568 | QString name; |
593 | QString id; | 569 | QString id; |
594 | QString app; | 570 | QString app; |
595 | int i = 0; | 571 | int i = 0; |
596 | while ( (i = data.find( "<Category ", i)) != -1 ) { | 572 | while ( (i = data.find( "<Category ", i)) != -1 ) { |
597 | 573 | ||
598 | i += 10; | 574 | i += 10; |
599 | name = QString::null; | 575 | name = QString::null; |
600 | app = QString::null; | 576 | app = QString::null; |
601 | while ( 1 ) { | 577 | while ( 1 ) { |
602 | // skip white space | 578 | // skip white space |
603 | while ( i < len && | 579 | while ( i < len && |
604 | (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') ) | 580 | (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') ) |
605 | i++; | 581 | i++; |
606 | // if at the end, then done | 582 | // if at the end, then done |
607 | if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') ) | 583 | if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') ) |
608 | break; | 584 | break; |
609 | // we have another attribute read it. | 585 | // we have another attribute read it. |
610 | int j = i; | 586 | int j = i; |
611 | while ( j < len && uc[j] != '=' ) | 587 | while ( j < len && uc[j] != '=' ) |
612 | j++; | 588 | j++; |
613 | QString attr = QConstString( uc+i, j-i ).string(); | 589 | QString attr = QConstString( uc+i, j-i ).string(); |
614 | i = ++j; // skip = | 590 | i = ++j; // skip = |
615 | while ( i < len && uc[i] != '"' ) | 591 | while ( i < len && uc[i] != '"' ) |
616 | i++; | 592 | i++; |
617 | j = ++i; | 593 | j = ++i; |
618 | while ( j < len && uc[j] != '"' ) | 594 | while ( j < len && uc[j] != '"' ) |
619 | j++; | 595 | j++; |
620 | QString value = Qtopia::plainString( QConstString( uc+i, j-i ).string() ); | 596 | QString value = Qtopia::plainString( QConstString( uc+i, j-i ).string() ); |
621 | i = j + 1; | 597 | i = j + 1; |
622 | 598 | ||
623 | // qDebug("attr='%s' value='%s'", attr.latin1(), value.latin1() ); | 599 | // qDebug("attr='%s' value='%s'", attr.latin1(), value.latin1() ); |
624 | if ( attr == "id" ) | 600 | if ( attr == "id" ) |
625 | id = value; | 601 | id = value; |
626 | else if ( attr == "app" ) | 602 | else if ( attr == "app" ) |
627 | app = value; | 603 | app = value; |
628 | 604 | ||
629 | else if ( attr == "name" ) | 605 | else if ( attr == "name" ) |
630 | name = value; | 606 | name = value; |
631 | } | 607 | } |
632 | 608 | ||
633 | if ( name.isNull() || id.isNull() ) { | 609 | if ( name.isNull() || id.isNull() ) { |
634 | qWarning("No name or id in the category"); | 610 | qWarning("No name or id in the category"); |
635 | continue; | 611 | continue; |
636 | } | 612 | } |
637 | if ( app.isNull() ) | 613 | if ( app.isNull() ) |
638 | mGlobalCats.add( id.toInt(), name ); | 614 | mGlobalCats.add( id.toInt(), name ); |
639 | else | 615 | else |
640 | mAppCats[ app ].add( id.toInt(), name ); | 616 | mAppCats[ app ].add( id.toInt(), name ); |
641 | } | 617 | } |
642 | 618 | ||
643 | return TRUE; | 619 | return TRUE; |
644 | } | 620 | } |
diff --git a/library/backend/categories.h b/library/backend/categories.h index 82d765b..ba65ee3 100644 --- a/library/backend/categories.h +++ b/library/backend/categories.h | |||
@@ -10,214 +10,208 @@ | |||
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING |
12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A | 12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A |
13 | ** PARTICULAR PURPOSE. | 13 | ** PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef QTPALMTOP_CATEGORIES_H | 22 | #ifndef QTPALMTOP_CATEGORIES_H |
23 | #define QTPALMTOP_CATEGORIES_H | 23 | #define QTPALMTOP_CATEGORIES_H |
24 | 24 | ||
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <qarray.h> | 29 | #include <qarray.h> |
30 | #include "qpcglobal.h" | 30 | #include "qpcglobal.h" |
31 | #include "palmtopuidgen.h" | 31 | #include "palmtopuidgen.h" |
32 | 32 | ||
33 | class CategoryGroup; | 33 | class CategoryGroup; |
34 | 34 | ||
35 | #if defined(QPC_TEMPLATEDLL) | 35 | #if defined(QPC_TEMPLATEDLL) |
36 | // MOC_SKIP_BEGIN | 36 | // MOC_SKIP_BEGIN |
37 | template class QPC_EXPORT QMap<int, QString>; | 37 | template class QPC_EXPORT QMap<int, QString>; |
38 | template class QPC_EXPORT QMap<QString, int>; | 38 | template class QPC_EXPORT QMap<QString, int>; |
39 | template class QPC_EXPORT QMap< QString, CategoryGroup >; | 39 | template class QPC_EXPORT QMap< QString, CategoryGroup >; |
40 | // MOC_SKIP_END | 40 | // MOC_SKIP_END |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | class QPC_EXPORT CategoryGroup | 43 | class QPC_EXPORT CategoryGroup |
44 | { | 44 | { |
45 | friend class Categories; | 45 | friend class Categories; |
46 | public: | 46 | public: |
47 | CategoryGroup(): mIdLabelMap(), mLabelIdMap() { } | 47 | CategoryGroup(): mIdLabelMap(), mLabelIdMap() { } |
48 | CategoryGroup( const CategoryGroup &c ) : | 48 | CategoryGroup( const CategoryGroup &c ) : |
49 | mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { } | 49 | mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { } |
50 | 50 | ||
51 | void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); } | 51 | void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); } |
52 | 52 | ||
53 | int add( const QString &label ); | 53 | int add( const QString &label ); |
54 | bool add( int uid, const QString &label ); | 54 | bool add( int uid, const QString &label ); |
55 | 55 | ||
56 | bool remove( const QString &label ); | 56 | bool remove( const QString &label ); |
57 | bool remove( int uid ); | 57 | bool remove( int uid ); |
58 | 58 | ||
59 | bool rename( int uid, const QString &newLabel ); | 59 | bool rename( int uid, const QString &newLabel ); |
60 | bool rename( const QString &oldLabel, const QString &newLabel ); | 60 | bool rename( const QString &oldLabel, const QString &newLabel ); |
61 | 61 | ||
62 | bool contains(int id) const; | 62 | bool contains(int id) const; |
63 | bool contains(const QString &label) const; | 63 | bool contains(const QString &label) const; |
64 | 64 | ||
65 | /** Returns label associated with the uid or QString::null if | 65 | /** Returns label associated with the uid or QString::null if |
66 | * not found | 66 | * not found |
67 | */ | 67 | */ |
68 | const QString &label(int id) const; | 68 | const QString &label(int id) const; |
69 | /** Returns the uid associated with label or 0 if not found */ | 69 | /** Returns the uid associated with label or 0 if not found */ |
70 | int id(const QString &label) const; | 70 | int id(const QString &label) const; |
71 | 71 | ||
72 | /** Returns a sorted list of labels */ | 72 | /** Returns a sorted list of labels */ |
73 | QStringList labels() const; | 73 | QStringList labels() const; |
74 | QArray<int> ids( const QStringList &cats ) const; | 74 | |
75 | QArray<int> ids() const; | ||
76 | QStringList labels( const QArray<int> &catids ) const; | 75 | QStringList labels( const QArray<int> &catids ) const; |
77 | 76 | ||
78 | const QMap<int, QString> &idMap() const { return mIdLabelMap; } | 77 | const QMap<int, QString> &idMap() const { return mIdLabelMap; } |
79 | 78 | ||
80 | private: | 79 | private: |
81 | void insert( int uid, const QString &label ); | 80 | void insert( int uid, const QString &label ); |
82 | QMap<int, QString> mIdLabelMap; | 81 | QMap<int, QString> mIdLabelMap; |
83 | QMap<QString, int> mLabelIdMap; | 82 | QMap<QString, int> mLabelIdMap; |
84 | 83 | ||
85 | static Qtopia::UidGen &uidGen() { return sUidGen; } | 84 | static Qtopia::UidGen &uidGen() { return sUidGen; } |
86 | static Qtopia::UidGen sUidGen; | 85 | static Qtopia::UidGen sUidGen; |
87 | }; | 86 | }; |
88 | 87 | ||
89 | /** Map from application name to categories */ | 88 | /** Map from application name to categories */ |
90 | class QPC_EXPORT Categories : public QObject | 89 | class QPC_EXPORT Categories : public QObject |
91 | { | 90 | { |
92 | Q_OBJECT | 91 | Q_OBJECT |
93 | public: | 92 | public: |
94 | Categories( QObject *parent=0, const char *name = 0 ) | 93 | Categories( QObject *parent=0, const char *name = 0 ) |
95 | : QObject( parent, name ), mGlobalCats(), mAppCats() { } | 94 | : QObject( parent, name ), mGlobalCats(), mAppCats() { } |
96 | Categories( const Categories ©From ) : QObject( copyFrom.parent() ), | 95 | Categories( const Categories ©From ) : QObject( copyFrom.parent() ), |
97 | mGlobalCats( copyFrom.mGlobalCats ), | 96 | mGlobalCats( copyFrom.mGlobalCats ), |
98 | mAppCats( copyFrom.mAppCats ) { } | 97 | mAppCats( copyFrom.mAppCats ) { } |
99 | virtual ~Categories() { } | 98 | virtual ~Categories() { } |
100 | 99 | ||
101 | Categories &operator= ( const Categories &c ) | 100 | Categories &operator= ( const Categories &c ) |
102 | { mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; } | 101 | { mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; } |
103 | 102 | ||
104 | void clear(); | 103 | void clear(); |
105 | 104 | ||
106 | /** Add the category name as long as it doesn't already exist | 105 | /** Add the category name as long as it doesn't already exist |
107 | * locally or globally. Return UID if added, 0 if conflicts | 106 | * locally or globally. Return UID if added, 0 if conflicts |
108 | * (error). | 107 | * (error). |
109 | */ | 108 | */ |
110 | int addCategory( const QString &appname, const QString &catname); | 109 | int addCategory( const QString &appname, const QString &catname); |
111 | /** Add the category name as long as it doesn't already exist | 110 | /** Add the category name as long as it doesn't already exist |
112 | * locally or globally. Return UID if added, 0 if conflicts | 111 | * locally or globally. Return UID if added, 0 if conflicts |
113 | * (error). | 112 | * (error). |
114 | */ | 113 | */ |
115 | int addCategory( const QString &appname, const QString &catname, int uid); | 114 | int addCategory( const QString &appname, const QString &catname, int uid); |
116 | /** Add the global category just checking that it doesn't | 115 | /** Add the global category just checking that it doesn't |
117 | * already exist globally. Return UID if added, 0 if conflicts. | 116 | * already exist globally. Return UID if added, 0 if conflicts. |
118 | */ | 117 | */ |
119 | int addGlobalCategory( const QString &catname ); | 118 | int addGlobalCategory( const QString &catname ); |
120 | /** Add the global category just checking that it doesn't | 119 | /** Add the global category just checking that it doesn't |
121 | * already exist globally. Return UID if added, 0 if conflicts. | 120 | * already exist globally. Return UID if added, 0 if conflicts. |
122 | */ | 121 | */ |
123 | int addGlobalCategory( const QString &catname, int uid ); | 122 | int addGlobalCategory( const QString &catname, int uid ); |
124 | /** Removes the category from the application; if it is not found | 123 | /** Removes the category from the application; if it is not found |
125 | * in the application, then it removes it from the global list | 124 | * in the application, then it removes it from the global list |
126 | */ | 125 | */ |
127 | bool removeCategory( const QString &appName, const QString &catName, | 126 | bool removeCategory( const QString &appName, const QString &catName, |
128 | bool checkGlobal = TRUE); | 127 | bool checkGlobal = TRUE); |
129 | bool removeCategory( const QString &appName, int uid ); | 128 | bool removeCategory( const QString &appName, int uid ); |
130 | bool removeGlobalCategory( const QString &catName ); | 129 | bool removeGlobalCategory( const QString &catName ); |
131 | bool removeGlobalCategory( int uid ); | 130 | bool removeGlobalCategory( int uid ); |
132 | 131 | ||
133 | QArray<int> ids( const QString &app ) const; | 132 | QArray<int> ids( const QString &app, const QStringList &labels) const; |
134 | QArray<int> ids( const QString &app, | 133 | |
135 | const QStringList &cats ) const; | ||
136 | /** Returns the id associated with the app */ | 134 | /** Returns the id associated with the app */ |
137 | int id( const QString &app, const QString &cat ) const; | 135 | int id( const QString &app, const QString &cat ) const; |
138 | /** Returns the label associated with the id */ | 136 | /** Returns the label associated with the id */ |
139 | QString label( const QString &app, int id ) const; | 137 | QString label( const QString &app, int id ) const; |
140 | 138 | ||
141 | enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel }; | 139 | enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel }; |
142 | /** Returns the sorted list of all categories that are | 140 | /** Returns the sorted list of all categories that are |
143 | * associated with the app. | 141 | * associated with the app. |
144 | * If includeGlobal parameter is TRUE then the returned | 142 | * If includeGlobal parameter is TRUE then the returned |
145 | * categories will include the global category items. | 143 | * categories will include the global category items. |
146 | * If extra = NoExtra, then | 144 | * If extra = NoExtra, then |
147 | * If extra = AllUnfiled, then All and Unfiled will be prepended to | 145 | * If extra = AllUnfiled, then All and Unfiled will be prepended to |
148 | * the list | 146 | * the list |
149 | * If extra = AllLabel, then All is prepended | 147 | * If extra = AllLabel, then All is prepended |
150 | * If extra = UnfiledLabel, then Unfiled is prepended | 148 | * If extra = UnfiledLabel, then Unfiled is prepended |
151 | */ | 149 | */ |
152 | QStringList labels( const QString &app, | 150 | QStringList labels( const QString &app, |
153 | bool includeGlobal = TRUE, | 151 | bool includeGlobal = TRUE, |
154 | ExtraLabels extra = NoExtra ) const; | 152 | ExtraLabels extra = NoExtra ) const; |
155 | 153 | ||
156 | /** Returns the labels of the categories associated with the uids */ | ||
157 | QStringList labels( const QString & app, | ||
158 | const QArray<int> &catids ) const; | ||
159 | |||
160 | enum DisplaySingle { ShowMulti, ShowAll, ShowFirst }; | 154 | enum DisplaySingle { ShowMulti, ShowAll, ShowFirst }; |
161 | 155 | ||
162 | /** Returns a single string associated with the cat ids for display in | 156 | /** Returns a single string associated with the cat ids for display in |
163 | * a combobox or any area that requires one string. If catids are empty | 157 | * a combobox or any area that requires one string. If catids are empty |
164 | * then "Unfiled" will be returned. If multiple categories are assigned | 158 | * then "Unfiled" will be returned. If multiple categories are assigned |
165 | * then the behavior depends on the DisplaySingle type. | 159 | * then the behavior depends on the DisplaySingle type. |
166 | * If /a display is set to ShowMulti then " (multi)" appended to the | 160 | * If /a display is set to ShowMulti then " (multi)" appended to the |
167 | * first string. If /a display is set to ShowAll, then a space seperated | 161 | * first string. If /a display is set to ShowAll, then a space seperated |
168 | * string is returned with all categories. If ShowFirst is returned, | 162 | * string is returned with all categories. If ShowFirst is returned, |
169 | * the just the first string is returned. | 163 | * the just the first string is returned. |
170 | */ | 164 | */ |
171 | QString displaySingle( const QString &app, | 165 | QString displaySingle( const QString &app, |
172 | const QArray<int> &catids, | 166 | const QArray<int> &catids, |
173 | DisplaySingle display ) const; | 167 | DisplaySingle display ) const; |
174 | 168 | ||
175 | QStringList globalCategories() const { return mGlobalCats.labels();} | 169 | QStringList globalCategories() const { return mGlobalCats.labels();} |
176 | 170 | ||
177 | bool renameCategory( const QString &appname, | 171 | bool renameCategory( const QString &appname, |
178 | const QString &oldName, | 172 | const QString &oldName, |
179 | const QString &newName ); | 173 | const QString &newName ); |
180 | bool renameGlobalCategory( const QString &oldName, | 174 | bool renameGlobalCategory( const QString &oldName, |
181 | const QString &newName ); | 175 | const QString &newName ); |
182 | 176 | ||
183 | void setGlobal( const QString &appname, const QString &catname, | 177 | void setGlobal( const QString &appname, const QString &catname, |
184 | bool value ); | 178 | bool value ); |
185 | bool isGlobal( const QString &catname ) const; | 179 | bool isGlobal( const QString &catname ) const; |
186 | 180 | ||
187 | 181 | ||
188 | /** Returns true if the catname is associated with any application | 182 | /** Returns true if the catname is associated with any application |
189 | */ | 183 | */ |
190 | bool exists( const QString &catname ) const; | 184 | bool exists( const QString &catname ) const; |
191 | bool exists( const QString &appname, const QString &catname) const; | 185 | bool exists( const QString &appname, const QString &catname) const; |
192 | 186 | ||
193 | bool save( const QString &fname ) const; | 187 | bool save( const QString &fname ) const; |
194 | bool load( const QString &fname ); | 188 | bool load( const QString &fname ); |
195 | 189 | ||
196 | // for debugging | 190 | // for debugging |
197 | void dump() const; | 191 | void dump() const; |
198 | 192 | ||
199 | const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; } | 193 | const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; } |
200 | const CategoryGroup &globalGroup() const { return mGlobalCats; } | 194 | const CategoryGroup &globalGroup() const { return mGlobalCats; } |
201 | 195 | ||
202 | signals: | 196 | signals: |
203 | /** emitted if added a category; | 197 | /** emitted if added a category; |
204 | * the second param is the application the category was added to | 198 | * the second param is the application the category was added to |
205 | * or null if global | 199 | * or null if global |
206 | * the third param is the uid of the newly added category | 200 | * the third param is the uid of the newly added category |
207 | */ | 201 | */ |
208 | void categoryAdded( const Categories &, const QString &, int ); | 202 | void categoryAdded( const Categories &, const QString &, int ); |
209 | /** emitted if removed a category | 203 | /** emitted if removed a category |
210 | * the second param is the application the category was removed from | 204 | * the second param is the application the category was removed from |
211 | * or null if global | 205 | * or null if global |
212 | * the third param is the uid of the removed category | 206 | * the third param is the uid of the removed category |
213 | */ | 207 | */ |
214 | void categoryRemoved( const Categories &, const QString &, int ); | 208 | void categoryRemoved( const Categories &, const QString &, int ); |
215 | /** emitted if a category is renamed; the second param is the uid of | 209 | /** emitted if a category is renamed; the second param is the uid of |
216 | * the removed category */ | 210 | * the removed category */ |
217 | void categoryRenamed( const Categories &, const QString &, int ); | 211 | void categoryRenamed( const Categories &, const QString &, int ); |
218 | 212 | ||
219 | private: | 213 | private: |
220 | CategoryGroup mGlobalCats; | 214 | CategoryGroup mGlobalCats; |
221 | QMap< QString, CategoryGroup > mAppCats; | 215 | QMap< QString, CategoryGroup > mAppCats; |
222 | }; | 216 | }; |
223 | 217 | ||
diff --git a/library/backend/contact.cpp b/library/backend/contact.cpp index a5f10ab..b10b19a 100644 --- a/library/backend/contact.cpp +++ b/library/backend/contact.cpp | |||
@@ -1,87 +1,89 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_CONTACT_MRE | ||
22 | |||
21 | #include "contact.h" | 23 | #include "contact.h" |
22 | #include "vobject_p.h" | 24 | #include "vobject_p.h" |
23 | #include "qfiledirect_p.h" | 25 | #include "qfiledirect_p.h" |
24 | 26 | ||
25 | #include <qpe/stringutil.h> | 27 | #include <qpe/stringutil.h> |
26 | #include <qpe/timeconversion.h> | 28 | #include <qpe/timeconversion.h> |
27 | 29 | ||
28 | #include <qobject.h> | 30 | #include <qobject.h> |
29 | #include <qregexp.h> | 31 | #include <qregexp.h> |
30 | #include <qstylesheet.h> | 32 | #include <qstylesheet.h> |
31 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
32 | 34 | ||
33 | #include <stdio.h> | 35 | #include <stdio.h> |
34 | 36 | ||
35 | Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); | 37 | Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); |
36 | 38 | ||
37 | Contact::Contact() | 39 | Contact::Contact() |
38 | : Record(), mMap(), d( 0 ) | 40 | : Record(), mMap(), d( 0 ) |
39 | { | 41 | { |
40 | } | 42 | } |
41 | 43 | ||
42 | Contact::Contact( const QMap<int, QString> &fromMap ) : | 44 | Contact::Contact( const QMap<int, QString> &fromMap ) : |
43 | Record(), mMap( fromMap ), d( 0 ) | 45 | Record(), mMap( fromMap ), d( 0 ) |
44 | { | 46 | { |
45 | QString cats = mMap[ Qtopia::AddressCategory ]; | 47 | QString cats = mMap[ Qtopia::AddressCategory ]; |
46 | if ( !cats.isEmpty() ) | 48 | if ( !cats.isEmpty() ) |
47 | setCategories( idsFromString( cats ) ); | 49 | setCategories( idsFromString( cats ) ); |
48 | QString uidStr = find( Qtopia::AddressUid ); | 50 | QString uidStr = find( Qtopia::AddressUid ); |
49 | if ( uidStr.isEmpty() ) | 51 | if ( uidStr.isEmpty() ) |
50 | setUid( uidGen().generate() ); | 52 | setUid( uidGen().generate() ); |
51 | else | 53 | else |
52 | setUid( uidStr.toInt() ); | 54 | setUid( uidStr.toInt() ); |
53 | } | 55 | } |
54 | 56 | ||
55 | Contact::~Contact() | 57 | Contact::~Contact() |
56 | { | 58 | { |
57 | } | 59 | } |
58 | 60 | ||
59 | QMap<int, QString> Contact::toMap() const | 61 | QMap<int, QString> Contact::toMap() const |
60 | { | 62 | { |
61 | QMap<int, QString> map = mMap; | 63 | QMap<int, QString> map = mMap; |
62 | map.insert( Qtopia::AddressCategory, idsToString( categories() )); | 64 | map.insert( Qtopia::AddressCategory, idsToString( categories() )); |
63 | return map; | 65 | return map; |
64 | } | 66 | } |
65 | 67 | ||
66 | /*! | 68 | /*! |
67 | Returns a rich text formatted QString of the Contact. | 69 | Returns a rich text formatted QString of the Contact. |
68 | */ | 70 | */ |
69 | QString Contact::toRichText() const | 71 | QString Contact::toRichText() const |
70 | { | 72 | { |
71 | QString text; | 73 | QString text; |
72 | QString value, comp, state; | 74 | QString value, comp, state; |
73 | 75 | ||
74 | // name, jobtitle and company | 76 | // name, jobtitle and company |
75 | if ( !(value = fullName()).isEmpty() ) | 77 | if ( !(value = fullName()).isEmpty() ) |
76 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; | 78 | text += "<b>" + Qtopia::escapeString(value) + "</b><br>"; |
77 | if ( !(value = jobTitle()).isEmpty() ) | 79 | if ( !(value = jobTitle()).isEmpty() ) |
78 | text += Qtopia::escapeString(value) + "<br>"; | 80 | text += Qtopia::escapeString(value) + "<br>"; |
79 | 81 | ||
80 | comp = company(); | 82 | comp = company(); |
81 | if ( !(value = department()).isEmpty() ) { | 83 | if ( !(value = department()).isEmpty() ) { |
82 | text += Qtopia::escapeString(value); | 84 | text += Qtopia::escapeString(value); |
83 | if ( comp ) | 85 | if ( comp ) |
84 | text += ", "; | 86 | text += ", "; |
85 | else | 87 | else |
86 | text += "<br>"; | 88 | text += "<br>"; |
87 | } | 89 | } |
@@ -325,221 +327,229 @@ QStringList Contact::childrenList() const | |||
325 | return QStringList::split( " ", find( Qtopia::Children ) ); | 327 | return QStringList::split( " ", find( Qtopia::Children ) ); |
326 | } | 328 | } |
327 | 329 | ||
328 | QStringList Contact::emailList() const | 330 | QStringList Contact::emailList() const |
329 | { | 331 | { |
330 | return QStringList::split( ";", find( Qtopia::Emails ) ); | 332 | return QStringList::split( ";", find( Qtopia::Emails ) ); |
331 | } | 333 | } |
332 | 334 | ||
333 | void Contact::setFileAs() | 335 | void Contact::setFileAs() |
334 | { | 336 | { |
335 | QString lastName, firstName, middleName, fileas; | 337 | QString lastName, firstName, middleName, fileas; |
336 | 338 | ||
337 | lastName = find( Qtopia::LastName ); | 339 | lastName = find( Qtopia::LastName ); |
338 | firstName = find( Qtopia::FirstName ); | 340 | firstName = find( Qtopia::FirstName ); |
339 | middleName = find( Qtopia::MiddleName ); | 341 | middleName = find( Qtopia::MiddleName ); |
340 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 342 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
341 | && !middleName.isEmpty() ) | 343 | && !middleName.isEmpty() ) |
342 | fileas = lastName + ", " + firstName + " " + middleName; | 344 | fileas = lastName + ", " + firstName + " " + middleName; |
343 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) | 345 | else if ( !lastName.isEmpty() && !firstName.isEmpty() ) |
344 | fileas = lastName + ", " + firstName; | 346 | fileas = lastName + ", " + firstName; |
345 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || | 347 | else if ( !lastName.isEmpty() || !firstName.isEmpty() || |
346 | !middleName.isEmpty() ) | 348 | !middleName.isEmpty() ) |
347 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 349 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
348 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 350 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
349 | + lastName; | 351 | + lastName; |
350 | 352 | ||
351 | replace( Qtopia::FileAs, fileas ); | 353 | replace( Qtopia::FileAs, fileas ); |
352 | } | 354 | } |
353 | 355 | ||
354 | void Contact::save( QString &buf ) const | 356 | void Contact::save( QString &buf ) const |
355 | { | 357 | { |
356 | static const QStringList SLFIELDS = fields(); | 358 | static const QStringList SLFIELDS = fields(); |
357 | // I'm expecting "<Contact " in front of this... | 359 | // I'm expecting "<Contact " in front of this... |
358 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 360 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
359 | it != mMap.end(); ++it ) { | 361 | it != mMap.end(); ++it ) { |
360 | const QString &value = it.data(); | 362 | const QString &value = it.data(); |
361 | int key = it.key(); | 363 | int key = it.key(); |
362 | if ( !value.isEmpty() ) { | 364 | if ( !value.isEmpty() ) { |
363 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) | 365 | if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) |
364 | continue; | 366 | continue; |
365 | 367 | ||
366 | key -= Qtopia::AddressCategory+1; | 368 | key -= Qtopia::AddressCategory+1; |
367 | buf += SLFIELDS[key]; | 369 | buf += SLFIELDS[key]; |
368 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; | 370 | buf += "=\"" + Qtopia::escapeString(value) + "\" "; |
369 | } | 371 | } |
370 | } | 372 | } |
371 | buf += customToXml(); | 373 | buf += customToXml(); |
372 | if ( categories().count() > 0 ) | 374 | if ( categories().count() > 0 ) |
373 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 375 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
374 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 376 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
375 | // You need to close this yourself | 377 | // You need to close this yourself |
376 | } | 378 | } |
377 | 379 | ||
378 | QStringList Contact::fields() | 380 | QStringList Contact::fields() |
379 | { | 381 | { |
380 | QStringList list; | 382 | QStringList list; |
381 | 383 | ||
382 | list.append( "Title" ); // Not Used! | 384 | list.append( "Title" ); // Not Used! |
383 | list.append( "FirstName" ); | 385 | list.append( "FirstName" ); |
384 | list.append( "MiddleName" ); | 386 | list.append( "MiddleName" ); |
385 | list.append( "LastName" ); | 387 | list.append( "LastName" ); |
386 | list.append( "Suffix" ); | 388 | list.append( "Suffix" ); |
387 | list.append( "FileAs" ); | 389 | list.append( "FileAs" ); |
388 | 390 | ||
391 | list.append( "JobTitle" ); | ||
392 | list.append( "Department" ); | ||
393 | list.append( "Company" ); | ||
394 | list.append( "BusinessPhone" ); | ||
395 | list.append( "BusinessFax" ); | ||
396 | list.append( "BusinessMobile" ); | ||
397 | |||
389 | list.append( "DefaultEmail" ); | 398 | list.append( "DefaultEmail" ); |
390 | list.append( "Emails" ); | 399 | list.append( "Emails" ); |
391 | 400 | ||
392 | list.append( "HomeStreet" ); | ||
393 | list.append( "HomeCity" ); | ||
394 | list.append( "HomeState" ); | ||
395 | list.append( "HomeZip" ); | ||
396 | list.append( "HomeCountry" ); | ||
397 | list.append( "HomePhone" ); | 401 | list.append( "HomePhone" ); |
398 | list.append( "HomeFax" ); | 402 | list.append( "HomeFax" ); |
399 | list.append( "HomeMobile" ); | 403 | list.append( "HomeMobile" ); |
400 | list.append( "HomeWebPage" ); | ||
401 | 404 | ||
402 | list.append( "Company" ); | ||
403 | list.append( "BusinessStreet" ); | 405 | list.append( "BusinessStreet" ); |
404 | list.append( "BusinessCity" ); | 406 | list.append( "BusinessCity" ); |
405 | list.append( "BusinessState" ); | 407 | list.append( "BusinessState" ); |
406 | list.append( "BusinessZip" ); | 408 | list.append( "BusinessZip" ); |
407 | list.append( "BusinessCountry" ); | 409 | list.append( "BusinessCountry" ); |
410 | list.append( "BusinessPager" ); | ||
408 | list.append( "BusinessWebPage" ); | 411 | list.append( "BusinessWebPage" ); |
409 | list.append( "JobTitle" ); | 412 | |
410 | list.append( "Department" ); | ||
411 | list.append( "Office" ); | 413 | list.append( "Office" ); |
412 | list.append( "BusinessPhone" ); | ||
413 | list.append( "BusinessFax" ); | ||
414 | list.append( "BusinessMobile" ); | ||
415 | list.append( "BusinessPager" ); | ||
416 | list.append( "Profession" ); | 414 | list.append( "Profession" ); |
417 | list.append( "Assistant" ); | 415 | list.append( "Assistant" ); |
418 | list.append( "Manager" ); | 416 | list.append( "Manager" ); |
419 | 417 | ||
418 | list.append( "HomeStreet" ); | ||
419 | list.append( "HomeCity" ); | ||
420 | list.append( "HomeState" ); | ||
421 | list.append( "HomeZip" ); | ||
422 | list.append( "HomeCountry" ); | ||
423 | list.append( "HomeWebPage" ); | ||
424 | |||
420 | list.append( "Spouse" ); | 425 | list.append( "Spouse" ); |
421 | list.append( "Gender" ); | 426 | list.append( "Gender" ); |
422 | list.append( "Birthday" ); | 427 | list.append( "Birthday" ); |
423 | list.append( "Anniversary" ); | 428 | list.append( "Anniversary" ); |
424 | list.append( "Nickname" ); | 429 | list.append( "Nickname" ); |
425 | |||
426 | list.append( "Children" ); | 430 | list.append( "Children" ); |
431 | |||
427 | list.append( "Notes" ); | 432 | list.append( "Notes" ); |
433 | list.append( "Groups" ); | ||
428 | 434 | ||
429 | return list; | 435 | return list; |
430 | } | 436 | } |
431 | 437 | ||
432 | QStringList Contact::trfields() | 438 | QStringList Contact::trfields() |
433 | { | 439 | { |
434 | QStringList list; | 440 | QStringList list; |
435 | 441 | ||
436 | list.append( QObject::tr( "Name Title") ); | 442 | list.append( QObject::tr( "Name Title") ); |
437 | list.append( QObject::tr( "First Name" ) ); | 443 | list.append( QObject::tr( "First Name" ) ); |
438 | list.append( QObject::tr( "Middle Name" ) ); | 444 | list.append( QObject::tr( "Middle Name" ) ); |
439 | list.append( QObject::tr( "Last Name" ) ); | 445 | list.append( QObject::tr( "Last Name" ) ); |
440 | list.append( QObject::tr( "Suffix" ) ); | 446 | list.append( QObject::tr( "Suffix" ) ); |
441 | list.append( QObject::tr( "File As" ) ); | 447 | list.append( QObject::tr( "File As" ) ); |
442 | 448 | ||
449 | list.append( QObject::tr( "Job Title" ) ); | ||
450 | list.append( QObject::tr( "Department" ) ); | ||
451 | list.append( QObject::tr( "Company" ) ); | ||
452 | list.append( QObject::tr( "Business Phone" ) ); | ||
453 | list.append( QObject::tr( "Business Fax" ) ); | ||
454 | list.append( QObject::tr( "Business Mobile" ) ); | ||
455 | |||
443 | list.append( QObject::tr( "Default Email" ) ); | 456 | list.append( QObject::tr( "Default Email" ) ); |
444 | list.append( QObject::tr( "Emails" ) ); | 457 | list.append( QObject::tr( "Emails" ) ); |
445 | 458 | ||
446 | list.append( QObject::tr( "Home Street" ) ); | ||
447 | list.append( QObject::tr( "Home City" ) ); | ||
448 | list.append( QObject::tr( "Home State" ) ); | ||
449 | list.append( QObject::tr( "Home Zip" ) ); | ||
450 | list.append( QObject::tr( "Home Country" ) ); | ||
451 | list.append( QObject::tr( "Home Phone" ) ); | 459 | list.append( QObject::tr( "Home Phone" ) ); |
452 | list.append( QObject::tr( "Home Fax" ) ); | 460 | list.append( QObject::tr( "Home Fax" ) ); |
453 | list.append( QObject::tr( "Home Mobile" ) ); | 461 | list.append( QObject::tr( "Home Mobile" ) ); |
454 | list.append( QObject::tr( "Home Web Page" ) ); | ||
455 | 462 | ||
456 | list.append( QObject::tr( "Company" ) ); | ||
457 | list.append( QObject::tr( "Business Street" ) ); | 463 | list.append( QObject::tr( "Business Street" ) ); |
458 | list.append( QObject::tr( "Business City" ) ); | 464 | list.append( QObject::tr( "Business City" ) ); |
459 | list.append( QObject::tr( "Business State" ) ); | 465 | list.append( QObject::tr( "Business State" ) ); |
460 | list.append( QObject::tr( "Business Zip" ) ); | 466 | list.append( QObject::tr( "Business Zip" ) ); |
461 | list.append( QObject::tr( "Business Country" ) ); | 467 | list.append( QObject::tr( "Business Country" ) ); |
468 | list.append( QObject::tr( "Business Pager" ) ); | ||
462 | list.append( QObject::tr( "Business WebPage" ) ); | 469 | list.append( QObject::tr( "Business WebPage" ) ); |
463 | list.append( QObject::tr( "Job Title" ) ); | 470 | |
464 | list.append( QObject::tr( "Department" ) ); | ||
465 | list.append( QObject::tr( "Office" ) ); | 471 | list.append( QObject::tr( "Office" ) ); |
466 | list.append( QObject::tr( "Business Phone" ) ); | ||
467 | list.append( QObject::tr( "Business Fax" ) ); | ||
468 | list.append( QObject::tr( "Business Mobile" ) ); | ||
469 | list.append( QObject::tr( "Business Pager" ) ); | ||
470 | list.append( QObject::tr( "Profession" ) ); | 472 | list.append( QObject::tr( "Profession" ) ); |
471 | list.append( QObject::tr( "Assistant" ) ); | 473 | list.append( QObject::tr( "Assistant" ) ); |
472 | list.append( QObject::tr( "Manager" ) ); | 474 | list.append( QObject::tr( "Manager" ) ); |
473 | 475 | ||
476 | list.append( QObject::tr( "Home Street" ) ); | ||
477 | list.append( QObject::tr( "Home City" ) ); | ||
478 | list.append( QObject::tr( "Home State" ) ); | ||
479 | list.append( QObject::tr( "Home Zip" ) ); | ||
480 | list.append( QObject::tr( "Home Country" ) ); | ||
481 | list.append( QObject::tr( "Home Web Page" ) ); | ||
482 | |||
474 | list.append( QObject::tr( "Spouse" ) ); | 483 | list.append( QObject::tr( "Spouse" ) ); |
475 | list.append( QObject::tr( "Gender" ) ); | 484 | list.append( QObject::tr( "Gender" ) ); |
476 | list.append( QObject::tr( "Birthday" ) ); | 485 | list.append( QObject::tr( "Birthday" ) ); |
477 | list.append( QObject::tr( "Anniversary" ) ); | 486 | list.append( QObject::tr( "Anniversary" ) ); |
478 | list.append( QObject::tr( "Nickname" ) ); | 487 | list.append( QObject::tr( "Nickname" ) ); |
479 | |||
480 | list.append( QObject::tr( "Children" ) ); | 488 | list.append( QObject::tr( "Children" ) ); |
489 | |||
481 | list.append( QObject::tr( "Notes" ) ); | 490 | list.append( QObject::tr( "Notes" ) ); |
491 | list.append( QObject::tr( "Groups" ) ); | ||
482 | 492 | ||
483 | return list; | 493 | return list; |
484 | } | 494 | } |
485 | 495 | ||
486 | void Contact::setEmails( const QString &v ) | 496 | void Contact::setEmails( const QString &v ) |
487 | { | 497 | { |
488 | replace( Qtopia::Emails, v ); | 498 | replace( Qtopia::Emails, v ); |
489 | if ( v.isEmpty() ) | 499 | if ( v.isEmpty() ) |
490 | setDefaultEmail( QString::null ); | 500 | setDefaultEmail( QString::null ); |
491 | } | 501 | } |
492 | 502 | ||
493 | void Contact::setChildren( const QString &v ) | 503 | void Contact::setChildren( const QString &v ) |
494 | { | 504 | { |
495 | replace( Qtopia::Children, v ); | 505 | replace( Qtopia::Children, v ); |
496 | } | 506 | } |
497 | 507 | ||
498 | // vcard conversion code | 508 | // vcard conversion code |
499 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 509 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
500 | { | 510 | { |
501 | VObject *ret = 0; | 511 | VObject *ret = 0; |
502 | if ( o && !value.isEmpty() ) | 512 | if ( o && !value.isEmpty() ) |
503 | ret = addPropValue( o, prop, value.latin1() ); | 513 | ret = addPropValue( o, prop, value.latin1() ); |
504 | return ret; | 514 | return ret; |
505 | } | 515 | } |
506 | 516 | ||
507 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 517 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
508 | { | 518 | { |
509 | VObject *ret = 0; | 519 | VObject *ret = 0; |
510 | if ( o ) | 520 | if ( o ) |
511 | ret = addProp( o, prop ); | 521 | ret = addProp( o, prop ); |
512 | return ret; | 522 | return ret; |
513 | } | 523 | } |
514 | 524 | ||
515 | static VObject *createVObject( const Contact &c ) | 525 | static VObject *createVObject( const Contact &c ) |
516 | { | 526 | { |
517 | VObject *vcard = newVObject( VCCardProp ); | 527 | VObject *vcard = newVObject( VCCardProp ); |
518 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 528 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
519 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 529 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
520 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 530 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
521 | 531 | ||
522 | // full name | 532 | // full name |
523 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 533 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
524 | 534 | ||
525 | // name properties | 535 | // name properties |
526 | VObject *name = safeAddProp( vcard, VCNameProp ); | 536 | VObject *name = safeAddProp( vcard, VCNameProp ); |
527 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 537 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
528 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 538 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
529 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 539 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
530 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 540 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
531 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 541 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
532 | 542 | ||
533 | // home properties | 543 | // home properties |
534 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 544 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
535 | safeAddProp( home_adr, VCHomeProp ); | 545 | safeAddProp( home_adr, VCHomeProp ); |
536 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 546 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
537 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 547 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
538 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 548 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
539 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 549 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
540 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 550 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
541 | 551 | ||
542 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 552 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
543 | safeAddProp( home_phone, VCHomeProp ); | 553 | safeAddProp( home_phone, VCHomeProp ); |
544 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 554 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
545 | safeAddProp( home_phone, VCHomeProp ); | 555 | safeAddProp( home_phone, VCHomeProp ); |
@@ -568,342 +578,347 @@ static VObject *createVObject( const Contact &c ) | |||
568 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 578 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
569 | safeAddProp( work_phone, VCWorkProp ); | 579 | safeAddProp( work_phone, VCWorkProp ); |
570 | safeAddProp( work_phone, VCFaxProp ); | 580 | safeAddProp( work_phone, VCFaxProp ); |
571 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 581 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
572 | safeAddProp( work_phone, VCWorkProp ); | 582 | safeAddProp( work_phone, VCWorkProp ); |
573 | safeAddProp( work_phone, VCPagerProp ); | 583 | safeAddProp( work_phone, VCPagerProp ); |
574 | 584 | ||
575 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 585 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
576 | safeAddProp( url, VCWorkProp ); | 586 | safeAddProp( url, VCWorkProp ); |
577 | 587 | ||
578 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 588 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
579 | safeAddProp( title, VCWorkProp ); | 589 | safeAddProp( title, VCWorkProp ); |
580 | 590 | ||
581 | 591 | ||
582 | QStringList emails = c.emailList(); | 592 | QStringList emails = c.emailList(); |
583 | emails.prepend( c.defaultEmail() ); | 593 | emails.prepend( c.defaultEmail() ); |
584 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 594 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
585 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 595 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
586 | safeAddProp( email, VCInternetProp ); | 596 | safeAddProp( email, VCInternetProp ); |
587 | } | 597 | } |
588 | 598 | ||
589 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 599 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
590 | 600 | ||
591 | safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); | 601 | safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); |
592 | 602 | ||
593 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 603 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
594 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 604 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
595 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 605 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
596 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 606 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
597 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 607 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
598 | } | 608 | } |
599 | 609 | ||
600 | // some values we have to export as custom fields | 610 | // some values we have to export as custom fields |
601 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 611 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
602 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 612 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
603 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 613 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
604 | 614 | ||
605 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 615 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
606 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 616 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
607 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); | 617 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); |
608 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 618 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
609 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 619 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
610 | 620 | ||
611 | return vcard; | 621 | return vcard; |
612 | } | 622 | } |
613 | 623 | ||
614 | 624 | ||
615 | static Contact parseVObject( VObject *obj ) | 625 | static Contact parseVObject( VObject *obj ) |
616 | { | 626 | { |
617 | Contact c; | 627 | Contact c; |
618 | 628 | ||
619 | bool haveDefaultEmail = FALSE; | 629 | bool haveDefaultEmail = FALSE; |
620 | 630 | ||
621 | VObjectIterator it; | 631 | VObjectIterator it; |
622 | initPropIterator( &it, obj ); | 632 | initPropIterator( &it, obj ); |
623 | while( moreIteration( &it ) ) { | 633 | while( moreIteration( &it ) ) { |
624 | VObject *o = nextVObject( &it ); | 634 | VObject *o = nextVObject( &it ); |
625 | QCString name = vObjectName( o ); | 635 | QCString name = vObjectName( o ); |
626 | QCString value = vObjectStringZValue( o ); | 636 | QCString value = vObjectStringZValue( o ); |
627 | if ( name == VCNameProp ) { | 637 | if ( name == VCNameProp ) { |
628 | VObjectIterator nit; | 638 | VObjectIterator nit; |
629 | initPropIterator( &nit, o ); | 639 | initPropIterator( &nit, o ); |
630 | while( moreIteration( &nit ) ) { | 640 | while( moreIteration( &nit ) ) { |
631 | VObject *o = nextVObject( &nit ); | 641 | VObject *o = nextVObject( &nit ); |
632 | QCString name = vObjectName( o ); | 642 | QCString name = vObjectTypeInfo( o ); |
633 | QString value = vObjectStringZValue( o ); | 643 | QString value = vObjectStringZValue( o ); |
634 | if ( name == VCNamePrefixesProp ) | 644 | if ( name == VCNamePrefixesProp ) |
635 | c.setTitle( value ); | 645 | c.setTitle( value ); |
636 | else if ( name == VCNameSuffixesProp ) | 646 | else if ( name == VCNameSuffixesProp ) |
637 | c.setSuffix( value ); | 647 | c.setSuffix( value ); |
638 | else if ( name == VCFamilyNameProp ) | 648 | else if ( name == VCFamilyNameProp ) |
639 | c.setLastName( value ); | 649 | c.setLastName( value ); |
640 | else if ( name == VCGivenNameProp ) | 650 | else if ( name == VCGivenNameProp ) |
641 | c.setFirstName( value ); | 651 | c.setFirstName( value ); |
642 | else if ( name == VCAdditionalNamesProp ) | 652 | else if ( name == VCAdditionalNamesProp ) |
643 | c.setMiddleName( value ); | 653 | c.setMiddleName( value ); |
644 | } | 654 | } |
645 | } | 655 | } |
646 | else if ( name == VCAdrProp ) { | 656 | else if ( name == VCAdrProp ) { |
647 | bool work = TRUE; // default address is work address | 657 | bool work = TRUE; // default address is work address |
648 | QString street; | 658 | QString street; |
649 | QString city; | 659 | QString city; |
650 | QString region; | 660 | QString region; |
651 | QString postal; | 661 | QString postal; |
652 | QString country; | 662 | QString country; |
653 | 663 | ||
654 | VObjectIterator nit; | 664 | VObjectIterator nit; |
655 | initPropIterator( &nit, o ); | 665 | initPropIterator( &nit, o ); |
656 | while( moreIteration( &nit ) ) { | 666 | while( moreIteration( &nit ) ) { |
657 | VObject *o = nextVObject( &nit ); | 667 | VObject *o = nextVObject( &nit ); |
658 | QCString name = vObjectName( o ); | 668 | QCString name = vObjectName( o ); |
659 | QString value = vObjectStringZValue( o ); | 669 | QString value = vObjectStringZValue( o ); |
660 | if ( name == VCHomeProp ) | 670 | if ( name == VCHomeProp ) |
661 | work = FALSE; | 671 | work = FALSE; |
662 | else if ( name == VCWorkProp ) | 672 | else if ( name == VCWorkProp ) |
663 | work = TRUE; | 673 | work = TRUE; |
664 | else if ( name == VCStreetAddressProp ) | 674 | else if ( name == VCStreetAddressProp ) |
665 | street = value; | 675 | street = value; |
666 | else if ( name == VCCityProp ) | 676 | else if ( name == VCCityProp ) |
667 | city = value; | 677 | city = value; |
668 | else if ( name == VCRegionProp ) | 678 | else if ( name == VCRegionProp ) |
669 | region = value; | 679 | region = value; |
670 | else if ( name == VCPostalCodeProp ) | 680 | else if ( name == VCPostalCodeProp ) |
671 | postal = value; | 681 | postal = value; |
672 | else if ( name == VCCountryNameProp ) | 682 | else if ( name == VCCountryNameProp ) |
673 | country = value; | 683 | country = value; |
674 | } | 684 | } |
675 | if ( work ) { | 685 | if ( work ) { |
676 | c.setBusinessStreet( street ); | 686 | c.setBusinessStreet( street ); |
677 | c.setBusinessCity( city ); | 687 | c.setBusinessCity( city ); |
678 | c.setBusinessCountry( country ); | 688 | c.setBusinessCountry( country ); |
679 | c.setBusinessZip( postal ); | 689 | c.setBusinessZip( postal ); |
680 | c.setBusinessState( region ); | 690 | c.setBusinessState( region ); |
681 | } else { | 691 | } else { |
682 | c.setHomeStreet( street ); | 692 | c.setHomeStreet( street ); |
683 | c.setHomeCity( city ); | 693 | c.setHomeCity( city ); |
684 | c.setHomeCountry( country ); | 694 | c.setHomeCountry( country ); |
685 | c.setHomeZip( postal ); | 695 | c.setHomeZip( postal ); |
686 | c.setHomeState( region ); | 696 | c.setHomeState( region ); |
687 | } | 697 | } |
688 | } | 698 | } |
689 | else if ( name == VCTelephoneProp ) { | 699 | else if ( name == VCTelephoneProp ) { |
690 | enum { | 700 | enum { |
691 | HOME = 0x01, | 701 | HOME = 0x01, |
692 | WORK = 0x02, | 702 | WORK = 0x02, |
693 | VOICE = 0x04, | 703 | VOICE = 0x04, |
694 | CELL = 0x08, | 704 | CELL = 0x08, |
695 | FAX = 0x10, | 705 | FAX = 0x10, |
696 | PAGER = 0x20, | 706 | PAGER = 0x20, |
697 | UNKNOWN = 0x80 | 707 | UNKNOWN = 0x80 |
698 | }; | 708 | }; |
699 | int type = 0; | 709 | int type = 0; |
700 | 710 | ||
701 | VObjectIterator nit; | 711 | VObjectIterator nit; |
702 | initPropIterator( &nit, o ); | 712 | initPropIterator( &nit, o ); |
703 | while( moreIteration( &nit ) ) { | 713 | while( moreIteration( &nit ) ) { |
704 | VObject *o = nextVObject( &nit ); | 714 | VObject *o = nextVObject( &nit ); |
705 | QCString name = vObjectName( o ); | 715 | QCString name = vObjectTypeInfo( o ); |
706 | if ( name == VCHomeProp ) | 716 | if ( name == VCHomeProp ) |
707 | type |= HOME; | 717 | type |= HOME; |
708 | else if ( name == VCWorkProp ) | 718 | else if ( name == VCWorkProp ) |
709 | type |= WORK; | 719 | type |= WORK; |
710 | else if ( name == VCVoiceProp ) | 720 | else if ( name == VCVoiceProp ) |
711 | type |= VOICE; | 721 | type |= VOICE; |
712 | else if ( name == VCCellularProp ) | 722 | else if ( name == VCCellularProp ) |
713 | type |= CELL; | 723 | type |= CELL; |
714 | else if ( name == VCFaxProp ) | 724 | else if ( name == VCFaxProp ) |
715 | type |= FAX; | 725 | type |= FAX; |
716 | else if ( name == VCPagerProp ) | 726 | else if ( name == VCPagerProp ) |
717 | type |= PAGER; | 727 | type |= PAGER; |
718 | else if ( name == VCPreferredProp ) | 728 | else if ( name == VCPreferredProp ) |
719 | ; | 729 | ; |
720 | else | 730 | else |
721 | type |= UNKNOWN; | 731 | type |= UNKNOWN; |
722 | } | 732 | } |
723 | if ( (type & UNKNOWN) != UNKNOWN ) { | 733 | if ( (type & UNKNOWN) != UNKNOWN ) { |
724 | if ( ( type & (HOME|WORK) ) == 0 ) // default | 734 | if ( ( type & (HOME|WORK) ) == 0 ) // default |
725 | type |= HOME; | 735 | type |= HOME; |
726 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default | 736 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default |
727 | type |= VOICE; | 737 | type |= VOICE; |
728 | 738 | ||
729 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) | 739 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) |
730 | c.setHomePhone( value ); | 740 | c.setHomePhone( value ); |
731 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) | 741 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) |
732 | c.setHomeFax( value ); | 742 | c.setHomeFax( value ); |
733 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) | 743 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) |
734 | c.setHomeMobile( value ); | 744 | c.setHomeMobile( value ); |
735 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) | 745 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) |
736 | c.setBusinessPhone( value ); | 746 | c.setBusinessPhone( value ); |
737 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) | 747 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) |
738 | c.setBusinessFax( value ); | 748 | c.setBusinessFax( value ); |
739 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) | 749 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) |
740 | c.setBusinessMobile( value ); | 750 | c.setBusinessMobile( value ); |
741 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) | 751 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) |
742 | c.setBusinessPager( value ); | 752 | c.setBusinessPager( value ); |
743 | } | 753 | } |
744 | } | 754 | } |
745 | else if ( name == VCEmailAddressProp ) { | 755 | else if ( name == VCEmailAddressProp ) { |
746 | QString email = vObjectStringZValue( o ); | 756 | QString email = vObjectStringZValue( o ); |
747 | bool valid = TRUE; | 757 | bool valid = TRUE; |
748 | VObjectIterator nit; | 758 | VObjectIterator nit; |
749 | initPropIterator( &nit, o ); | 759 | initPropIterator( &nit, o ); |
750 | while( moreIteration( &nit ) ) { | 760 | while( moreIteration( &nit ) ) { |
751 | VObject *o = nextVObject( &nit ); | 761 | VObject *o = nextVObject( &nit ); |
752 | QCString name = vObjectName( o ); | 762 | QCString name = vObjectTypeInfo( o ); |
753 | if ( name != VCInternetProp && name != VCHomeProp && | 763 | if ( name != VCInternetProp && name != VCHomeProp && |
754 | name != VCWorkProp && | 764 | name != VCWorkProp && |
755 | name != VCPreferredProp ) | 765 | name != VCPreferredProp ) |
756 | // ### preffered should map to default email | 766 | // ### preffered should map to default email |
757 | valid = FALSE; | 767 | valid = FALSE; |
758 | } | 768 | } |
759 | if ( valid ) { | 769 | if ( valid ) { |
760 | if ( haveDefaultEmail ) { | 770 | if ( haveDefaultEmail ) { |
761 | QString str = c.emails(); | 771 | QString str = c.emails(); |
762 | if ( !str.isEmpty() ) | 772 | if ( !str.isEmpty() ) |
763 | str += ","+email; | 773 | str += ","+email; |
764 | c.setEmails( str ); | 774 | c.setEmails( str ); |
765 | } else { | 775 | } else { |
766 | c.setDefaultEmail( email ); | 776 | c.setDefaultEmail( email ); |
767 | } | 777 | } |
768 | } | 778 | } |
769 | } | 779 | } |
770 | else if ( name == VCURLProp ) { | 780 | else if ( name == VCURLProp ) { |
771 | VObjectIterator nit; | 781 | VObjectIterator nit; |
772 | initPropIterator( &nit, o ); | 782 | initPropIterator( &nit, o ); |
773 | while( moreIteration( &nit ) ) { | 783 | while( moreIteration( &nit ) ) { |
774 | VObject *o = nextVObject( &nit ); | 784 | VObject *o = nextVObject( &nit ); |
775 | QCString name = vObjectName( o ); | 785 | QCString name = vObjectTypeInfo( o ); |
776 | if ( name == VCHomeProp ) | 786 | if ( name == VCHomeProp ) |
777 | c.setHomeWebpage( value ); | 787 | c.setHomeWebpage( value ); |
778 | else if ( name == VCWorkProp ) | 788 | else if ( name == VCWorkProp ) |
779 | c.setBusinessWebpage( value ); | 789 | c.setBusinessWebpage( value ); |
780 | } | 790 | } |
781 | } | 791 | } |
782 | else if ( name == VCOrgProp ) { | 792 | else if ( name == VCOrgProp ) { |
783 | VObjectIterator nit; | 793 | VObjectIterator nit; |
784 | initPropIterator( &nit, o ); | 794 | initPropIterator( &nit, o ); |
785 | while( moreIteration( &nit ) ) { | 795 | while( moreIteration( &nit ) ) { |
786 | VObject *o = nextVObject( &nit ); | 796 | VObject *o = nextVObject( &nit ); |
787 | QCString name = vObjectName( o ); | 797 | QCString name = vObjectName( o ); |
788 | QString value = vObjectStringZValue( o ); | 798 | QString value = vObjectStringZValue( o ); |
789 | if ( name == VCOrgNameProp ) | 799 | if ( name == VCOrgNameProp ) |
790 | c.setCompany( value ); | 800 | c.setCompany( value ); |
791 | else if ( name == VCOrgUnitProp ) | 801 | else if ( name == VCOrgUnitProp ) |
792 | c.setDepartment( value ); | 802 | c.setDepartment( value ); |
793 | else if ( name == VCOrgUnit2Prop ) | 803 | else if ( name == VCOrgUnit2Prop ) |
794 | c.setOffice( value ); | 804 | c.setOffice( value ); |
795 | } | 805 | } |
796 | } | 806 | } |
797 | else if ( name == VCTitleProp ) { | 807 | else if ( name == VCTitleProp ) { |
798 | c.setJobTitle( value ); | 808 | c.setJobTitle( value ); |
799 | } | 809 | } |
800 | else if ( name == "X-Qtopia-Profession" ) { | 810 | else if ( name == "X-Qtopia-Profession" ) { |
801 | c.setProfession( value ); | 811 | c.setProfession( value ); |
802 | } | 812 | } |
803 | else if ( name == "X-Qtopia-Manager" ) { | 813 | else if ( name == "X-Qtopia-Manager" ) { |
804 | c.setManager( value ); | 814 | c.setManager( value ); |
805 | } | 815 | } |
806 | else if ( name == "X-Qtopia-Assistant" ) { | 816 | else if ( name == "X-Qtopia-Assistant" ) { |
807 | c.setAssistant( value ); | 817 | c.setAssistant( value ); |
808 | } | 818 | } |
809 | else if ( name == "X-Qtopia-Spouse" ) { | 819 | else if ( name == "X-Qtopia-Spouse" ) { |
810 | c.setSpouse( value ); | 820 | c.setSpouse( value ); |
811 | } | 821 | } |
812 | else if ( name == "X-Qtopia-Gender" ) { | 822 | else if ( name == "X-Qtopia-Gender" ) { |
813 | c.setGender( value ); | 823 | c.setGender( value ); |
814 | } | 824 | } |
815 | else if ( name == "X-Qtopia-Anniversary" ) { | 825 | else if ( name == "X-Qtopia-Anniversary" ) { |
816 | c.setAnniversary( value ); | 826 | c.setAnniversary( value ); |
817 | } | 827 | } |
818 | else if ( name == "X-Qtopia-Nickname" ) { | 828 | else if ( name == "X-Qtopia-Nickname" ) { |
819 | c.setNickname( value ); | 829 | c.setNickname( value ); |
820 | } | 830 | } |
821 | else if ( name == "X-Qtopia-Children" ) { | 831 | else if ( name == "X-Qtopia-Children" ) { |
822 | c.setChildren( value ); | 832 | c.setChildren( value ); |
823 | } | 833 | } |
824 | 834 | ||
825 | 835 | ||
826 | #if 0 | 836 | #if 0 |
827 | else { | 837 | else { |
828 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 838 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
829 | VObjectIterator nit; | 839 | VObjectIterator nit; |
830 | initPropIterator( &nit, o ); | 840 | initPropIterator( &nit, o ); |
831 | while( moreIteration( &nit ) ) { | 841 | while( moreIteration( &nit ) ) { |
832 | VObject *o = nextVObject( &nit ); | 842 | VObject *o = nextVObject( &nit ); |
833 | QCString name = vObjectName( o ); | 843 | QCString name = vObjectName( o ); |
834 | QString value = vObjectStringZValue( o ); | 844 | QString value = vObjectStringZValue( o ); |
835 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 845 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
836 | } | 846 | } |
837 | } | 847 | } |
838 | #endif | 848 | #endif |
839 | } | 849 | } |
840 | c.setFileAs(); | 850 | c.setFileAs(); |
841 | return c; | 851 | return c; |
842 | } | 852 | } |
843 | 853 | ||
844 | void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) | 854 | void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) |
845 | { | 855 | { |
846 | QFileDirect f( filename.utf8().data() ); | 856 | QFileDirect f( filename.utf8().data() ); |
847 | if ( !f.open( IO_WriteOnly ) ) { | 857 | if ( !f.open( IO_WriteOnly ) ) { |
848 | qWarning("Unable to open vcard write"); | 858 | qWarning("Unable to open vcard write"); |
849 | return; | 859 | return; |
850 | } | 860 | } |
851 | 861 | ||
852 | QValueList<Contact>::ConstIterator it; | 862 | QValueList<Contact>::ConstIterator it; |
853 | for( it = contacts.begin(); it != contacts.end(); ++it ) { | 863 | for( it = contacts.begin(); it != contacts.end(); ++it ) { |
854 | VObject *obj = createVObject( *it ); | 864 | VObject *obj = createVObject( *it ); |
855 | writeVObject(f.directHandle() , obj ); | 865 | writeVObject(f.directHandle() , obj ); |
856 | cleanVObject( obj ); | 866 | cleanVObject( obj ); |
857 | } | 867 | } |
858 | cleanStrTbl(); | 868 | cleanStrTbl(); |
859 | } | 869 | } |
860 | 870 | ||
861 | void Contact::writeVCard( const QString &filename, const Contact &contact) | 871 | void Contact::writeVCard( const QString &filename, const Contact &contact) |
862 | { | 872 | { |
863 | QFileDirect f( filename.utf8().data() ); | 873 | QFileDirect f( filename.utf8().data() ); |
864 | if ( !f.open( IO_WriteOnly ) ) { | 874 | if ( !f.open( IO_WriteOnly ) ) { |
865 | qWarning("Unable to open vcard write"); | 875 | qWarning("Unable to open vcard write"); |
866 | return; | 876 | return; |
867 | } | 877 | } |
868 | 878 | ||
869 | VObject *obj = createVObject( contact ); | 879 | VObject *obj = createVObject( contact ); |
870 | writeVObject( f.directHandle() , obj ); | 880 | writeVObject( f.directHandle() , obj ); |
871 | cleanVObject( obj ); | 881 | cleanVObject( obj ); |
872 | 882 | ||
873 | cleanStrTbl(); | 883 | cleanStrTbl(); |
874 | } | 884 | } |
875 | 885 | ||
876 | 886 | ||
877 | QValueList<Contact> Contact::readVCard( const QString &filename ) | 887 | QValueList<Contact> Contact::readVCard( const QString &filename ) |
878 | { | 888 | { |
879 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 889 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
880 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 890 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
881 | 891 | ||
882 | qDebug("vobject = %p", obj ); | 892 | qDebug("vobject = %p", obj ); |
883 | 893 | ||
884 | QValueList<Contact> contacts; | 894 | QValueList<Contact> contacts; |
885 | 895 | ||
886 | while ( obj ) { | 896 | while ( obj ) { |
887 | contacts.append( parseVObject( obj ) ); | 897 | contacts.append( parseVObject( obj ) ); |
888 | 898 | ||
889 | VObject *t = obj; | 899 | VObject *t = obj; |
890 | obj = nextVObjectInList(obj); | 900 | obj = nextVObjectInList(obj); |
891 | cleanVObject( t ); | 901 | cleanVObject( t ); |
892 | } | 902 | } |
893 | 903 | ||
894 | return contacts; | 904 | return contacts; |
895 | } | 905 | } |
896 | 906 | ||
907 | bool Contact::match( const QString ®exp ) const | ||
908 | { | ||
909 | return match(QRegExp(regexp)); | ||
910 | } | ||
911 | |||
897 | bool Contact::match( const QRegExp &r ) const | 912 | bool Contact::match( const QRegExp &r ) const |
898 | { | 913 | { |
899 | bool match; | 914 | bool match; |
900 | match = false; | 915 | match = false; |
901 | QMap<int, QString>::ConstIterator it; | 916 | QMap<int, QString>::ConstIterator it; |
902 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 917 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
903 | if ( (*it).find( r ) > -1 ) { | 918 | if ( (*it).find( r ) > -1 ) { |
904 | match = true; | 919 | match = true; |
905 | break; | 920 | break; |
906 | } | 921 | } |
907 | } | 922 | } |
908 | return match; | 923 | return match; |
909 | } | 924 | } |
diff --git a/library/backend/contact.h b/library/backend/contact.h index 6abdab6..a74cbbe 100644 --- a/library/backend/contact.h +++ b/library/backend/contact.h | |||
@@ -40,129 +40,134 @@ public: | |||
40 | Contact(); | 40 | Contact(); |
41 | Contact( const QMap<int, QString> &fromMap ); | 41 | Contact( const QMap<int, QString> &fromMap ); |
42 | virtual ~Contact(); | 42 | virtual ~Contact(); |
43 | 43 | ||
44 | static void writeVCard( const QString &filename, const QValueList<Contact> &contacts); | 44 | static void writeVCard( const QString &filename, const QValueList<Contact> &contacts); |
45 | static void writeVCard( const QString &filename, const Contact &c ); | 45 | static void writeVCard( const QString &filename, const Contact &c ); |
46 | static QValueList<Contact> readVCard( const QString &filename ); | 46 | static QValueList<Contact> readVCard( const QString &filename ); |
47 | 47 | ||
48 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | 48 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; |
49 | 49 | ||
50 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 50 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
56 | void setFileAs(); | 56 | void setFileAs(); |
57 | 57 | ||
58 | // default email address | 58 | // default email address |
59 | void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } | 59 | void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } |
60 | // the emails should be seperated by a semicolon | 60 | // the emails should be seperated by a semicolon |
61 | void setEmails( const QString &v ); | 61 | void setEmails( const QString &v ); |
62 | 62 | ||
63 | // home | 63 | // home |
64 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 64 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
65 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 65 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
66 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 66 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
67 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 67 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
68 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 68 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
69 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 69 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
70 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 70 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
71 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 71 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
72 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 72 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
73 | 73 | ||
74 | // business | 74 | // business |
75 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 75 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
76 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 76 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
77 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 77 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
78 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 78 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
79 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 79 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
80 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 80 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
81 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 81 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
82 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 82 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
83 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 83 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
84 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 84 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
85 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 85 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
86 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 86 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
87 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 87 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
88 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 88 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
89 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 89 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
90 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 90 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
91 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 91 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
92 | 92 | ||
93 | // personal | 93 | // personal |
94 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 94 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
95 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 95 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
96 | void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } | 96 | void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } |
97 | void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } | 97 | void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } |
98 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 98 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
99 | void setChildren( const QString &v ); | 99 | void setChildren( const QString &v ); |
100 | 100 | ||
101 | // other | 101 | // other |
102 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 102 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
103 | 103 | ||
104 | bool match( const QRegExp &r ) const; | 104 | bool match( const QString ®exp ) const; |
105 | |||
106 | // DON'T ATTEMPT TO USE THIS | ||
107 | #ifdef QTOPIA_INTERNAL_CONTACT_MRE | ||
108 | bool match( const QRegExp ®exp ) const; | ||
109 | #endif | ||
105 | 110 | ||
106 | // // custom | 111 | // // custom |
107 | // void setCustomField( const QString &key, const QString &v ) | 112 | // void setCustomField( const QString &key, const QString &v ) |
108 | // { replace(Custom- + key, v ); } | 113 | // { replace(Custom- + key, v ); } |
109 | 114 | ||
110 | // name | 115 | // name |
111 | QString fullName() const; | 116 | QString fullName() const; |
112 | QString title() const { return find( Qtopia::Title ); } | 117 | QString title() const { return find( Qtopia::Title ); } |
113 | QString firstName() const { return find( Qtopia::FirstName ); } | 118 | QString firstName() const { return find( Qtopia::FirstName ); } |
114 | QString middleName() const { return find( Qtopia::MiddleName ); } | 119 | QString middleName() const { return find( Qtopia::MiddleName ); } |
115 | QString lastName() const { return find( Qtopia::LastName ); } | 120 | QString lastName() const { return find( Qtopia::LastName ); } |
116 | QString suffix() const { return find( Qtopia::Suffix ); } | 121 | QString suffix() const { return find( Qtopia::Suffix ); } |
117 | QString fileAs() const { return find( Qtopia::FileAs ); } | 122 | QString fileAs() const { return find( Qtopia::FileAs ); } |
118 | 123 | ||
119 | 124 | ||
120 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 125 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
121 | QString emails() const { return find( Qtopia::Emails ); } | 126 | QString emails() const { return find( Qtopia::Emails ); } |
122 | QStringList emailList() const; | 127 | QStringList emailList() const; |
123 | 128 | ||
124 | // home | 129 | // home |
125 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 130 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
126 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 131 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
127 | QString homeState() const { return find( Qtopia::HomeState ); } | 132 | QString homeState() const { return find( Qtopia::HomeState ); } |
128 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 133 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
129 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 134 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
130 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 135 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
131 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 136 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
132 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 137 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
133 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 138 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
134 | /** Multi line string containing all non-empty address info in the form | 139 | /** Multi line string containing all non-empty address info in the form |
135 | * Street | 140 | * Street |
136 | * City, State Zip | 141 | * City, State Zip |
137 | * Country | 142 | * Country |
138 | */ | 143 | */ |
139 | QString displayHomeAddress() const; | 144 | QString displayHomeAddress() const; |
140 | 145 | ||
141 | // business | 146 | // business |
142 | QString company() const { return find( Qtopia::Company ); } | 147 | QString company() const { return find( Qtopia::Company ); } |
143 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 148 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
144 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 149 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
145 | QString businessState() const { return find( Qtopia::BusinessState ); } | 150 | QString businessState() const { return find( Qtopia::BusinessState ); } |
146 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 151 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
147 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 152 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
148 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 153 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
149 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 154 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
150 | QString department() const { return find( Qtopia::Department ); } | 155 | QString department() const { return find( Qtopia::Department ); } |
151 | QString office() const { return find( Qtopia::Office ); } | 156 | QString office() const { return find( Qtopia::Office ); } |
152 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 157 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
153 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 158 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
154 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 159 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
155 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 160 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
156 | QString profession() const { return find( Qtopia::Profession ); } | 161 | QString profession() const { return find( Qtopia::Profession ); } |
157 | QString assistant() const { return find( Qtopia::Assistant ); } | 162 | QString assistant() const { return find( Qtopia::Assistant ); } |
158 | QString manager() const { return find( Qtopia::Manager ); } | 163 | QString manager() const { return find( Qtopia::Manager ); } |
159 | /** Multi line string containing all non-empty address info in the form | 164 | /** Multi line string containing all non-empty address info in the form |
160 | * Street | 165 | * Street |
161 | * City, State Zip | 166 | * City, State Zip |
162 | * Country | 167 | * Country |
163 | */ | 168 | */ |
164 | QString displayBusinessAddress() const; | 169 | QString displayBusinessAddress() const; |
165 | 170 | ||
166 | //personal | 171 | //personal |
167 | QString spouse() const { return find( Qtopia::Spouse ); } | 172 | QString spouse() const { return find( Qtopia::Spouse ); } |
168 | QString gender() const { return find( Qtopia::Gender ); } | 173 | QString gender() const { return find( Qtopia::Gender ); } |
diff --git a/library/backend/event.h b/library/backend/event.h index 0ebe9ea..277aadd 100644 --- a/library/backend/event.h +++ b/library/backend/event.h | |||
@@ -79,129 +79,134 @@ public: | |||
79 | 79 | ||
80 | void setDescription( const QString &s ); | 80 | void setDescription( const QString &s ); |
81 | const QString &description() const; | 81 | const QString &description() const; |
82 | 82 | ||
83 | void setLocation( const QString &s ); | 83 | void setLocation( const QString &s ); |
84 | const QString &location() const; | 84 | const QString &location() const; |
85 | 85 | ||
86 | void setType( Type t ); | 86 | void setType( Type t ); |
87 | Type type() const; | 87 | Type type() const; |
88 | void setStart( const QDateTime &d ); | 88 | void setStart( const QDateTime &d ); |
89 | void setStart( time_t time ); | 89 | void setStart( time_t time ); |
90 | QDateTime start( bool actual = FALSE ) const; | 90 | QDateTime start( bool actual = FALSE ) const; |
91 | time_t startTime() const { return startUTC; } | 91 | time_t startTime() const { return startUTC; } |
92 | void setEnd( const QDateTime &e ); | 92 | void setEnd( const QDateTime &e ); |
93 | void setEnd( time_t time ); | 93 | void setEnd( time_t time ); |
94 | QDateTime end( bool actual = FALSE ) const; | 94 | QDateTime end( bool actual = FALSE ) const; |
95 | time_t endTime() const { return endUTC; } | 95 | time_t endTime() const { return endUTC; } |
96 | void setTimeZone( const QString & ); | 96 | void setTimeZone( const QString & ); |
97 | const QString &timeZone() const; | 97 | const QString &timeZone() const; |
98 | void setAlarm( bool b, int minutes, SoundTypeChoice ); | 98 | void setAlarm( bool b, int minutes, SoundTypeChoice ); |
99 | bool hasAlarm() const; | 99 | bool hasAlarm() const; |
100 | int alarmTime() const; | 100 | int alarmTime() const; |
101 | SoundTypeChoice alarmSound() const; | 101 | SoundTypeChoice alarmSound() const; |
102 | void setRepeat( bool b, const RepeatPattern &p ); | 102 | void setRepeat( bool b, const RepeatPattern &p ); |
103 | void setRepeat( const RepeatPattern &p ); | 103 | void setRepeat( const RepeatPattern &p ); |
104 | bool hasRepeat() const; | 104 | bool hasRepeat() const; |
105 | const RepeatPattern &repeatPattern() const; | 105 | const RepeatPattern &repeatPattern() const; |
106 | RepeatPattern &repeatPattern(); | 106 | RepeatPattern &repeatPattern(); |
107 | void setNotes( const QString &n ); | 107 | void setNotes( const QString &n ); |
108 | const QString ¬es() const; | 108 | const QString ¬es() const; |
109 | bool doRepeat() const { return pattern.type != NoRepeat; } | 109 | bool doRepeat() const { return pattern.type != NoRepeat; } |
110 | 110 | ||
111 | void save( QString& buf ); | 111 | void save( QString& buf ); |
112 | //void load( Node *n ); | 112 | //void load( Node *n ); |
113 | 113 | ||
114 | // helper function to calculate the week of the given date | 114 | // helper function to calculate the week of the given date |
115 | static int week( const QDate& date ); | 115 | static int week( const QDate& date ); |
116 | // calculates the number of occurrences of the week day of | 116 | // calculates the number of occurrences of the week day of |
117 | // the given date from the start of the month | 117 | // the given date from the start of the month |
118 | static int occurrence( const QDate& date ); | 118 | static int occurrence( const QDate& date ); |
119 | // returns a proper days-char for a given dayOfWeek() | 119 | // returns a proper days-char for a given dayOfWeek() |
120 | static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } | 120 | static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } |
121 | // returns the dayOfWeek for the *first* day it finds (ignores | 121 | // returns the dayOfWeek for the *first* day it finds (ignores |
122 | // any further days!). Returns 1 (Monday) if there isn't any day found | 122 | // any further days!). Returns 1 (Monday) if there isn't any day found |
123 | static int dayOfWeek( char day ); | 123 | static int dayOfWeek( char day ); |
124 | // returns the difference of months from first to second. | 124 | // returns the difference of months from first to second. |
125 | static int monthDiff( const QDate& first, const QDate& second ); | 125 | static int monthDiff( const QDate& first, const QDate& second ); |
126 | bool match( const QRegExp &r ) const; | 126 | bool match( const QRegExp &r ) const; |
127 | 127 | ||
128 | private: | 128 | private: |
129 | Qtopia::UidGen &uidGen() { return sUidGen; } | 129 | Qtopia::UidGen &uidGen() { return sUidGen; } |
130 | static Qtopia::UidGen sUidGen; | 130 | static Qtopia::UidGen sUidGen; |
131 | 131 | ||
132 | QString descript, locat, categ; | 132 | QString descript, locat, categ; |
133 | Type typ : 4; | 133 | Type typ : 4; |
134 | bool startTimeDirty : 1; | 134 | bool startTimeDirty : 1; |
135 | bool endTimeDirty : 1; | 135 | bool endTimeDirty : 1; |
136 | time_t startUTC, endUTC; | 136 | time_t startUTC, endUTC; |
137 | QString tz; | 137 | QString tz; |
138 | bool hAlarm, hRepeat; | 138 | bool hAlarm, hRepeat; |
139 | int aMinutes; | 139 | int aMinutes; |
140 | SoundTypeChoice aSound; | 140 | SoundTypeChoice aSound; |
141 | RepeatPattern pattern; | 141 | RepeatPattern pattern; |
142 | QString note; | 142 | QString note; |
143 | // ADDITION | ||
144 | int mRid;// Recode ID | ||
145 | int mRinfo;// Recode Info | ||
146 | // | ||
143 | EventPrivate *d; | 147 | EventPrivate *d; |
148 | |||
144 | }; | 149 | }; |
145 | 150 | ||
146 | // Since an event spans multiple day, it is better to have this | 151 | // Since an event spans multiple day, it is better to have this |
147 | // class to represent a day instead of creating many | 152 | // class to represent a day instead of creating many |
148 | // dummy events... | 153 | // dummy events... |
149 | 154 | ||
150 | class EffectiveEventPrivate; | 155 | class EffectiveEventPrivate; |
151 | class QPC_EXPORT EffectiveEvent | 156 | class QPC_EXPORT EffectiveEvent |
152 | { | 157 | { |
153 | public: | 158 | public: |
154 | // If we calculate the effective event of a multi-day event | 159 | // If we calculate the effective event of a multi-day event |
155 | // we have to figure out whether we are at the first day, | 160 | // we have to figure out whether we are at the first day, |
156 | // at the end, or anywhere else ("middle"). This is important | 161 | // at the end, or anywhere else ("middle"). This is important |
157 | // for the start/end times (00:00/23:59) | 162 | // for the start/end times (00:00/23:59) |
158 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | 163 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- |
159 | // day event | 164 | // day event |
160 | // Start: start time -> 23:59 | 165 | // Start: start time -> 23:59 |
161 | // End: 00:00 -> end time | 166 | // End: 00:00 -> end time |
162 | // Start | End == StartEnd: for single-day events (default) | 167 | // Start | End == StartEnd: for single-day events (default) |
163 | // here we draw start time -> end time | 168 | // here we draw start time -> end time |
164 | enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 }; | 169 | enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 }; |
165 | 170 | ||
166 | EffectiveEvent(); | 171 | EffectiveEvent(); |
167 | EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd ); | 172 | EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd ); |
168 | EffectiveEvent( const EffectiveEvent & ); | 173 | EffectiveEvent( const EffectiveEvent & ); |
169 | EffectiveEvent& operator=( const EffectiveEvent & ); | 174 | EffectiveEvent& operator=( const EffectiveEvent & ); |
170 | ~EffectiveEvent(); | 175 | ~EffectiveEvent(); |
171 | 176 | ||
172 | 177 | ||
173 | bool operator<( const EffectiveEvent &e ) const; | 178 | bool operator<( const EffectiveEvent &e ) const; |
174 | bool operator<=( const EffectiveEvent &e ) const; | 179 | bool operator<=( const EffectiveEvent &e ) const; |
175 | bool operator==( const EffectiveEvent &e ) const; | 180 | bool operator==( const EffectiveEvent &e ) const; |
176 | bool operator!=( const EffectiveEvent &e ) const; | 181 | bool operator!=( const EffectiveEvent &e ) const; |
177 | bool operator>( const EffectiveEvent &e ) const; | 182 | bool operator>( const EffectiveEvent &e ) const; |
178 | bool operator>= ( const EffectiveEvent &e ) const; | 183 | bool operator>= ( const EffectiveEvent &e ) const; |
179 | 184 | ||
180 | void setStart( const QTime &start ); | 185 | void setStart( const QTime &start ); |
181 | void setEnd( const QTime &end ); | 186 | void setEnd( const QTime &end ); |
182 | void setEvent( Event e ); | 187 | void setEvent( Event e ); |
183 | void setDate( const QDate &date ); | 188 | void setDate( const QDate &date ); |
184 | void setEffectiveDates( const QDate &from, const QDate &to ); | 189 | void setEffectiveDates( const QDate &from, const QDate &to ); |
185 | 190 | ||
186 | // QString category() const; | 191 | // QString category() const; |
187 | const QString &description() const; | 192 | const QString &description() const; |
188 | const QString &location() const; | 193 | const QString &location() const; |
189 | const QString ¬es() const; | 194 | const QString ¬es() const; |
190 | const Event &event() const; | 195 | const Event &event() const; |
191 | const QTime &start() const; | 196 | const QTime &start() const; |
192 | const QTime &end() const; | 197 | const QTime &end() const; |
193 | const QDate &date() const; | 198 | const QDate &date() const; |
194 | int length() const; | 199 | int length() const; |
195 | int size() const; | 200 | int size() const; |
196 | 201 | ||
197 | QDate startDate() const; | 202 | QDate startDate() const; |
198 | QDate endDate() const; | 203 | QDate endDate() const; |
199 | 204 | ||
200 | private: | 205 | private: |
201 | class EffectiveEventPrivate *d; | 206 | class EffectiveEventPrivate *d; |
202 | Event mEvent; | 207 | Event mEvent; |
203 | QDate mDate; | 208 | QDate mDate; |
204 | QTime mStart, | 209 | QTime mStart, |
205 | mEnd; | 210 | mEnd; |
206 | 211 | ||
207 | }; | 212 | }; |
diff --git a/library/backend/recordfields.h b/library/backend/recordfields.h index 3cddde2..4196c8b 100644 --- a/library/backend/recordfields.h +++ b/library/backend/recordfields.h | |||
@@ -1,135 +1,149 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** Licensees holding valid Qtopia Developer license may use this | 6 | ** Licensees holding valid Qtopia Developer license may use this |
7 | ** file in accordance with the Qtopia Developer License Agreement | 7 | ** file in accordance with the Qtopia Developer License Agreement |
8 | ** provided with the Software. | 8 | ** provided with the Software. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING |
11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
12 | ** PURPOSE. | 12 | ** PURPOSE. |
13 | ** | 13 | ** |
14 | ** email sales@trolltech.com for information about Qtopia License | 14 | ** email sales@trolltech.com for information about Qtopia License |
15 | ** Agreements. | 15 | ** Agreements. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | #ifndef QPC_RECORD_FIELDS_H | 21 | #ifndef QPC_RECORD_FIELDS_H |
22 | #define QPC_RECORD_FIELDS_H | 22 | #define QPC_RECORD_FIELDS_H |
23 | #include "qpcglobal.h" | 23 | #include "qpcglobal.h" |
24 | 24 | ||
25 | // dataset = "addressbook" | 25 | // dataset = "addressbook" |
26 | namespace Qtopia | 26 | namespace Qtopia |
27 | { | 27 | { |
28 | static const int UID_ID = 0; | 28 | static const int UID_ID = 0; |
29 | static const int CATEGORY_ID = 1; | 29 | static const int CATEGORY_ID = 1; |
30 | 30 | ||
31 | enum AddressBookFields { | 31 | enum AddressBookFields { |
32 | AddressUid = UID_ID, | 32 | AddressUid = UID_ID, |
33 | AddressCategory = CATEGORY_ID, | 33 | AddressCategory = CATEGORY_ID, |
34 | 34 | ||
35 | // NOTE: Order of fields dependency in backend/contact.cpp | ||
36 | |||
35 | Title, | 37 | Title, |
36 | FirstName, | 38 | FirstName, |
37 | MiddleName, | 39 | MiddleName, |
38 | LastName, | 40 | LastName, |
39 | Suffix, | 41 | Suffix, |
40 | FileAs, | 42 | FileAs, |
41 | 43 | ||
44 | JobTitle, | ||
45 | Department, | ||
46 | Company, | ||
47 | BusinessPhone, | ||
48 | BusinessFax, | ||
49 | BusinessMobile, | ||
50 | |||
42 | 51 | ||
43 | DefaultEmail, | 52 | DefaultEmail, |
44 | Emails, | 53 | Emails, |
45 | 54 | ||
46 | // home | ||
47 | HomeStreet, | ||
48 | HomeCity, | ||
49 | HomeState, | ||
50 | HomeZip, | ||
51 | HomeCountry, | ||
52 | HomePhone, | 55 | HomePhone, |
53 | HomeFax, | 56 | HomeFax, |
54 | HomeMobile, | 57 | HomeMobile, |
55 | HomeWebPage, | ||
56 | 58 | ||
57 | // business | 59 | // business |
58 | Company, | ||
59 | BusinessStreet, | 60 | BusinessStreet, |
60 | BusinessCity, | 61 | BusinessCity, |
61 | BusinessState, | 62 | BusinessState, |
62 | BusinessZip, | 63 | BusinessZip, |
63 | BusinessCountry, | 64 | BusinessCountry, |
65 | BusinessPager, | ||
64 | BusinessWebPage, | 66 | BusinessWebPage, |
65 | JobTitle, | 67 | |
66 | Department, | ||
67 | Office, | 68 | Office, |
68 | BusinessPhone, | ||
69 | BusinessFax, | ||
70 | BusinessMobile, | ||
71 | BusinessPager, | ||
72 | Profession, | 69 | Profession, |
73 | Assistant, | 70 | Assistant, |
74 | Manager, | 71 | Manager, |
75 | 72 | ||
73 | // home | ||
74 | HomeStreet, | ||
75 | HomeCity, | ||
76 | HomeState, | ||
77 | HomeZip, | ||
78 | HomeCountry, | ||
79 | HomeWebPage, | ||
80 | |||
76 | //personal | 81 | //personal |
77 | Spouse, | 82 | Spouse, |
78 | Gender, | 83 | Gender, |
79 | Birthday, | 84 | Birthday, |
80 | Anniversary, | 85 | Anniversary, |
81 | Nickname, | 86 | Nickname, |
82 | Children, | 87 | Children, |
83 | 88 | ||
84 | // other | 89 | // other |
85 | Notes, | 90 | Notes, |
86 | Groups | 91 | Groups |
92 | |||
93 | ,rid, | ||
94 | rinfo | ||
87 | }; | 95 | }; |
88 | 96 | ||
89 | // dataset = "todolist" | 97 | // dataset = "todolist" |
90 | enum TaskFields { | 98 | enum TaskFields { |
91 | TaskUid = UID_ID, | 99 | TaskUid = UID_ID, |
92 | TaskCategory = CATEGORY_ID, | 100 | TaskCategory = CATEGORY_ID, |
93 | 101 | ||
94 | HasDate, | 102 | HasDate, |
95 | Completed, | 103 | Completed, |
96 | TaskDescription, | 104 | TaskDescription, |
97 | Priority, | 105 | Priority, |
98 | Date | 106 | Date, |
107 | |||
108 | TaskRid, | ||
109 | TaskRinfo | ||
99 | }; | 110 | }; |
100 | 111 | ||
101 | // dataset = "categories" for todos | 112 | // dataset = "categories" for todos |
102 | enum CategoryFields { | 113 | enum CategoryFields { |
103 | CatUid = UID_ID, | 114 | CatUid = UID_ID, |
104 | CatName, | 115 | CatName, |
105 | CatAppGroup | 116 | CatAppGroup |
106 | }; | 117 | }; |
107 | 118 | ||
108 | 119 | ||
109 | // dataset = "datebook" | 120 | // dataset = "datebook" |
110 | enum DatebookFields { | 121 | enum DatebookFields { |
111 | DatebookUid = UID_ID, | 122 | DatebookUid = UID_ID, |
112 | DatebookCategory = CATEGORY_ID, | 123 | DatebookCategory = CATEGORY_ID, |
113 | 124 | ||
114 | DatebookDescription, | 125 | DatebookDescription, |
115 | Location, | 126 | Location, |
116 | TimeZone, | 127 | TimeZone, |
117 | Note, | 128 | Note, |
118 | StartDateTime, | 129 | StartDateTime, |
119 | EndDateTime, | 130 | EndDateTime, |
120 | DatebookType, | 131 | DatebookType, |
121 | HasAlarm, | 132 | HasAlarm, |
122 | SoundType, | 133 | SoundType, |
123 | AlarmTime, | 134 | AlarmTime, |
124 | 135 | ||
125 | RepeatPatternType, | 136 | RepeatPatternType, |
126 | RepeatPatternFrequency, | 137 | RepeatPatternFrequency, |
127 | RepeatPatternPosition, | 138 | RepeatPatternPosition, |
128 | RepeatPatternDays, | 139 | RepeatPatternDays, |
129 | RepeatPatternHasEndDate, | 140 | RepeatPatternHasEndDate, |
130 | RepeatPatternEndDate, | 141 | RepeatPatternEndDate, |
142 | |||
143 | DateBookRid, | ||
144 | DateBookRinfo | ||
131 | }; | 145 | }; |
132 | }; | 146 | }; |
133 | 147 | ||
134 | 148 | ||
135 | #endif | 149 | #endif |
diff --git a/library/backend/task.h b/library/backend/task.h index ffe26b0..6f383b8 100644 --- a/library/backend/task.h +++ b/library/backend/task.h | |||
@@ -11,67 +11,71 @@ | |||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __TASK_H__ | 20 | #ifndef __TASK_H__ |
21 | #define __TASK_H__ | 21 | #define __TASK_H__ |
22 | 22 | ||
23 | #include <qpe/palmtoprecord.h> | 23 | #include <qpe/palmtoprecord.h> |
24 | #include <qpe/stringutil.h> | 24 | #include <qpe/stringutil.h> |
25 | 25 | ||
26 | #include <qvaluelist.h> | 26 | #include <qvaluelist.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | 28 | ||
29 | class TaskPrivate; | 29 | class TaskPrivate; |
30 | class QPC_EXPORT Task : public Qtopia::Record | 30 | class QPC_EXPORT Task : public Qtopia::Record |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | Task(); | 33 | Task(); |
34 | Task( const QMap<int, QString> &fromMap ); | 34 | Task( const QMap<int, QString> &fromMap ); |
35 | ~Task(); | 35 | ~Task(); |
36 | 36 | ||
37 | QMap<int, QString> toMap() const; | 37 | QMap<int, QString> toMap() const; |
38 | 38 | ||
39 | static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks); | 39 | static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks); |
40 | static void writeVCalendar( const QString &filename, const Task &task); | 40 | static void writeVCalendar( const QString &filename, const Task &task); |
41 | static QValueList<Task> readVCalendar( const QString &filename ); | 41 | static QValueList<Task> readVCalendar( const QString &filename ); |
42 | 42 | ||
43 | void setPriority( int priority ) { mPriority = priority; } | 43 | void setPriority( int priority ) { mPriority = priority; } |
44 | int priority() const { return mPriority; } | 44 | int priority() const { return mPriority; } |
45 | 45 | ||
46 | // void setCategory( const QString& category ) | 46 | // void setCategory( const QString& category ) |
47 | // { mCategory = category.stripWhiteSpace(); } | 47 | // { mCategory = category.stripWhiteSpace(); } |
48 | // const QString &category() const { return mCategory; } | 48 | // const QString &category() const { return mCategory; } |
49 | 49 | ||
50 | void setDescription( const QString& description ) | 50 | void setDescription( const QString& description ) |
51 | { mDesc = Qtopia::simplifyMultiLineSpace(description); } | 51 | { mDesc = Qtopia::simplifyMultiLineSpace(description); } |
52 | const QString &description() const { return mDesc; } | 52 | const QString &description() const { return mDesc; } |
53 | 53 | ||
54 | void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } | 54 | void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } |
55 | const QDate &dueDate() const { return mDueDate; } | 55 | const QDate &dueDate() const { return mDueDate; } |
56 | bool hasDueDate() const { return mDue; } | 56 | bool hasDueDate() const { return mDue; } |
57 | void setHasDueDate( bool b ) { mDue = b; } | 57 | void setHasDueDate( bool b ) { mDue = b; } |
58 | 58 | ||
59 | void setCompleted( bool b ) { mCompleted = b; } | 59 | void setCompleted( bool b ) { mCompleted = b; } |
60 | bool isCompleted() const { return mCompleted; } | 60 | bool isCompleted() const { return mCompleted; } |
61 | 61 | ||
62 | void save( QString& buf ) const; | 62 | void save( QString& buf ) const; |
63 | bool match( const QRegExp &r ) const; | 63 | bool match( const QRegExp &r ) const; |
64 | 64 | ||
65 | private: | 65 | private: |
66 | Qtopia::UidGen &uidGen() { return sUidGen; } | 66 | Qtopia::UidGen &uidGen() { return sUidGen; } |
67 | static Qtopia::UidGen sUidGen; | 67 | static Qtopia::UidGen sUidGen; |
68 | 68 | ||
69 | bool mDue; | 69 | bool mDue; |
70 | QDate mDueDate; | 70 | QDate mDueDate; |
71 | bool mCompleted; | 71 | bool mCompleted; |
72 | int mPriority; | 72 | int mPriority; |
73 | QString mDesc; | 73 | QString mDesc; |
74 | TaskPrivate *d; | 74 | TaskPrivate *d; |
75 | // ADDITION | ||
76 | int recordId; | ||
77 | int recordInfo; | ||
78 | // | ||
75 | }; | 79 | }; |
76 | 80 | ||
77 | #endif | 81 | #endif |
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index af112a7..9c2ba3b 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp | |||
@@ -1146,65 +1146,74 @@ static void writeProp(OFile *fp, VObject *o) | |||
1146 | writeValue(fp,o,size); | 1146 | writeValue(fp,o,size); |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | appendcOFile(fp,'\n'); | 1149 | appendcOFile(fp,'\n'); |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | static void writeVObject_(OFile *fp, VObject *o) | 1152 | static void writeVObject_(OFile *fp, VObject *o) |
1153 | { | 1153 | { |
1154 | if (NAME_OF(o)) { | 1154 | if (NAME_OF(o)) { |
1155 | struct PreDefProp *pi; | 1155 | struct PreDefProp *pi; |
1156 | pi = lookupPropInfo(NAME_OF(o)); | 1156 | pi = lookupPropInfo(NAME_OF(o)); |
1157 | 1157 | ||
1158 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { | 1158 | if (pi && ((pi->flags & PD_BEGIN) != 0)) { |
1159 | VObjectIterator t; | 1159 | VObjectIterator t; |
1160 | const char *begin = NAME_OF(o); | 1160 | const char *begin = NAME_OF(o); |
1161 | appendsOFile(fp,"BEGIN:"); | 1161 | appendsOFile(fp,"BEGIN:"); |
1162 | appendsOFile(fp,begin); | 1162 | appendsOFile(fp,begin); |
1163 | appendcOFile(fp,'\n'); | 1163 | appendcOFile(fp,'\n'); |
1164 | initPropIterator(&t,o); | 1164 | initPropIterator(&t,o); |
1165 | while (moreIteration(&t)) { | 1165 | while (moreIteration(&t)) { |
1166 | VObject *eachProp = nextVObject(&t); | 1166 | VObject *eachProp = nextVObject(&t); |
1167 | writeProp(fp, eachProp); | 1167 | writeProp(fp, eachProp); |
1168 | } | 1168 | } |
1169 | appendsOFile(fp,"END:"); | 1169 | appendsOFile(fp,"END:"); |
1170 | appendsOFile(fp,begin); | 1170 | appendsOFile(fp,begin); |
1171 | appendsOFile(fp,"\n\n"); | 1171 | appendsOFile(fp,"\n\n"); |
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | void writeVObject(FILE *fp, VObject *o) | 1176 | void writeVObject(FILE *fp, VObject *o) |
1177 | { | 1177 | { |
1178 | OFile ofp; | 1178 | OFile ofp; |
1179 | // ##### | 1179 | // ##### |
1180 | //_setmode(_fileno(fp), _O_BINARY); | 1180 | //_setmode(_fileno(fp), _O_BINARY); |
1181 | initOFile(&ofp,fp); | 1181 | initOFile(&ofp,fp); |
1182 | writeVObject_(&ofp,o); | 1182 | writeVObject_(&ofp,o); |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) | 1185 | DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) |
1186 | { | 1186 | { |
1187 | QFileDirect f( fname); | 1187 | QFileDirect f( fname); |
1188 | if ( !f.open( IO_WriteOnly ) ) { | 1188 | if ( !f.open( IO_WriteOnly ) ) { |
1189 | qWarning("Unable to open vobject write %s", fname); | 1189 | qWarning("Unable to open vobject write %s", fname); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | writeVObject( f.directHandle(),o ); | 1193 | writeVObject( f.directHandle(),o ); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) | 1196 | DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) |
1197 | { | 1197 | { |
1198 | QFileDirect f( fname); | 1198 | QFileDirect f( fname); |
1199 | if ( !f.open( IO_WriteOnly ) ) { | 1199 | if ( !f.open( IO_WriteOnly ) ) { |
1200 | qWarning("Unable to open vobject write %s", fname); | 1200 | qWarning("Unable to open vobject write %s", fname); |
1201 | return; | 1201 | return; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | while (list) { | 1204 | while (list) { |
1205 | writeVObject(f.directHandle(),list); | 1205 | writeVObject(f.directHandle(),list); |
1206 | list = nextVObjectInList(list); | 1206 | list = nextVObjectInList(list); |
1207 | } | 1207 | } |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) | ||
1211 | { | ||
1212 | const char *type = vObjectName( o ); | ||
1213 | if ( strcmp( type, "TYPE" ) == 0 ) | ||
1214 | type = vObjectStringZValue( o ); | ||
1215 | return type; | ||
1216 | } | ||
1217 | |||
1218 | |||
1210 | // end of source file vobject.c | 1219 | // end of source file vobject.c |
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h index b6a2c0a..a0d921e 100644 --- a/library/backend/vobject_p.h +++ b/library/backend/vobject_p.h | |||
@@ -335,67 +335,70 @@ extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list); | |||
335 | 335 | ||
336 | extern DLLEXPORT(int) vObjectValueType(VObject *o); | 336 | extern DLLEXPORT(int) vObjectValueType(VObject *o); |
337 | 337 | ||
338 | /* return type of vObjectValueType: */ | 338 | /* return type of vObjectValueType: */ |
339 | #define VCVT_NOVALUE0 | 339 | #define VCVT_NOVALUE0 |
340 | /* if the VObject has no value associated with it. */ | 340 | /* if the VObject has no value associated with it. */ |
341 | #define VCVT_STRINGZ1 | 341 | #define VCVT_STRINGZ1 |
342 | /* if the VObject has value set by setVObjectStringZValue. */ | 342 | /* if the VObject has value set by setVObjectStringZValue. */ |
343 | #define VCVT_UINT 2 | 343 | #define VCVT_UINT 2 |
344 | /* if the VObject has value set by setVObjectIntegerValue. */ | 344 | /* if the VObject has value set by setVObjectIntegerValue. */ |
345 | #define VCVT_ULONG 3 | 345 | #define VCVT_ULONG 3 |
346 | /* if the VObject has value set by setVObjectLongValue. */ | 346 | /* if the VObject has value set by setVObjectLongValue. */ |
347 | #define VCVT_RAW 4 | 347 | #define VCVT_RAW 4 |
348 | /* if the VObject has value set by setVObjectAnyValue. */ | 348 | /* if the VObject has value set by setVObjectAnyValue. */ |
349 | #define VCVT_VOBJECT5 | 349 | #define VCVT_VOBJECT5 |
350 | /* if the VObject has value set by setVObjectVObjectValue. */ | 350 | /* if the VObject has value set by setVObjectVObjectValue. */ |
351 | 351 | ||
352 | extern const char** fieldedProp; | 352 | extern const char** fieldedProp; |
353 | 353 | ||
354 | /*************************************************** | 354 | /*************************************************** |
355 | * The methods below are implemented in vcc.c (generated from vcc.y ) | 355 | * The methods below are implemented in vcc.c (generated from vcc.y ) |
356 | ***************************************************/ | 356 | ***************************************************/ |
357 | 357 | ||
358 | /* NOTE regarding printVObject and writeVObject | 358 | /* NOTE regarding printVObject and writeVObject |
359 | 359 | ||
360 | The functions below are not exported from the DLL because they | 360 | The functions below are not exported from the DLL because they |
361 | take a FILE* as a parameter, which cannot be passed across a DLL | 361 | take a FILE* as a parameter, which cannot be passed across a DLL |
362 | interface (at least that is my experience). Instead you can use | 362 | interface (at least that is my experience). Instead you can use |
363 | their companion functions which take file names or pointers | 363 | their companion functions which take file names or pointers |
364 | to memory. However, if you are linking this code into | 364 | to memory. However, if you are linking this code into |
365 | your build directly then you may find them a more convenient API | 365 | your build directly then you may find them a more convenient API |
366 | and you can go ahead and use them. If you try to use them with | 366 | and you can go ahead and use them. If you try to use them with |
367 | the DLL LIB you will get a link error. | 367 | the DLL LIB you will get a link error. |
368 | */ | 368 | */ |
369 | extern void writeVObject(FILE *fp, VObject *o); | 369 | extern void writeVObject(FILE *fp, VObject *o); |
370 | 370 | ||
371 | 371 | ||
372 | 372 | ||
373 | typedef void (*MimeErrorHandler)(char *); | 373 | typedef void (*MimeErrorHandler)(char *); |
374 | 374 | ||
375 | extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); | 375 | extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler); |
376 | 376 | ||
377 | extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); | 377 | extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len); |
378 | extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); | 378 | extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname); |
379 | 379 | ||
380 | 380 | ||
381 | /* NOTE regarding Parse_MIME_FromFile | 381 | /* NOTE regarding Parse_MIME_FromFile |
382 | The function above, Parse_MIME_FromFile, comes in two flavors, | 382 | The function above, Parse_MIME_FromFile, comes in two flavors, |
383 | neither of which is exported from the DLL. Each version takes | 383 | neither of which is exported from the DLL. Each version takes |
384 | a CFile or FILE* as a parameter, neither of which can be | 384 | a CFile or FILE* as a parameter, neither of which can be |
385 | passed across a DLL interface (at least that is my experience). | 385 | passed across a DLL interface (at least that is my experience). |
386 | If you are linking this code into your build directly then | 386 | If you are linking this code into your build directly then |
387 | you may find them a more convenient API that the other flavors | 387 | you may find them a more convenient API that the other flavors |
388 | that take a file name. If you use them with the DLL LIB you | 388 | that take a file name. If you use them with the DLL LIB you |
389 | will get a link error. | 389 | will get a link error. |
390 | */ | 390 | */ |
391 | 391 | ||
392 | 392 | ||
393 | #if INCLUDEMFC | 393 | #if INCLUDEMFC |
394 | extern VObject* Parse_MIME_FromFile(CFile *file); | 394 | extern VObject* Parse_MIME_FromFile(CFile *file); |
395 | #else | 395 | #else |
396 | extern VObject* Parse_MIME_FromFile(FILE *file); | 396 | extern VObject* Parse_MIME_FromFile(FILE *file); |
397 | #endif | 397 | #endif |
398 | 398 | ||
399 | extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o); | ||
400 | |||
401 | |||
399 | #endif /* __VOBJECT_H__ */ | 402 | #endif /* __VOBJECT_H__ */ |
400 | 403 | ||
401 | 404 | ||