-rw-r--r-- | kabc/addressee.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d5a110a..3d4992c 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -84,314 +84,324 @@ struct Addressee::AddresseeData : public KShared | |||
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | l.append( t[iii] ); | 259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | ||
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | ||
262 | if ( find < t[iii].length()) | ||
263 | l.append( t[iii] ); | ||
264 | |||
265 | } | ||
260 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 268 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
264 | t.sort(); | 270 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
267 | } | 273 | } |
268 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
269 | //qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 275 | #if 1 |
276 | for ( iii = 0; iii < l.count(); ++iii) | ||
277 | qDebug("%d***%s***",iii,l[iii].latin1()); | ||
278 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | ||
279 | #endif | ||
270 | setCsum( dev, QString::number (cs )); | 280 | setCsum( dev, QString::number (cs )); |
271 | } | 281 | } |
272 | 282 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 283 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 284 | { |
275 | 285 | ||
276 | detach(); | 286 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 287 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 288 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 289 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 290 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 291 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 292 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 293 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 294 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 295 | if ( !mData->birthday.isValid() ) |
286 | if ( ad.mData->birthday.isValid()) | 296 | if ( ad.mData->birthday.isValid()) |
287 | mData->birthday = ad.mData->birthday; | 297 | mData->birthday = ad.mData->birthday; |
288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 298 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 299 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 300 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 301 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 302 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 303 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 304 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 305 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 306 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 307 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 308 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 309 | QStringList t; |
300 | QStringList tAD; | 310 | QStringList tAD; |
301 | uint iii; | 311 | uint iii; |
302 | 312 | ||
303 | // ********** phone numbers | 313 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 314 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 315 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 316 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 317 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 318 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 319 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 320 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 321 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | 322 | (*it).setType( ( *phoneItAD ).type() ); |
313 | (*it).setNumber( ( *phoneItAD ).number() ); | 323 | (*it).setNumber( ( *phoneItAD ).number() ); |
314 | break; | 324 | break; |
315 | } | 325 | } |
316 | } | 326 | } |
317 | if ( isSubSet && ! found ) | 327 | if ( isSubSet && ! found ) |
318 | mData->phoneNumbers.append( *phoneItAD ); | 328 | mData->phoneNumbers.append( *phoneItAD ); |
319 | } | 329 | } |
320 | if ( isSubSet ) { | 330 | if ( isSubSet ) { |
321 | // ************* emails; | 331 | // ************* emails; |
322 | t = mData->emails; | 332 | t = mData->emails; |
323 | tAD = ad.mData->emails; | 333 | tAD = ad.mData->emails; |
324 | for ( iii = 0; iii < tAD.count(); ++iii) | 334 | for ( iii = 0; iii < tAD.count(); ++iii) |
325 | if ( !t.contains(tAD[iii] ) ) | 335 | if ( !t.contains(tAD[iii] ) ) |
326 | mData->emails.append( tAD[iii] ); | 336 | mData->emails.append( tAD[iii] ); |
327 | } | 337 | } |
328 | 338 | ||
329 | // ************* categories; | 339 | // ************* categories; |
330 | t = mData->categories; | 340 | t = mData->categories; |
331 | tAD = ad.mData->categories; | 341 | tAD = ad.mData->categories; |
332 | for ( iii = 0; iii < tAD.count(); ++iii) | 342 | for ( iii = 0; iii < tAD.count(); ++iii) |
333 | if ( !t.contains(tAD[iii] ) ) | 343 | if ( !t.contains(tAD[iii] ) ) |
334 | mData->categories.append( tAD[iii] ); | 344 | mData->categories.append( tAD[iii] ); |
335 | QStringList::ConstIterator it; | 345 | QStringList::ConstIterator it; |
336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 346 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
337 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 347 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
338 | bool found = false; | 348 | bool found = false; |
339 | QStringList::ConstIterator itL; | 349 | QStringList::ConstIterator itL; |
340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 350 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
341 | if ( (*itL).startsWith( qualifiedName ) ) { | 351 | if ( (*itL).startsWith( qualifiedName ) ) { |
342 | found = true; | 352 | found = true; |
343 | break; | 353 | break; |
344 | } | 354 | } |
345 | } | 355 | } |
346 | if ( ! found ) { | 356 | if ( ! found ) { |
347 | mData->custom.append( *it ); | 357 | mData->custom.append( *it ); |
348 | } | 358 | } |
349 | } | 359 | } |
350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 360 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 361 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
352 | if ( !mData->sound.isIntern() ) { | 362 | if ( !mData->sound.isIntern() ) { |
353 | if ( mData->sound.url().isEmpty() ) { | 363 | if ( mData->sound.url().isEmpty() ) { |
354 | mData->sound = ad.mData->sound; | 364 | mData->sound = ad.mData->sound; |
355 | } | 365 | } |
356 | } | 366 | } |
357 | if ( !mData->agent.isIntern() ) { | 367 | if ( !mData->agent.isIntern() ) { |
358 | if ( mData->agent.url().isEmpty() ) { | 368 | if ( mData->agent.url().isEmpty() ) { |
359 | mData->agent = ad.mData->agent; | 369 | mData->agent = ad.mData->agent; |
360 | } | 370 | } |
361 | } | 371 | } |
362 | { | 372 | { |
363 | Key::List::Iterator itA; | 373 | Key::List::Iterator itA; |
364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 374 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
365 | bool found = false; | 375 | bool found = false; |
366 | Key::List::Iterator it; | 376 | Key::List::Iterator it; |
367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 377 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
368 | if ( (*it) == (*itA)) { | 378 | if ( (*it) == (*itA)) { |
369 | found = true; | 379 | found = true; |
370 | break; | 380 | break; |
371 | 381 | ||
372 | } | 382 | } |
373 | } | 383 | } |
374 | if ( ! found ) { | 384 | if ( ! found ) { |
375 | mData->keys.append( *itA ); | 385 | mData->keys.append( *itA ); |
376 | } | 386 | } |
377 | } | 387 | } |
378 | } | 388 | } |
379 | KABC::Address::List::Iterator addressIterA; | 389 | KABC::Address::List::Iterator addressIterA; |
380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 390 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
381 | bool found = false; | 391 | bool found = false; |
382 | KABC::Address::List::Iterator addressIter; | 392 | KABC::Address::List::Iterator addressIter; |
383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 393 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
384 | ++addressIter ) { | 394 | ++addressIter ) { |
385 | if ( (*addressIter) == (*addressIterA)) { | 395 | if ( (*addressIter) == (*addressIterA)) { |
386 | found = true; | 396 | found = true; |
387 | (*addressIter).setType( (*addressIterA).type() ); | 397 | (*addressIter).setType( (*addressIterA).type() ); |
388 | break; | 398 | break; |
389 | } | 399 | } |
390 | 400 | ||
391 | } | 401 | } |
392 | if ( isSubSet && ! found ) { | 402 | if ( isSubSet && ! found ) { |
393 | mData->addresses.append( *addressIterA ); | 403 | mData->addresses.append( *addressIterA ); |
394 | } | 404 | } |
395 | } | 405 | } |
396 | //qDebug("merge contact %s ", ad.uid().latin1()); | 406 | //qDebug("merge contact %s ", ad.uid().latin1()); |
397 | setUid( ad.uid() ); | 407 | setUid( ad.uid() ); |
@@ -986,257 +996,260 @@ TimeZone Addressee::timeZone() const | |||
986 | return mData->timeZone; | 996 | return mData->timeZone; |
987 | } | 997 | } |
988 | 998 | ||
989 | QString Addressee::timeZoneLabel() | 999 | QString Addressee::timeZoneLabel() |
990 | { | 1000 | { |
991 | return i18n("Time Zone"); | 1001 | return i18n("Time Zone"); |
992 | } | 1002 | } |
993 | 1003 | ||
994 | 1004 | ||
995 | void Addressee::setGeo( const Geo &geo ) | 1005 | void Addressee::setGeo( const Geo &geo ) |
996 | { | 1006 | { |
997 | if ( geo == mData->geo ) return; | 1007 | if ( geo == mData->geo ) return; |
998 | detach(); | 1008 | detach(); |
999 | mData->empty = false; | 1009 | mData->empty = false; |
1000 | mData->geo = geo; | 1010 | mData->geo = geo; |
1001 | } | 1011 | } |
1002 | 1012 | ||
1003 | Geo Addressee::geo() const | 1013 | Geo Addressee::geo() const |
1004 | { | 1014 | { |
1005 | return mData->geo; | 1015 | return mData->geo; |
1006 | } | 1016 | } |
1007 | 1017 | ||
1008 | QString Addressee::geoLabel() | 1018 | QString Addressee::geoLabel() |
1009 | { | 1019 | { |
1010 | return i18n("Geographic Position"); | 1020 | return i18n("Geographic Position"); |
1011 | } | 1021 | } |
1012 | 1022 | ||
1013 | 1023 | ||
1014 | void Addressee::setTitle( const QString &title ) | 1024 | void Addressee::setTitle( const QString &title ) |
1015 | { | 1025 | { |
1016 | if ( title == mData->title ) return; | 1026 | if ( title == mData->title ) return; |
1017 | detach(); | 1027 | detach(); |
1018 | mData->empty = false; | 1028 | mData->empty = false; |
1019 | mData->title = title; | 1029 | mData->title = title; |
1020 | } | 1030 | } |
1021 | 1031 | ||
1022 | QString Addressee::title() const | 1032 | QString Addressee::title() const |
1023 | { | 1033 | { |
1024 | return mData->title; | 1034 | return mData->title; |
1025 | } | 1035 | } |
1026 | 1036 | ||
1027 | QString Addressee::titleLabel() | 1037 | QString Addressee::titleLabel() |
1028 | { | 1038 | { |
1029 | return i18n("Title"); | 1039 | return i18n("Title"); |
1030 | } | 1040 | } |
1031 | 1041 | ||
1032 | 1042 | ||
1033 | void Addressee::setRole( const QString &role ) | 1043 | void Addressee::setRole( const QString &role ) |
1034 | { | 1044 | { |
1035 | if ( role == mData->role ) return; | 1045 | if ( role == mData->role ) return; |
1036 | detach(); | 1046 | detach(); |
1037 | mData->empty = false; | 1047 | mData->empty = false; |
1038 | mData->role = role; | 1048 | mData->role = role; |
1039 | } | 1049 | } |
1040 | 1050 | ||
1041 | QString Addressee::role() const | 1051 | QString Addressee::role() const |
1042 | { | 1052 | { |
1043 | return mData->role; | 1053 | return mData->role; |
1044 | } | 1054 | } |
1045 | 1055 | ||
1046 | QString Addressee::roleLabel() | 1056 | QString Addressee::roleLabel() |
1047 | { | 1057 | { |
1048 | return i18n("Role"); | 1058 | return i18n("Role"); |
1049 | } | 1059 | } |
1050 | 1060 | ||
1051 | 1061 | ||
1052 | void Addressee::setOrganization( const QString &organization ) | 1062 | void Addressee::setOrganization( const QString &organization ) |
1053 | { | 1063 | { |
1054 | if ( organization == mData->organization ) return; | 1064 | if ( organization == mData->organization ) return; |
1055 | detach(); | 1065 | detach(); |
1056 | mData->empty = false; | 1066 | mData->empty = false; |
1057 | mData->organization = organization; | 1067 | mData->organization = organization; |
1058 | } | 1068 | } |
1059 | 1069 | ||
1060 | QString Addressee::organization() const | 1070 | QString Addressee::organization() const |
1061 | { | 1071 | { |
1062 | return mData->organization; | 1072 | return mData->organization; |
1063 | } | 1073 | } |
1064 | 1074 | ||
1065 | QString Addressee::organizationLabel() | 1075 | QString Addressee::organizationLabel() |
1066 | { | 1076 | { |
1067 | return i18n("Organization"); | 1077 | return i18n("Organization"); |
1068 | } | 1078 | } |
1069 | 1079 | ||
1070 | 1080 | ||
1071 | void Addressee::setNote( const QString ¬e ) | 1081 | void Addressee::setNote( const QString ¬e ) |
1072 | { | 1082 | { |
1073 | if ( note == mData->note ) return; | 1083 | if ( note == mData->note ) return; |
1074 | detach(); | 1084 | detach(); |
1075 | mData->empty = false; | 1085 | mData->empty = false; |
1076 | mData->note = note; | 1086 | mData->note = note; |
1077 | } | 1087 | } |
1078 | 1088 | ||
1079 | QString Addressee::note() const | 1089 | QString Addressee::note() const |
1080 | { | 1090 | { |
1081 | return mData->note; | 1091 | return mData->note; |
1082 | } | 1092 | } |
1083 | 1093 | ||
1084 | QString Addressee::noteLabel() | 1094 | QString Addressee::noteLabel() |
1085 | { | 1095 | { |
1086 | return i18n("Note"); | 1096 | return i18n("Note"); |
1087 | } | 1097 | } |
1088 | 1098 | ||
1089 | 1099 | ||
1090 | void Addressee::setProductId( const QString &productId ) | 1100 | void Addressee::setProductId( const QString &productId ) |
1091 | { | 1101 | { |
1092 | if ( productId == mData->productId ) return; | 1102 | if ( productId == mData->productId ) return; |
1093 | detach(); | 1103 | detach(); |
1094 | mData->empty = false; | 1104 | mData->empty = false; |
1095 | mData->productId = productId; | 1105 | mData->productId = productId; |
1096 | } | 1106 | } |
1097 | 1107 | ||
1098 | QString Addressee::productId() const | 1108 | QString Addressee::productId() const |
1099 | { | 1109 | { |
1100 | return mData->productId; | 1110 | return mData->productId; |
1101 | } | 1111 | } |
1102 | 1112 | ||
1103 | QString Addressee::productIdLabel() | 1113 | QString Addressee::productIdLabel() |
1104 | { | 1114 | { |
1105 | return i18n("Product Identifier"); | 1115 | return i18n("Product Identifier"); |
1106 | } | 1116 | } |
1107 | 1117 | ||
1108 | 1118 | ||
1109 | void Addressee::setRevision( const QDateTime &revision ) | 1119 | void Addressee::setRevision( const QDateTime &revision ) |
1110 | { | 1120 | { |
1111 | if ( revision == mData->revision ) return; | 1121 | if ( revision == mData->revision ) return; |
1112 | detach(); | 1122 | detach(); |
1113 | mData->empty = false; | 1123 | mData->empty = false; |
1114 | mData->revision = revision; | 1124 | mData->revision = QDateTime( revision.date(), |
1125 | QTime (revision.time().hour(), | ||
1126 | revision.time().minute(), | ||
1127 | revision.time().second())); | ||
1115 | } | 1128 | } |
1116 | 1129 | ||
1117 | QDateTime Addressee::revision() const | 1130 | QDateTime Addressee::revision() const |
1118 | { | 1131 | { |
1119 | return mData->revision; | 1132 | return mData->revision; |
1120 | } | 1133 | } |
1121 | 1134 | ||
1122 | QString Addressee::revisionLabel() | 1135 | QString Addressee::revisionLabel() |
1123 | { | 1136 | { |
1124 | return i18n("Revision Date"); | 1137 | return i18n("Revision Date"); |
1125 | } | 1138 | } |
1126 | 1139 | ||
1127 | 1140 | ||
1128 | void Addressee::setSortString( const QString &sortString ) | 1141 | void Addressee::setSortString( const QString &sortString ) |
1129 | { | 1142 | { |
1130 | if ( sortString == mData->sortString ) return; | 1143 | if ( sortString == mData->sortString ) return; |
1131 | detach(); | 1144 | detach(); |
1132 | mData->empty = false; | 1145 | mData->empty = false; |
1133 | mData->sortString = sortString; | 1146 | mData->sortString = sortString; |
1134 | } | 1147 | } |
1135 | 1148 | ||
1136 | QString Addressee::sortString() const | 1149 | QString Addressee::sortString() const |
1137 | { | 1150 | { |
1138 | return mData->sortString; | 1151 | return mData->sortString; |
1139 | } | 1152 | } |
1140 | 1153 | ||
1141 | QString Addressee::sortStringLabel() | 1154 | QString Addressee::sortStringLabel() |
1142 | { | 1155 | { |
1143 | return i18n("Sort String"); | 1156 | return i18n("Sort String"); |
1144 | } | 1157 | } |
1145 | 1158 | ||
1146 | 1159 | ||
1147 | void Addressee::setUrl( const KURL &url ) | 1160 | void Addressee::setUrl( const KURL &url ) |
1148 | { | 1161 | { |
1149 | if ( url == mData->url ) return; | 1162 | if ( url == mData->url ) return; |
1150 | detach(); | 1163 | detach(); |
1151 | mData->empty = false; | 1164 | mData->empty = false; |
1152 | mData->url = url; | 1165 | mData->url = url; |
1153 | } | 1166 | } |
1154 | 1167 | ||
1155 | KURL Addressee::url() const | 1168 | KURL Addressee::url() const |
1156 | { | 1169 | { |
1157 | return mData->url; | 1170 | return mData->url; |
1158 | } | 1171 | } |
1159 | 1172 | ||
1160 | QString Addressee::urlLabel() | 1173 | QString Addressee::urlLabel() |
1161 | { | 1174 | { |
1162 | return i18n("URL"); | 1175 | return i18n("URL"); |
1163 | } | 1176 | } |
1164 | 1177 | ||
1165 | 1178 | ||
1166 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1179 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1167 | { | 1180 | { |
1168 | if ( secrecy == mData->secrecy ) return; | 1181 | if ( secrecy == mData->secrecy ) return; |
1169 | detach(); | 1182 | detach(); |
1170 | mData->empty = false; | 1183 | mData->empty = false; |
1171 | mData->secrecy = secrecy; | 1184 | mData->secrecy = secrecy; |
1172 | } | 1185 | } |
1173 | 1186 | ||
1174 | Secrecy Addressee::secrecy() const | 1187 | Secrecy Addressee::secrecy() const |
1175 | { | 1188 | { |
1176 | return mData->secrecy; | 1189 | return mData->secrecy; |
1177 | } | 1190 | } |
1178 | 1191 | ||
1179 | QString Addressee::secrecyLabel() | 1192 | QString Addressee::secrecyLabel() |
1180 | { | 1193 | { |
1181 | return i18n("Security Class"); | 1194 | return i18n("Security Class"); |
1182 | } | 1195 | } |
1183 | 1196 | ||
1184 | 1197 | ||
1185 | void Addressee::setLogo( const Picture &logo ) | 1198 | void Addressee::setLogo( const Picture &logo ) |
1186 | { | 1199 | { |
1187 | if ( logo == mData->logo ) return; | 1200 | if ( logo == mData->logo ) return; |
1188 | detach(); | 1201 | detach(); |
1189 | mData->empty = false; | 1202 | mData->empty = false; |
1190 | mData->logo = logo; | 1203 | mData->logo = logo; |
1191 | } | 1204 | } |
1192 | 1205 | ||
1193 | Picture Addressee::logo() const | 1206 | Picture Addressee::logo() const |
1194 | { | 1207 | { |
1195 | return mData->logo; | 1208 | return mData->logo; |
1196 | } | 1209 | } |
1197 | 1210 | ||
1198 | QString Addressee::logoLabel() | 1211 | QString Addressee::logoLabel() |
1199 | { | 1212 | { |
1200 | return i18n("Logo"); | 1213 | return i18n("Logo"); |
1201 | } | 1214 | } |
1202 | 1215 | ||
1203 | 1216 | ||
1204 | void Addressee::setPhoto( const Picture &photo ) | 1217 | void Addressee::setPhoto( const Picture &photo ) |
1205 | { | 1218 | { |
1206 | if ( photo == mData->photo ) return; | 1219 | if ( photo == mData->photo ) return; |
1207 | detach(); | 1220 | detach(); |
1208 | mData->empty = false; | 1221 | mData->empty = false; |
1209 | mData->photo = photo; | 1222 | mData->photo = photo; |
1210 | } | 1223 | } |
1211 | 1224 | ||
1212 | Picture Addressee::photo() const | 1225 | Picture Addressee::photo() const |
1213 | { | 1226 | { |
1214 | return mData->photo; | 1227 | return mData->photo; |
1215 | } | 1228 | } |
1216 | 1229 | ||
1217 | QString Addressee::photoLabel() | 1230 | QString Addressee::photoLabel() |
1218 | { | 1231 | { |
1219 | return i18n("Photo"); | 1232 | return i18n("Photo"); |
1220 | } | 1233 | } |
1221 | 1234 | ||
1222 | 1235 | ||
1223 | void Addressee::setSound( const Sound &sound ) | 1236 | void Addressee::setSound( const Sound &sound ) |
1224 | { | 1237 | { |
1225 | if ( sound == mData->sound ) return; | 1238 | if ( sound == mData->sound ) return; |
1226 | detach(); | 1239 | detach(); |
1227 | mData->empty = false; | 1240 | mData->empty = false; |
1228 | mData->sound = sound; | 1241 | mData->sound = sound; |
1229 | } | 1242 | } |
1230 | 1243 | ||
1231 | Sound Addressee::sound() const | 1244 | Sound Addressee::sound() const |
1232 | { | 1245 | { |
1233 | return mData->sound; | 1246 | return mData->sound; |
1234 | } | 1247 | } |
1235 | 1248 | ||
1236 | QString Addressee::soundLabel() | 1249 | QString Addressee::soundLabel() |
1237 | { | 1250 | { |
1238 | return i18n("Sound"); | 1251 | return i18n("Sound"); |
1239 | } | 1252 | } |
1240 | 1253 | ||
1241 | 1254 | ||
1242 | void Addressee::setAgent( const Agent &agent ) | 1255 | void Addressee::setAgent( const Agent &agent ) |