summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp5
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kabc/addressee.cpp1
3 files changed, 5 insertions, 3 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 6e8d027..3ec0795 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -400,112 +400,113 @@ AddressBook::ConstIterator AddressBook::begin() const
400{ 400{
401 ConstIterator it = ConstIterator(); 401 ConstIterator it = ConstIterator();
402 it.d->mIt = d->mAddressees.begin(); 402 it.d->mIt = d->mAddressees.begin();
403 return it; 403 return it;
404} 404}
405 405
406AddressBook::Iterator AddressBook::end() 406AddressBook::Iterator AddressBook::end()
407{ 407{
408 Iterator it = Iterator(); 408 Iterator it = Iterator();
409 it.d->mIt = d->mAddressees.end(); 409 it.d->mIt = d->mAddressees.end();
410 return it; 410 return it;
411} 411}
412 412
413AddressBook::ConstIterator AddressBook::end() const 413AddressBook::ConstIterator AddressBook::end() const
414{ 414{
415 ConstIterator it = ConstIterator(); 415 ConstIterator it = ConstIterator();
416 it.d->mIt = d->mAddressees.end(); 416 it.d->mIt = d->mAddressees.end();
417 return it; 417 return it;
418} 418}
419 419
420void AddressBook::clear() 420void AddressBook::clear()
421{ 421{
422 d->mAddressees.clear(); 422 d->mAddressees.clear();
423} 423}
424 424
425Ticket *AddressBook::requestSaveTicket( Resource *resource ) 425Ticket *AddressBook::requestSaveTicket( Resource *resource )
426{ 426{
427 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 427 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
428 428
429 if ( !resource ) 429 if ( !resource )
430 { 430 {
431 qDebug("AddressBook::requestSaveTicket no resource" ); 431 qDebug("AddressBook::requestSaveTicket no resource" );
432 resource = standardResource(); 432 resource = standardResource();
433 } 433 }
434 434
435 KRES::Manager<Resource>::ActiveIterator it; 435 KRES::Manager<Resource>::ActiveIterator it;
436 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 436 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
437 if ( (*it) == resource ) { 437 if ( (*it) == resource ) {
438 if ( (*it)->readOnly() || !(*it)->isOpen() ) 438 if ( (*it)->readOnly() || !(*it)->isOpen() )
439 return 0; 439 return 0;
440 else 440 else
441 return (*it)->requestSaveTicket(); 441 return (*it)->requestSaveTicket();
442 } 442 }
443 } 443 }
444 444
445 return 0; 445 return 0;
446} 446}
447 447
448void AddressBook::insertAddressee( const Addressee &a ) 448void AddressBook::insertAddressee( const Addressee &a, bool setRev )
449{ 449{
450 Addressee::List::Iterator it; 450 Addressee::List::Iterator it;
451 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 451 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
452 if ( a.uid() == (*it).uid() ) { 452 if ( a.uid() == (*it).uid() ) {
453 bool changed = false; 453 bool changed = false;
454 Addressee addr = a; 454 Addressee addr = a;
455 if ( addr != (*it) ) 455 if ( addr != (*it) )
456 changed = true; 456 changed = true;
457 457
458 (*it) = a; 458 (*it) = a;
459 if ( (*it).resource() == 0 ) 459 if ( (*it).resource() == 0 )
460 (*it).setResource( standardResource() ); 460 (*it).setResource( standardResource() );
461 461
462 if ( changed ) { 462 if ( changed ) {
463 (*it).setRevision( QDateTime::currentDateTime() ); 463 if ( setRev )
464 (*it).setRevision( QDateTime::currentDateTime() );
464 (*it).setChanged( true ); 465 (*it).setChanged( true );
465 } 466 }
466 467
467 return; 468 return;
468 } 469 }
469 } 470 }
470 d->mAddressees.append( a ); 471 d->mAddressees.append( a );
471 Addressee& addr = d->mAddressees.last(); 472 Addressee& addr = d->mAddressees.last();
472 if ( addr.resource() == 0 ) 473 if ( addr.resource() == 0 )
473 addr.setResource( standardResource() ); 474 addr.setResource( standardResource() );
474 475
475 addr.setChanged( true ); 476 addr.setChanged( true );
476} 477}
477 478
478void AddressBook::removeAddressee( const Addressee &a ) 479void AddressBook::removeAddressee( const Addressee &a )
479{ 480{
480 Iterator it; 481 Iterator it;
481 for ( it = begin(); it != end(); ++it ) { 482 for ( it = begin(); it != end(); ++it ) {
482 if ( a.uid() == (*it).uid() ) { 483 if ( a.uid() == (*it).uid() ) {
483 removeAddressee( it ); 484 removeAddressee( it );
484 return; 485 return;
485 } 486 }
486 } 487 }
487} 488}
488 489
489void AddressBook::removeAddressee( const Iterator &it ) 490void AddressBook::removeAddressee( const Iterator &it )
490{ 491{
491 d->mRemovedAddressees.append( (*it) ); 492 d->mRemovedAddressees.append( (*it) );
492 d->mAddressees.remove( it.d->mIt ); 493 d->mAddressees.remove( it.d->mIt );
493} 494}
494 495
495AddressBook::Iterator AddressBook::find( const Addressee &a ) 496AddressBook::Iterator AddressBook::find( const Addressee &a )
496{ 497{
497 Iterator it; 498 Iterator it;
498 for ( it = begin(); it != end(); ++it ) { 499 for ( it = begin(); it != end(); ++it ) {
499 if ( a.uid() == (*it).uid() ) { 500 if ( a.uid() == (*it).uid() ) {
500 return it; 501 return it;
501 } 502 }
502 } 503 }
503 return end(); 504 return end();
504} 505}
505 506
506Addressee AddressBook::findByUid( const QString &uid ) 507Addressee AddressBook::findByUid( const QString &uid )
507{ 508{
508 Iterator it; 509 Iterator it;
509 for ( it = begin(); it != end(); ++it ) { 510 for ( it = begin(); it != end(); ++it ) {
510 if ( uid == (*it).uid() ) { 511 if ( uid == (*it).uid() ) {
511 return *it; 512 return *it;
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 650a638..253de68 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -128,97 +128,97 @@ class AddressBook : public QObject
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( ); 144 bool saveAB( );
145 145
146 /** 146 /**
147 Returns a iterator for first entry of address book. 147 Returns a iterator for first entry of address book.
148 */ 148 */
149 Iterator begin(); 149 Iterator begin();
150 150
151 /** 151 /**
152 Returns a const iterator for first entry of address book. 152 Returns a const iterator for first entry of address book.
153 */ 153 */
154 ConstIterator begin() const; 154 ConstIterator begin() const;
155 155
156 /** 156 /**
157 Returns a iterator for first entry of address book. 157 Returns a iterator for first entry of address book.
158 */ 158 */
159 Iterator end(); 159 Iterator end();
160 160
161 /** 161 /**
162 Returns a const iterator for first entry of address book. 162 Returns a const iterator for first entry of address book.
163 */ 163 */
164 ConstIterator end() const; 164 ConstIterator end() const;
165 165
166 /** 166 /**
167 Removes all entries from address book. 167 Removes all entries from address book.
168 */ 168 */
169 void clear(); 169 void clear();
170 170
171 /** 171 /**
172 Insert an Addressee object into address book. If an object with the same 172 Insert an Addressee object into address book. If an object with the same
173 unique id already exists in the address book it it replaced by the new 173 unique id already exists in the address book it it replaced by the new
174 one. If not the new object is appended to the address book. 174 one. If not the new object is appended to the address book.
175 */ 175 */
176 void insertAddressee( const Addressee & ); 176 void insertAddressee( const Addressee &, bool setRev = true );
177 177
178 /** 178 /**
179 Removes entry from the address book. 179 Removes entry from the address book.
180 */ 180 */
181 void removeAddressee( const Addressee & ); 181 void removeAddressee( const Addressee & );
182 182
183 /** 183 /**
184 This is like @ref removeAddressee() just above, with the difference that 184 This is like @ref removeAddressee() just above, with the difference that
185 the first element is a iterator, returned by @ref begin(). 185 the first element is a iterator, returned by @ref begin().
186 */ 186 */
187 void removeAddressee( const Iterator & ); 187 void removeAddressee( const Iterator & );
188 188
189 /** 189 /**
190 Find the specified entry in address book. Returns end(), if the entry 190 Find the specified entry in address book. Returns end(), if the entry
191 couldn't be found. 191 couldn't be found.
192 */ 192 */
193 Iterator find( const Addressee & ); 193 Iterator find( const Addressee & );
194 194
195 /** 195 /**
196 Find the entry specified by an unique id. Returns an empty Addressee 196 Find the entry specified by an unique id. Returns an empty Addressee
197 object, if the address book does not contain an entry with this id. 197 object, if the address book does not contain an entry with this id.
198 */ 198 */
199 Addressee findByUid( const QString & ); 199 Addressee findByUid( const QString & );
200 200
201 201
202 /** 202 /**
203 Returns a list of all addressees in the address book. This list can 203 Returns a list of all addressees in the address book. This list can
204 be sorted with @ref KABC::AddresseeList for example. 204 be sorted with @ref KABC::AddresseeList for example.
205 */ 205 */
206 Addressee::List allAddressees(); 206 Addressee::List allAddressees();
207 207
208 /** 208 /**
209 Find all entries with the specified name in the address book. Returns 209 Find all entries with the specified name in the address book. Returns
210 an empty list, if no entries could be found. 210 an empty list, if no entries could be found.
211 */ 211 */
212 Addressee::List findByName( const QString & ); 212 Addressee::List findByName( const QString & );
213 213
214 /** 214 /**
215 Find all entries with the specified email address in the address book. 215 Find all entries with the specified email address in the address book.
216 Returns an empty list, if no entries could be found. 216 Returns an empty list, if no entries could be found.
217 */ 217 */
218 Addressee::List findByEmail( const QString & ); 218 Addressee::List findByEmail( const QString & );
219 219
220 /** 220 /**
221 Find all entries wich have the specified category in the address book. 221 Find all entries wich have the specified category in the address book.
222 Returns an empty list, if no entries could be found. 222 Returns an empty list, if no entries could be found.
223 */ 223 */
224 Addressee::List findByCategory( const QString & ); 224 Addressee::List findByCategory( const QString & );
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index fb32f6e..7f04d8f 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -48,96 +48,97 @@ struct Addressee::AddresseeData : public KShared
48{ 48{
49 QString uid; 49 QString uid;
50 QString name; 50 QString name;
51 QString formattedName; 51 QString formattedName;
52 QString familyName; 52 QString familyName;
53 QString givenName; 53 QString givenName;
54 QString additionalName; 54 QString additionalName;
55 QString prefix; 55 QString prefix;
56 QString suffix; 56 QString suffix;
57 QString nickName; 57 QString nickName;
58 QDateTime birthday; 58 QDateTime birthday;
59 QString mailer; 59 QString mailer;
60 TimeZone timeZone; 60 TimeZone timeZone;
61 Geo geo; 61 Geo geo;
62 QString title; 62 QString title;
63 QString role; 63 QString role;
64 QString organization; 64 QString organization;
65 QString note; 65 QString note;
66 QString productId; 66 QString productId;
67 QDateTime revision; 67 QDateTime revision;
68 QString sortString; 68 QString sortString;
69 KURL url; 69 KURL url;
70 Secrecy secrecy; 70 Secrecy secrecy;
71 Picture logo; 71 Picture logo;
72 Picture photo; 72 Picture photo;
73 Sound sound; 73 Sound sound;
74 Agent agent; 74 Agent agent;
75 QString mExternalId; 75 QString mExternalId;
76 PhoneNumber::List phoneNumbers; 76 PhoneNumber::List phoneNumbers;
77 Address::List addresses; 77 Address::List addresses;
78 Key::List keys; 78 Key::List keys;
79 QStringList emails; 79 QStringList emails;
80 QStringList categories; 80 QStringList categories;
81 QStringList custom; 81 QStringList custom;
82 82
83 Resource *resource; 83 Resource *resource;
84 84
85 bool empty :1; 85 bool empty :1;
86 bool changed :1; 86 bool changed :1;
87}; 87};
88 88
89Addressee::Addressee() 89Addressee::Addressee()
90{ 90{
91 mData = new AddresseeData; 91 mData = new AddresseeData;
92 mData->empty = true; 92 mData->empty = true;
93 mData->changed = false; 93 mData->changed = false;
94 mData->resource = 0; 94 mData->resource = 0;
95 mData->mExternalId = ":"; 95 mData->mExternalId = ":";
96 mData->revision = QDateTime ( QDate( 2004,1,1));
96 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 97 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
97} 98}
98 99
99Addressee::~Addressee() 100Addressee::~Addressee()
100{ 101{
101} 102}
102 103
103Addressee::Addressee( const Addressee &a ) 104Addressee::Addressee( const Addressee &a )
104{ 105{
105 mData = a.mData; 106 mData = a.mData;
106 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 107 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
107} 108}
108 109
109Addressee &Addressee::operator=( const Addressee &a ) 110Addressee &Addressee::operator=( const Addressee &a )
110{ 111{
111 mData = a.mData; 112 mData = a.mData;
112 return (*this); 113 return (*this);
113} 114}
114 115
115Addressee Addressee::copy() 116Addressee Addressee::copy()
116{ 117{
117 Addressee a; 118 Addressee a;
118 *(a.mData) = *mData; 119 *(a.mData) = *mData;
119 return a; 120 return a;
120} 121}
121 122
122void Addressee::detach() 123void Addressee::detach()
123{ 124{
124 if ( mData.count() == 1 ) return; 125 if ( mData.count() == 1 ) return;
125 *this = copy(); 126 *this = copy();
126} 127}
127 128
128bool Addressee::operator==( const Addressee &a ) const 129bool Addressee::operator==( const Addressee &a ) const
129{ 130{
130 if ( uid() != a.uid() ) return false; 131 if ( uid() != a.uid() ) return false;
131 if ( mData->name != a.mData->name ) return false; 132 if ( mData->name != a.mData->name ) return false;
132 if ( mData->formattedName != a.mData->formattedName ) return false; 133 if ( mData->formattedName != a.mData->formattedName ) return false;
133 if ( mData->familyName != a.mData->familyName ) return false; 134 if ( mData->familyName != a.mData->familyName ) return false;
134 if ( mData->givenName != a.mData->givenName ) return false; 135 if ( mData->givenName != a.mData->givenName ) return false;
135 if ( mData->additionalName != a.mData->additionalName ) return false; 136 if ( mData->additionalName != a.mData->additionalName ) return false;
136 if ( mData->prefix != a.mData->prefix ) return false; 137 if ( mData->prefix != a.mData->prefix ) return false;
137 if ( mData->suffix != a.mData->suffix ) return false; 138 if ( mData->suffix != a.mData->suffix ) return false;
138 if ( mData->nickName != a.mData->nickName ) return false; 139 if ( mData->nickName != a.mData->nickName ) return false;
139 if ( mData->birthday != a.mData->birthday ) return false; 140 if ( mData->birthday != a.mData->birthday ) return false;
140 if ( mData->mailer != a.mData->mailer ) return false; 141 if ( mData->mailer != a.mData->mailer ) return false;
141 if ( mData->timeZone != a.mData->timeZone ) return false; 142 if ( mData->timeZone != a.mData->timeZone ) return false;
142 if ( mData->geo != a.mData->geo ) return false; 143 if ( mData->geo != a.mData->geo ) return false;
143 if ( mData->title != a.mData->title ) return false; 144 if ( mData->title != a.mData->title ) return false;