summaryrefslogtreecommitdiff
path: root/library/backend
Unidiff
Diffstat (limited to 'library/backend') (more/less context) (show whitespace changes)
-rw-r--r--library/backend/categories.cpp142
-rw-r--r--library/backend/categories.h12
-rw-r--r--library/backend/contact.cpp79
-rw-r--r--library/backend/contact.h7
-rw-r--r--library/backend/event.h5
-rw-r--r--library/backend/recordfields.h44
-rw-r--r--library/backend/task.h4
-rw-r--r--library/backend/vobject.cpp9
-rw-r--r--library/backend/vobject_p.h3
9 files changed, 165 insertions, 140 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
@@ -173,32 +173,2 @@ QStringList CategoryGroup::labels(const QArray<int> &catids ) const
173 173
174QArray<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
193QArray<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/***********************************************************
@@ -345,2 +315,10 @@ QStringList Categories::labels( const QString &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 ) {
@@ -358,10 +336,3 @@ QStringList Categories::labels( const QString &app,
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;
@@ -380,10 +351,2 @@ QString Categories::label( const QString &app, int id ) const
380 351
381QStringList 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
@@ -419,29 +382,17 @@ QString Categories::displaySingle( const QString &app,
419 382
420QArray<int> Categories::ids( const QString &app ) const 383QArray<int> Categories::ids( const QString &app, const QStringList &labels) const
421{ 384{
422 QArray<int> allIds = mGlobalCats.ids(); 385 QArray<int> results;
423 QArray<int> appIds = mAppCats[app].ids(); 386 QStringList::ConstIterator it;
424 387 int i;
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 388
433 return appIds; 389 for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) {
390 int value = id( app, *it );
391 if ( value != 0 ) {
392 int tmp = results.size();
393 results.resize( tmp + 1 );
394 results[ tmp ] = value;
434} 395}
435 396 }
436QArray<int> Categories::ids( const QString &app, const QStringList &cats ) const 397 return results;
437{
438 QArray<int> allIds = mGlobalCats.ids( cats );
439 QArray<int> appIds = mAppCats[app].ids( cats );
440
441 uint appSize = appIds.size();
442 appIds.resize( appSize + allIds.size() );
443 for ( uint i = appSize; i < appIds.size(); ++i )
444 appIds[int(i)] = allIds[int(i - appSize)];
445
446 return appIds;
447} 398}
@@ -541,6 +492,11 @@ bool Categories::exists( const QString &appname,
541 492
493
542bool Categories::save( const QString &fname ) const 494bool 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());
@@ -549,11 +505,11 @@ bool Categories::save( const QString &fname ) const
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
@@ -565,9 +521,24 @@ bool Categories::save( const QString &fname ) const
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;
@@ -580,2 +551,7 @@ bool Categories::load( const QString &fname )
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;
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
@@ -73,4 +73,3 @@ public:
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;
@@ -132,5 +131,4 @@ public:
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 */
@@ -155,6 +153,2 @@ public:
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 };
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
@@ -20,2 +20,4 @@
20 20
21#define QTOPIA_INTERNAL_CONTACT_MRE
22
21#include "contact.h" 23#include "contact.h"
@@ -388,2 +390,9 @@ QStringList Contact::fields()
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" );
@@ -391,7 +400,2 @@ QStringList Contact::fields()
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" );
@@ -399,5 +403,3 @@ QStringList Contact::fields()
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" );
@@ -407,10 +409,6 @@ QStringList Contact::fields()
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" );
@@ -419,2 +417,9 @@ QStringList Contact::fields()
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" );
@@ -424,5 +429,6 @@ QStringList Contact::fields()
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
@@ -442,2 +448,9 @@ QStringList Contact::trfields()
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" ) );
@@ -445,7 +458,2 @@ QStringList Contact::trfields()
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" ) );
@@ -453,5 +461,3 @@ QStringList Contact::trfields()
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" ) );
@@ -461,10 +467,6 @@ QStringList Contact::trfields()
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" ) );
@@ -473,2 +475,9 @@ QStringList Contact::trfields()
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" ) );
@@ -478,5 +487,6 @@ QStringList Contact::trfields()
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
@@ -631,3 +641,3 @@ static Contact parseVObject( VObject *obj )
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 );
@@ -704,3 +714,3 @@ static Contact parseVObject( VObject *obj )
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 )
@@ -751,3 +761,3 @@ static Contact parseVObject( VObject *obj )
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 &&
@@ -774,3 +784,3 @@ static Contact parseVObject( VObject *obj )
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 )
@@ -896,2 +906,7 @@ QValueList<Contact> Contact::readVCard( const QString &filename )
896 906
907bool Contact::match( const QString &regexp ) const
908{
909 return match(QRegExp(regexp));
910}
911
897bool Contact::match( const QRegExp &r ) const 912bool Contact::match( const QRegExp &r ) const
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
@@ -103,3 +103,8 @@ public:
103 103
104 bool match( const QRegExp &r ) const; 104 bool match( const QString &regexp ) const;
105
106// DON'T ATTEMPT TO USE THIS
107#ifdef QTOPIA_INTERNAL_CONTACT_MRE
108 bool match( const QRegExp &regexp ) const;
109#endif
105 110
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
@@ -142,3 +142,8 @@ private:
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};
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
@@ -34,2 +34,4 @@ namespace Qtopia
34 34
35 // NOTE: Order of fields dependency in backend/contact.cpp
36
35 Title, 37 Title,
@@ -41,2 +43,9 @@ namespace Qtopia
41 43
44 JobTitle,
45 Department,
46 Company,
47 BusinessPhone,
48 BusinessFax,
49 BusinessMobile,
50
42 // email 51 // email
@@ -45,8 +54,2 @@ namespace Qtopia
45 54
46 // home
47 HomeStreet,
48 HomeCity,
49 HomeState,
50 HomeZip,
51 HomeCountry,
52 HomePhone, 55 HomePhone,
@@ -54,6 +57,4 @@ namespace Qtopia
54 HomeMobile, 57 HomeMobile,
55 HomeWebPage,
56 58
57 // business 59 // business
58 Company,
59 BusinessStreet, 60 BusinessStreet,
@@ -63,10 +64,6 @@ namespace Qtopia
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,
@@ -75,2 +72,10 @@ namespace Qtopia
75 72
73 // home
74 HomeStreet,
75 HomeCity,
76 HomeState,
77 HomeZip,
78 HomeCountry,
79 HomeWebPage,
80
76 //personal 81 //personal
@@ -86,2 +91,5 @@ namespace Qtopia
86 Groups 91 Groups
92
93 ,rid,
94 rinfo
87 }; 95 };
@@ -97,3 +105,6 @@ namespace Qtopia
97 Priority, 105 Priority,
98 Date 106 Date,
107
108 TaskRid,
109 TaskRinfo
99 }; 110 };
@@ -130,2 +141,5 @@ namespace Qtopia
130 RepeatPatternEndDate, 141 RepeatPatternEndDate,
142
143 DateBookRid,
144 DateBookRinfo
131 }; 145 };
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
@@ -74,2 +74,6 @@ private:
74 TaskPrivate *d; 74 TaskPrivate *d;
75 // ADDITION
76 int recordId;
77 int recordInfo;
78 //
75}; 79};
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
@@ -1209,2 +1209,11 @@ DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
1209 1209
1210DLLEXPORT(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
@@ -398,2 +398,5 @@ extern VObject* Parse_MIME_FromFile(FILE *file);
398 398
399extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o);
400
401
399#endif /* __VOBJECT_H__ */ 402#endif /* __VOBJECT_H__ */