author | zautrix <zautrix> | 2005-01-18 14:09:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-18 14:09:00 (UTC) |
commit | ced210b0c4643ddac6a2e80eab4c85c1994b20e0 (patch) (unidiff) | |
tree | 5126b599b1213553ae71512a400f46d7b2037d92 | |
parent | 4b82a36d1b2479dd2e6f00aef45af848f6793099 (diff) | |
download | kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.zip kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.gz kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.bz2 |
ab sync fixes
-rw-r--r-- | kabc/addressee.cpp | 31 | ||||
-rw-r--r-- | kaddressbook/imagewidget.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 2 |
4 files changed, 38 insertions, 7 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index bfcfab5..18b4d58 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -151,178 +151,203 @@ bool Addressee::operator==( const Addressee &a ) const | |||
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 | //qDebug("csum: %d %d %d", i,k,cSum); | ||
199 | } | 200 | } |
200 | } | 201 | } |
201 | 202 | ||
202 | } | 203 | } |
203 | //QString dump = attList.join(","); | 204 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 205 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 206 | ||
206 | return cSum; | 207 | return cSum; |
207 | 208 | ||
208 | } | 209 | } |
209 | void Addressee::computeCsum(const QString &dev) | 210 | void Addressee::computeCsum(const QString &dev) |
210 | { | 211 | { |
211 | QStringList l; | 212 | QStringList l; |
212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 213 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 214 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 215 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 216 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 217 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 218 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 219 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 220 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 221 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 222 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 223 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 224 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 225 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 226 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 227 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 228 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 229 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 230 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 231 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 232 | if ( !mData->logo.undefined() ) { |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 233 | if ( !mData->logo.isIntern() ) |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 234 | l.append( mData->logo.url() ); |
235 | else | ||
236 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); | ||
237 | } else { | ||
238 | l.append( "nologo"); | ||
239 | } | ||
240 | if ( !mData->photo.undefined() ) { | ||
241 | if ( !mData->photo.isIntern() ) | ||
242 | l.append( mData->photo.url() ); | ||
243 | else | ||
244 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); | ||
245 | } else { | ||
246 | l.append( "nophoto"); | ||
247 | } | ||
248 | #if 0 | ||
249 | if ( !mData->sound.undefined() ) { | ||
250 | if ( !mData->sound.isIntern() ) | ||
251 | l.append( mData->sound.url() ); | ||
252 | else | ||
253 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); | ||
254 | } else { | ||
255 | l.append( "nosound"); | ||
256 | } | ||
257 | #endif | ||
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 258 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 259 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 260 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 261 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 262 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 263 | ||
240 | QStringList t; | 264 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 265 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 266 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 267 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 268 | t.sort(); |
245 | uint iii; | 269 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 270 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 271 | l.append( t[iii] ); |
248 | t = mData->emails; | 272 | t = mData->emails; |
249 | t.sort(); | 273 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 274 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 275 | l.append( t[iii] ); |
252 | t = mData->categories; | 276 | t = mData->categories; |
253 | t.sort(); | 277 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 278 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 279 | l.append( t[iii] ); |
256 | t = mData->custom; | 280 | t = mData->custom; |
257 | t.sort(); | 281 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 282 | for ( iii = 0; iii < t.count(); ++iii) |
259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 283 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | 284 | int find = t[iii].find (':')+1; |
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 285 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
262 | if ( find < t[iii].length()) | 286 | if ( find < t[iii].length()) |
263 | l.append( t[iii] ); | 287 | l.append( t[iii] ); |
264 | 288 | ||
265 | } | 289 | } |
266 | KABC::Address::List::Iterator addressIter; | 290 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 291 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 292 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 293 | t = (*addressIter).asList(); |
270 | t.sort(); | 294 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 295 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 296 | l.append( t[iii] ); |
273 | } | 297 | } |
274 | uint cs = getCsum4List(l); | 298 | uint cs = getCsum4List(l); |
275 | 299 | ||
276 | #if 0 | 300 | #if 0 |
277 | for ( iii = 0; iii < l.count(); ++iii) | 301 | for ( iii = 0; iii < l.count(); ++iii) |
278 | qDebug("%d***%s***",iii,l[iii].latin1()); | 302 | qDebug("%d***%s***",iii,l[iii].latin1()); |
279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 303 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
280 | #endif | 304 | #endif |
305 | |||
281 | 306 | ||
282 | setCsum( dev, QString::number (cs )); | 307 | setCsum( dev, QString::number (cs )); |
283 | } | 308 | } |
284 | 309 | ||
285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 310 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
286 | { | 311 | { |
287 | // merge all standard non-outlook fields. | 312 | // merge all standard non-outlook fields. |
288 | //if isSubSet (e.g. mobile phone sync) merge all fields | 313 | //if isSubSet (e.g. mobile phone sync) merge all fields |
289 | 314 | ||
290 | detach(); | 315 | detach(); |
291 | if ( isSubSet ) { | 316 | if ( isSubSet ) { |
292 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 317 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
293 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 318 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
294 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 319 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
295 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 320 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
296 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 321 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
297 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 322 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
298 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 323 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
299 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 324 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
300 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 325 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
301 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 326 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
302 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 327 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
303 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 328 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
304 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 329 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
305 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 330 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
306 | if ( !mData->birthday.isValid() ) | 331 | if ( !mData->birthday.isValid() ) |
307 | if ( ad.mData->birthday.isValid()) | 332 | if ( ad.mData->birthday.isValid()) |
308 | mData->birthday = ad.mData->birthday; | 333 | mData->birthday = ad.mData->birthday; |
309 | 334 | ||
310 | } | 335 | } |
311 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 336 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
312 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 337 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
313 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 338 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
314 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 339 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
315 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 340 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
316 | QStringList t; | 341 | QStringList t; |
317 | QStringList tAD; | 342 | QStringList tAD; |
318 | uint iii; | 343 | uint iii; |
319 | 344 | ||
320 | // ********** phone numbers | 345 | // ********** phone numbers |
321 | if ( isSubSet ) { | 346 | if ( isSubSet ) { |
322 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 347 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
323 | PhoneNumber::List::Iterator phoneItAD; | 348 | PhoneNumber::List::Iterator phoneItAD; |
324 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 349 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
325 | bool found = false; | 350 | bool found = false; |
326 | PhoneNumber::List::Iterator it; | 351 | PhoneNumber::List::Iterator it; |
327 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 352 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
328 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 353 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 1e9743c..d0f52ea 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -194,98 +194,99 @@ KABC::Picture ImageWidget::photo() const | |||
194 | #endif //KAB_EMBEDDED | 194 | #endif //KAB_EMBEDDED |
195 | 195 | ||
196 | photo.setType( "PNG" ); | 196 | photo.setType( "PNG" ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | return photo; | 200 | return photo; |
201 | } | 201 | } |
202 | 202 | ||
203 | void ImageWidget::setLogo( const KABC::Picture &logo ) | 203 | void ImageWidget::setLogo( const KABC::Picture &logo ) |
204 | { | 204 | { |
205 | bool blocked = signalsBlocked(); | 205 | bool blocked = signalsBlocked(); |
206 | blockSignals( true ); | 206 | blockSignals( true ); |
207 | 207 | ||
208 | if ( logo.isIntern() ) { | 208 | if ( logo.isIntern() ) { |
209 | //US | 209 | //US |
210 | //US mLogoLabel->setPixmap( logo.data() ); | 210 | //US mLogoLabel->setPixmap( logo.data() ); |
211 | if (logo.data().isNull() != true) | 211 | if (logo.data().isNull() != true) |
212 | { | 212 | { |
213 | QPixmap pm; | 213 | QPixmap pm; |
214 | pm.convertFromImage(logo.data()); | 214 | pm.convertFromImage(logo.data()); |
215 | mLogoLabel->setPixmap( pm ); | 215 | mLogoLabel->setPixmap( pm ); |
216 | } | 216 | } |
217 | mUseLogoUrl->setChecked( false ); | 217 | mUseLogoUrl->setChecked( false ); |
218 | } else { | 218 | } else { |
219 | mLogoUrl->setURL( logo.url() ); | 219 | mLogoUrl->setURL( logo.url() ); |
220 | if ( !logo.url().isEmpty() ) | 220 | if ( !logo.url().isEmpty() ) |
221 | mUseLogoUrl->setChecked( true ); | 221 | mUseLogoUrl->setChecked( true ); |
222 | loadLogo(); | 222 | loadLogo(); |
223 | } | 223 | } |
224 | 224 | ||
225 | blockSignals( blocked ); | 225 | blockSignals( blocked ); |
226 | } | 226 | } |
227 | 227 | ||
228 | KABC::Picture ImageWidget::logo() const | 228 | KABC::Picture ImageWidget::logo() const |
229 | { | 229 | { |
230 | KABC::Picture logo; | 230 | KABC::Picture logo; |
231 | 231 | ||
232 | if ( mUseLogoUrl->isChecked() ) | 232 | if ( mUseLogoUrl->isChecked() ) |
233 | logo.setUrl( mLogoUrl->url() ); | 233 | logo.setUrl( mLogoUrl->url() ); |
234 | else { | 234 | else { |
235 | QPixmap *px = mLogoLabel->pixmap(); | 235 | QPixmap *px = mLogoLabel->pixmap(); |
236 | if ( px ) { | 236 | if ( px ) { |
237 | #ifndef KAB_EMBEDDED | 237 | #ifndef KAB_EMBEDDED |
238 | if ( px->height() > px->width() ) | 238 | if ( px->height() > px->width() ) |
239 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); | 239 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); |
240 | else | 240 | else |
241 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); | 241 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); |
242 | #else //KAB_EMBEDDED | 242 | #else //KAB_EMBEDDED |
243 | logo.setData( px->convertToImage() ); | 243 | if (px->isNull() != true ) |
244 | logo.setData( px->convertToImage() ); | ||
244 | #endif //KAB_EMBEDDED | 245 | #endif //KAB_EMBEDDED |
245 | 246 | ||
246 | logo.setType( "PNG" ); | 247 | logo.setType( "PNG" ); |
247 | 248 | ||
248 | } | 249 | } |
249 | } | 250 | } |
250 | return logo; | 251 | return logo; |
251 | } | 252 | } |
252 | void ImageWidget::removePhoto() | 253 | void ImageWidget::removePhoto() |
253 | { | 254 | { |
254 | setPhoto(KABC::Picture() ); | 255 | setPhoto(KABC::Picture() ); |
255 | } | 256 | } |
256 | 257 | ||
257 | void ImageWidget::removeLogo() | 258 | void ImageWidget::removeLogo() |
258 | { | 259 | { |
259 | setLogo(KABC::Picture() ); | 260 | setLogo(KABC::Picture() ); |
260 | } | 261 | } |
261 | 262 | ||
262 | void ImageWidget::loadPhoto() | 263 | void ImageWidget::loadPhoto() |
263 | { | 264 | { |
264 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); | 265 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); |
265 | } | 266 | } |
266 | 267 | ||
267 | void ImageWidget::loadLogo() | 268 | void ImageWidget::loadLogo() |
268 | { | 269 | { |
269 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); | 270 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); |
270 | } | 271 | } |
271 | 272 | ||
272 | void ImageWidget::updateGUI() | 273 | void ImageWidget::updateGUI() |
273 | { | 274 | { |
274 | KURLRequester *ptr = (KURLRequester*)sender(); | 275 | KURLRequester *ptr = (KURLRequester*)sender(); |
275 | 276 | ||
276 | 277 | ||
277 | if ( ptr == mPhotoUrl ) | 278 | if ( ptr == mPhotoUrl ) |
278 | mUsePhotoUrl->setEnabled( true ); | 279 | mUsePhotoUrl->setEnabled( true ); |
279 | else if ( ptr == mLogoUrl ) | 280 | else if ( ptr == mLogoUrl ) |
280 | mUseLogoUrl->setEnabled( true ); | 281 | mUseLogoUrl->setEnabled( true ); |
281 | } | 282 | } |
282 | 283 | ||
283 | QPixmap ImageWidget::loadPixmap( const KURL &url ) | 284 | QPixmap ImageWidget::loadPixmap( const KURL &url ) |
284 | { | 285 | { |
285 | QString tempFile; | 286 | QString tempFile; |
286 | QPixmap pixmap; | 287 | QPixmap pixmap; |
287 | 288 | ||
288 | if ( url.isEmpty() ) | 289 | if ( url.isEmpty() ) |
289 | return pixmap; | 290 | return pixmap; |
290 | 291 | ||
291 | if ( url.isLocalFile() ) | 292 | if ( url.isLocalFile() ) |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d970ff1..e88706e 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1143,96 +1143,100 @@ void KABCore::setCategories() | |||
1143 | if ( uids.count() > 0 ) | 1143 | if ( uids.count() > 0 ) |
1144 | setModified( true ); | 1144 | setModified( true ); |
1145 | message( i18n("Setting categories completed!") ); | 1145 | message( i18n("Setting categories completed!") ); |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1148 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1149 | { | 1149 | { |
1150 | mIncSearchWidget->setFields( fields ); | 1150 | mIncSearchWidget->setFields( fields ); |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | void KABCore::incrementalSearch( const QString& text ) | 1153 | void KABCore::incrementalSearch( const QString& text ) |
1154 | { | 1154 | { |
1155 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1155 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | void KABCore::setModified() | 1158 | void KABCore::setModified() |
1159 | { | 1159 | { |
1160 | setModified( true ); | 1160 | setModified( true ); |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | void KABCore::setModifiedWOrefresh() | 1163 | void KABCore::setModifiedWOrefresh() |
1164 | { | 1164 | { |
1165 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1165 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1166 | mModified = true; | 1166 | mModified = true; |
1167 | mActionSave->setEnabled( mModified ); | 1167 | mActionSave->setEnabled( mModified ); |
1168 | 1168 | ||
1169 | 1169 | ||
1170 | } | 1170 | } |
1171 | void KABCore::setModified( bool modified ) | 1171 | void KABCore::setModified( bool modified ) |
1172 | { | 1172 | { |
1173 | mModified = modified; | 1173 | mModified = modified; |
1174 | mActionSave->setEnabled( mModified ); | 1174 | mActionSave->setEnabled( mModified ); |
1175 | 1175 | ||
1176 | if ( modified ) | 1176 | if ( modified ) |
1177 | mJumpButtonBar->recreateButtons(); | 1177 | mJumpButtonBar->recreateButtons(); |
1178 | 1178 | ||
1179 | mViewManager->refreshView(); | 1179 | mViewManager->refreshView(); |
1180 | 1180 | ||
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | bool KABCore::modified() const | 1183 | bool KABCore::modified() const |
1184 | { | 1184 | { |
1185 | return mModified; | 1185 | return mModified; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1188 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1189 | { | 1189 | { |
1190 | addrModified( addr ); | 1190 | addrModified( addr ); |
1191 | #if 0 // debug only | ||
1192 | KABC::Addressee ad = addr; | ||
1193 | ad.computeCsum( "123"); | ||
1194 | #endif | ||
1191 | } | 1195 | } |
1192 | 1196 | ||
1193 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1197 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1194 | { | 1198 | { |
1195 | 1199 | ||
1196 | Command *command = 0; | 1200 | Command *command = 0; |
1197 | QString uid; | 1201 | QString uid; |
1198 | 1202 | ||
1199 | // check if it exists already | 1203 | // check if it exists already |
1200 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1204 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1201 | if ( origAddr.isEmpty() ) | 1205 | if ( origAddr.isEmpty() ) |
1202 | command = new PwNewCommand( mAddressBook, addr ); | 1206 | command = new PwNewCommand( mAddressBook, addr ); |
1203 | else { | 1207 | else { |
1204 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1208 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1205 | uid = addr.uid(); | 1209 | uid = addr.uid(); |
1206 | } | 1210 | } |
1207 | 1211 | ||
1208 | UndoStack::instance()->push( command ); | 1212 | UndoStack::instance()->push( command ); |
1209 | RedoStack::instance()->clear(); | 1213 | RedoStack::instance()->clear(); |
1210 | if ( updateDetails ) | 1214 | if ( updateDetails ) |
1211 | mDetails->setAddressee( addr ); | 1215 | mDetails->setAddressee( addr ); |
1212 | setModified( true ); | 1216 | setModified( true ); |
1213 | } | 1217 | } |
1214 | 1218 | ||
1215 | void KABCore::newContact() | 1219 | void KABCore::newContact() |
1216 | { | 1220 | { |
1217 | 1221 | ||
1218 | 1222 | ||
1219 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1223 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1220 | 1224 | ||
1221 | QPtrList<KRES::Resource> kresResources; | 1225 | QPtrList<KRES::Resource> kresResources; |
1222 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1226 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1223 | KABC::Resource *resource; | 1227 | KABC::Resource *resource; |
1224 | while ( ( resource = it.current() ) != 0 ) { | 1228 | while ( ( resource = it.current() ) != 0 ) { |
1225 | ++it; | 1229 | ++it; |
1226 | if ( !resource->readOnly() ) { | 1230 | if ( !resource->readOnly() ) { |
1227 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1231 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1228 | if ( res ) | 1232 | if ( res ) |
1229 | kresResources.append( res ); | 1233 | kresResources.append( res ); |
1230 | } | 1234 | } |
1231 | } | 1235 | } |
1232 | 1236 | ||
1233 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1237 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1234 | resource = static_cast<KABC::Resource*>( res ); | 1238 | resource = static_cast<KABC::Resource*>( res ); |
1235 | 1239 | ||
1236 | if ( resource ) { | 1240 | if ( resource ) { |
1237 | KABC::Addressee addr; | 1241 | KABC::Addressee addr; |
1238 | addr.setResource( resource ); | 1242 | addr.setResource( resource ); |
@@ -2668,97 +2672,98 @@ void KABCore::faq() | |||
2668 | { | 2672 | { |
2669 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2673 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2670 | } | 2674 | } |
2671 | 2675 | ||
2672 | #include <libkcal/syncdefines.h> | 2676 | #include <libkcal/syncdefines.h> |
2673 | 2677 | ||
2674 | KABC::Addressee KABCore::getLastSyncAddressee() | 2678 | KABC::Addressee KABCore::getLastSyncAddressee() |
2675 | { | 2679 | { |
2676 | Addressee lse; | 2680 | Addressee lse; |
2677 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2681 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2678 | 2682 | ||
2679 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2683 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2680 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2684 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2681 | if (lse.isEmpty()) { | 2685 | if (lse.isEmpty()) { |
2682 | qDebug("Creating new last-syncAddressee "); | 2686 | qDebug("Creating new last-syncAddressee "); |
2683 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2687 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2684 | QString sum = ""; | 2688 | QString sum = ""; |
2685 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2689 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2686 | sum = "E: "; | 2690 | sum = "E: "; |
2687 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2691 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2688 | lse.setRevision( mLastAddressbookSync ); | 2692 | lse.setRevision( mLastAddressbookSync ); |
2689 | lse.setCategories( i18n("SyncEvent") ); | 2693 | lse.setCategories( i18n("SyncEvent") ); |
2690 | mAddressBook->insertAddressee( lse ); | 2694 | mAddressBook->insertAddressee( lse ); |
2691 | } | 2695 | } |
2692 | return lse; | 2696 | return lse; |
2693 | } | 2697 | } |
2694 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2698 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2695 | { | 2699 | { |
2696 | 2700 | ||
2697 | //void setZaurusId(int id); | 2701 | //void setZaurusId(int id); |
2698 | // int zaurusId() const; | 2702 | // int zaurusId() const; |
2699 | // void setZaurusUid(int id); | 2703 | // void setZaurusUid(int id); |
2700 | // int zaurusUid() const; | 2704 | // int zaurusUid() const; |
2701 | // void setZaurusStat(int id); | 2705 | // void setZaurusStat(int id); |
2702 | // int zaurusStat() const; | 2706 | // int zaurusStat() const; |
2703 | // 0 equal | 2707 | // 0 equal |
2704 | // 1 take local | 2708 | // 1 take local |
2705 | // 2 take remote | 2709 | // 2 take remote |
2706 | // 3 cancel | 2710 | // 3 cancel |
2707 | QDateTime lastSync = mLastAddressbookSync; | 2711 | QDateTime lastSync = mLastAddressbookSync; |
2708 | QDateTime localMod = local->revision(); | 2712 | QDateTime localMod = local->revision(); |
2709 | QDateTime remoteMod = remote->revision(); | 2713 | QDateTime remoteMod = remote->revision(); |
2710 | 2714 | ||
2711 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2715 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2712 | 2716 | ||
2713 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2717 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2714 | bool remCh, locCh; | 2718 | bool remCh, locCh; |
2715 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2719 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2716 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2720 | if ( remCh ) |
2721 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | ||
2717 | locCh = ( localMod > mLastAddressbookSync ); | 2722 | locCh = ( localMod > mLastAddressbookSync ); |
2718 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2723 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2719 | if ( !remCh && ! locCh ) { | 2724 | if ( !remCh && ! locCh ) { |
2720 | //qDebug("both not changed "); | 2725 | //qDebug("both not changed "); |
2721 | lastSync = localMod.addDays(1); | 2726 | lastSync = localMod.addDays(1); |
2722 | if ( mode <= SYNC_PREF_ASK ) | 2727 | if ( mode <= SYNC_PREF_ASK ) |
2723 | return 0; | 2728 | return 0; |
2724 | } else { | 2729 | } else { |
2725 | if ( locCh ) { | 2730 | if ( locCh ) { |
2726 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2731 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2727 | lastSync = localMod.addDays( -1 ); | 2732 | lastSync = localMod.addDays( -1 ); |
2728 | if ( !remCh ) | 2733 | if ( !remCh ) |
2729 | remoteMod =( lastSync.addDays( -1 ) ); | 2734 | remoteMod =( lastSync.addDays( -1 ) ); |
2730 | } else { | 2735 | } else { |
2731 | //qDebug(" not loc changed "); | 2736 | //qDebug(" not loc changed "); |
2732 | lastSync = localMod.addDays( 1 ); | 2737 | lastSync = localMod.addDays( 1 ); |
2733 | if ( remCh ) { | 2738 | if ( remCh ) { |
2734 | //qDebug("rem changed "); | 2739 | //qDebug("rem changed "); |
2735 | remoteMod =( lastSync.addDays( 1 ) ); | 2740 | remoteMod =( lastSync.addDays( 1 ) ); |
2736 | } | 2741 | } |
2737 | 2742 | ||
2738 | } | 2743 | } |
2739 | } | 2744 | } |
2740 | full = true; | 2745 | full = true; |
2741 | if ( mode < SYNC_PREF_ASK ) | 2746 | if ( mode < SYNC_PREF_ASK ) |
2742 | mode = SYNC_PREF_ASK; | 2747 | mode = SYNC_PREF_ASK; |
2743 | } else { | 2748 | } else { |
2744 | if ( localMod == remoteMod ) | 2749 | if ( localMod == remoteMod ) |
2745 | return 0; | 2750 | return 0; |
2746 | 2751 | ||
2747 | } | 2752 | } |
2748 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2753 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2749 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2754 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2750 | //full = true; //debug only | 2755 | //full = true; //debug only |
2751 | if ( full ) { | 2756 | if ( full ) { |
2752 | bool equ = ( (*local) == (*remote) ); | 2757 | bool equ = ( (*local) == (*remote) ); |
2753 | if ( equ ) { | 2758 | if ( equ ) { |
2754 | //qDebug("equal "); | 2759 | //qDebug("equal "); |
2755 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2760 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2756 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2761 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2757 | } | 2762 | } |
2758 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2763 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2759 | return 0; | 2764 | return 0; |
2760 | 2765 | ||
2761 | }//else //debug only | 2766 | }//else //debug only |
2762 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2767 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2763 | } | 2768 | } |
2764 | int result; | 2769 | int result; |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index ecd6f05..7022dcb 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -112,97 +112,97 @@ void KAddressBookTableView::reconstructListView() | |||
112 | SIGNAL(startDrag())); | 112 | SIGNAL(startDrag())); |
113 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 113 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
114 | SIGNAL(dropped(QDropEvent*))); | 114 | SIGNAL(dropped(QDropEvent*))); |
115 | 115 | ||
116 | if (KABPrefs::instance()->mHonorSingleClick) { | 116 | if (KABPrefs::instance()->mHonorSingleClick) { |
117 | // qDebug("KAddressBookTableView::reconstructListView single"); | 117 | // qDebug("KAddressBookTableView::reconstructListView single"); |
118 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 118 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
119 | this, SLOT(addresseeExecuted(QListViewItem*))); | 119 | this, SLOT(addresseeExecuted(QListViewItem*))); |
120 | } else { | 120 | } else { |
121 | // qDebug("KAddressBookTableView::reconstructListView double"); | 121 | // qDebug("KAddressBookTableView::reconstructListView double"); |
122 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 122 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
123 | this, SLOT(addresseeExecuted(QListViewItem*))); | 123 | this, SLOT(addresseeExecuted(QListViewItem*))); |
124 | } | 124 | } |
125 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 125 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
126 | this, SLOT(addresseeExecuted(QListViewItem*))); | 126 | this, SLOT(addresseeExecuted(QListViewItem*))); |
127 | connect(mListView, SIGNAL(signalDelete()), | 127 | connect(mListView, SIGNAL(signalDelete()), |
128 | this, SLOT(addresseeDeleted())); | 128 | this, SLOT(addresseeDeleted())); |
129 | 129 | ||
130 | //US performceimprovement. Refresh is done from the outside | 130 | //US performceimprovement. Refresh is done from the outside |
131 | //US refresh(); | 131 | //US refresh(); |
132 | 132 | ||
133 | mListView->setSorting( 0, true ); | 133 | mListView->setSorting( 0, true ); |
134 | mainLayout->addWidget( mListView ); | 134 | mainLayout->addWidget( mListView ); |
135 | mainLayout->activate(); | 135 | mainLayout->activate(); |
136 | mListView->show(); | 136 | mListView->show(); |
137 | } | 137 | } |
138 | 138 | ||
139 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 139 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
140 | { | 140 | { |
141 | mListView->clear(); | 141 | mListView->clear(); |
142 | if ( s.isEmpty() || s == "*" ) { | 142 | if ( s.isEmpty() || s == "*" ) { |
143 | refresh(); | 143 | refresh(); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | QString pattern = s.lower()+"*"; | 146 | QString pattern = s.lower()+"*"; |
147 | QRegExp re; | 147 | QRegExp re; |
148 | re.setWildcard(true); // most people understand these better. | 148 | re.setWildcard(true); // most people understand these better. |
149 | re.setCaseSensitive(false); | 149 | re.setCaseSensitive(false); |
150 | re.setPattern( pattern ); | 150 | re.setPattern( pattern ); |
151 | if (!re.isValid()) | 151 | if (!re.isValid()) |
152 | return; | 152 | return; |
153 | KABC::Addressee::List addresseeList = addressees(); | 153 | KABC::Addressee::List addresseeList = addressees(); |
154 | KABC::Addressee::List::Iterator it; | 154 | KABC::Addressee::List::Iterator it; |
155 | if ( field ) { | 155 | if ( field ) { |
156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
158 | continue; | 158 | continue; |
159 | #if QT_VERSION >= 300 | 159 | #if QT_VERSION >= 300 |
160 | if (re.search(field->value( *it ).lower()) != -1) | 160 | if (re.search(field->value( *it ).lower()) == 0) |
161 | #else | 161 | #else |
162 | if (re.match(field->value( *it ).lower()) != -1) | 162 | if (re.match(field->value( *it ).lower()) != -1) |
163 | #endif | 163 | #endif |
164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
165 | 165 | ||
166 | } | 166 | } |
167 | } else { | 167 | } else { |
168 | KABC::Field::List fieldList = allFields(); | 168 | KABC::Field::List fieldList = allFields(); |
169 | KABC::Field::List::ConstIterator fieldIt; | 169 | KABC::Field::List::ConstIterator fieldIt; |
170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
172 | continue; | 172 | continue; |
173 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 173 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
174 | #if QT_VERSION >= 300 | 174 | #if QT_VERSION >= 300 |
175 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 175 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
176 | #else | 176 | #else |
177 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 177 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
178 | #endif | 178 | #endif |
179 | { | 179 | { |
180 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 180 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
181 | break; | 181 | break; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | } | 184 | } |
185 | } | 185 | } |
186 | // Sometimes the background pixmap gets messed up when we add lots | 186 | // Sometimes the background pixmap gets messed up when we add lots |
187 | // of items. | 187 | // of items. |
188 | mListView->repaint(); | 188 | mListView->repaint(); |
189 | if ( mListView->firstChild() ) { | 189 | if ( mListView->firstChild() ) { |
190 | mListView->setCurrentItem ( mListView->firstChild() ); | 190 | mListView->setCurrentItem ( mListView->firstChild() ); |
191 | mListView->setSelected ( mListView->firstChild(), true ); | 191 | mListView->setSelected ( mListView->firstChild(), true ); |
192 | } | 192 | } |
193 | else | 193 | else |
194 | emit selected(QString::null); | 194 | emit selected(QString::null); |
195 | 195 | ||
196 | } | 196 | } |
197 | void KAddressBookTableView::writeConfig(KConfig *config) | 197 | void KAddressBookTableView::writeConfig(KConfig *config) |
198 | { | 198 | { |
199 | KAddressBookView::writeConfig(config); | 199 | KAddressBookView::writeConfig(config); |
200 | 200 | ||
201 | mListView->saveLayout(config, config->group()); | 201 | mListView->saveLayout(config, config->group()); |
202 | } | 202 | } |
203 | 203 | ||
204 | void KAddressBookTableView::readConfig(KConfig *config) | 204 | void KAddressBookTableView::readConfig(KConfig *config) |
205 | { | 205 | { |
206 | KAddressBookView::readConfig( config ); | 206 | KAddressBookView::readConfig( config ); |
207 | // The config could have changed the fields, so we need to reconstruct | 207 | // The config could have changed the fields, so we need to reconstruct |
208 | // the listview. | 208 | // the listview. |