Diffstat (limited to 'kaddressbook/views/kaddressbookcardview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 8d0fca1..4babf67 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -238,192 +238,194 @@ void KAddressBookCardView::readConfig(KConfig *config) | |||
238 | } | 238 | } |
239 | 239 | ||
240 | void KAddressBookCardView::writeConfig( KConfig *config ) | 240 | void KAddressBookCardView::writeConfig( KConfig *config ) |
241 | { | 241 | { |
242 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 242 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
243 | KAddressBookView::writeConfig( config ); | 243 | KAddressBookView::writeConfig( config ); |
244 | } | 244 | } |
245 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 245 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) |
246 | { | 246 | { |
247 | mCardView->clear(); | 247 | mCardView->clear(); |
248 | if ( s.isEmpty() || s == "*" ) { | 248 | if ( s.isEmpty() || s == "*" ) { |
249 | refresh(); | 249 | refresh(); |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | QString pattern = s.lower()+"*"; | 252 | QString pattern = s.lower()+"*"; |
253 | QRegExp re; | 253 | QRegExp re; |
254 | re.setWildcard(true); // most people understand these better. | 254 | re.setWildcard(true); // most people understand these better. |
255 | re.setCaseSensitive(false); | 255 | re.setCaseSensitive(false); |
256 | re.setPattern( pattern ); | 256 | re.setPattern( pattern ); |
257 | if (!re.isValid()) | 257 | if (!re.isValid()) |
258 | return; | 258 | return; |
259 | mCardView->viewport()->setUpdatesEnabled( false ); | 259 | mCardView->viewport()->setUpdatesEnabled( false ); |
260 | KABC::Addressee::List addresseeList = addressees(); | 260 | KABC::Addressee::List addresseeList = addressees(); |
261 | KABC::Addressee::List::Iterator it; | 261 | KABC::Addressee::List::Iterator it; |
262 | if ( field ) { | 262 | if ( field ) { |
263 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 263 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
264 | #if QT_VERSION >= 300 | 264 | #if QT_VERSION >= 300 |
265 | if (re.search(field->value( *it ).lower()) != -1) | 265 | if (re.search(field->value( *it ).lower()) != -1) |
266 | #else | 266 | #else |
267 | if (re.match(field->value( *it ).lower()) != -1) | 267 | if (re.match(field->value( *it ).lower()) != -1) |
268 | #endif | 268 | #endif |
269 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 269 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
270 | addressBook(), *it, mCardView); | 270 | addressBook(), *it, mCardView); |
271 | 271 | ||
272 | } | 272 | } |
273 | } else { | 273 | } else { |
274 | KABC::Field::List fieldList = fields(); | 274 | KABC::Field::List fieldList = fields(); |
275 | KABC::Field::List::ConstIterator fieldIt; | 275 | KABC::Field::List::ConstIterator fieldIt; |
276 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 276 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
277 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 277 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
278 | #if QT_VERSION >= 300 | 278 | #if QT_VERSION >= 300 |
279 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 279 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
280 | #else | 280 | #else |
281 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 281 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
282 | #endif | 282 | #endif |
283 | { | 283 | { |
284 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 284 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
285 | addressBook(), *it, mCardView); | 285 | addressBook(), *it, mCardView); |
286 | continue; | 286 | continue; |
287 | } | 287 | } |
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | mCardView->viewport()->setUpdatesEnabled( true ); | 291 | mCardView->viewport()->setUpdatesEnabled( true ); |
292 | mCardView->viewport()->update(); | 292 | mCardView->viewport()->update(); |
293 | // by default nothing is selected | 293 | // by default nothing is selected |
294 | emit selected(QString::null); | 294 | emit selected(QString::null); |
295 | } | 295 | } |
296 | QStringList KAddressBookCardView::selectedUids() | 296 | QStringList KAddressBookCardView::selectedUids() |
297 | { | 297 | { |
298 | QStringList uidList; | 298 | QStringList uidList; |
299 | CardViewItem *item; | 299 | CardViewItem *item; |
300 | AddresseeCardViewItem *aItem; | 300 | AddresseeCardViewItem *aItem; |
301 | 301 | ||
302 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 302 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
303 | { | 303 | { |
304 | if (item->isSelected()) | 304 | if (item->isSelected()) |
305 | { | 305 | { |
306 | #ifndef KAB_EMBEDDED | 306 | #ifndef KAB_EMBEDDED |
307 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 307 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
308 | #else //KAB_EMBEDDED | 308 | #else //KAB_EMBEDDED |
309 | aItem = (AddresseeCardViewItem*)(item); | 309 | aItem = (AddresseeCardViewItem*)(item); |
310 | #endif //KAB_EMBEDDED | 310 | #endif //KAB_EMBEDDED |
311 | if (aItem) | 311 | if (aItem) |
312 | uidList << aItem->addressee().uid(); | 312 | uidList << aItem->addressee().uid(); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | return uidList; | 316 | return uidList; |
317 | } | 317 | } |
318 | 318 | ||
319 | void KAddressBookCardView::refresh(QString uid) | 319 | void KAddressBookCardView::refresh(QString uid) |
320 | { | 320 | { |
321 | CardViewItem *item; | 321 | CardViewItem *item; |
322 | AddresseeCardViewItem *aItem; | 322 | AddresseeCardViewItem *aItem; |
323 | 323 | ||
324 | if (uid.isNull()) | 324 | if (uid.isNull()) |
325 | { | 325 | { |
326 | // Rebuild the view | 326 | // Rebuild the view |
327 | mCardView->viewport()->setUpdatesEnabled( false ); | 327 | mCardView->viewport()->setUpdatesEnabled( false ); |
328 | mCardView->clear(); | 328 | mCardView->clear(); |
329 | 329 | ||
330 | KABC::Addressee::List addresseeList = addressees(); | 330 | KABC::Addressee::List addresseeList = addressees(); |
331 | KABC::Addressee::List::Iterator iter; | 331 | KABC::Addressee::List::Iterator iter; |
332 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 332 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |
333 | { | 333 | { |
334 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) | ||
335 | continue; | ||
334 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, | 336 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, |
335 | addressBook(), *iter, mCardView); | 337 | addressBook(), *iter, mCardView); |
336 | } | 338 | } |
337 | mCardView->viewport()->setUpdatesEnabled( true ); | 339 | mCardView->viewport()->setUpdatesEnabled( true ); |
338 | mCardView->viewport()->update(); | 340 | mCardView->viewport()->update(); |
339 | 341 | ||
340 | // by default nothing is selected | 342 | // by default nothing is selected |
341 | emit selected(QString::null); | 343 | emit selected(QString::null); |
342 | } | 344 | } |
343 | else | 345 | else |
344 | { | 346 | { |
345 | // Try to find the one to refresh | 347 | // Try to find the one to refresh |
346 | bool found = false; | 348 | bool found = false; |
347 | for (item = mCardView->firstItem(); item && !found; | 349 | for (item = mCardView->firstItem(); item && !found; |
348 | item = item->nextItem()) | 350 | item = item->nextItem()) |
349 | { | 351 | { |
350 | #ifndef KAB_EMBEDDED | 352 | #ifndef KAB_EMBEDDED |
351 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 353 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
352 | #else //KAB_EMBEDDED | 354 | #else //KAB_EMBEDDED |
353 | aItem = (AddresseeCardViewItem*)(item); | 355 | aItem = (AddresseeCardViewItem*)(item); |
354 | #endif //KAB_EMBEDDED | 356 | #endif //KAB_EMBEDDED |
355 | 357 | ||
356 | if ((aItem) && (aItem->addressee().uid() == uid)) | 358 | if ((aItem) && (aItem->addressee().uid() == uid)) |
357 | { | 359 | { |
358 | aItem->refresh(); | 360 | aItem->refresh(); |
359 | found = true; | 361 | found = true; |
360 | } | 362 | } |
361 | } | 363 | } |
362 | } | 364 | } |
363 | } | 365 | } |
364 | 366 | ||
365 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 367 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
366 | { | 368 | { |
367 | CardViewItem *item; | 369 | CardViewItem *item; |
368 | AddresseeCardViewItem *aItem; | 370 | AddresseeCardViewItem *aItem; |
369 | 371 | ||
370 | if (uid.isNull()) | 372 | if (uid.isNull()) |
371 | { | 373 | { |
372 | mCardView->selectAll(selected); | 374 | mCardView->selectAll(selected); |
373 | } | 375 | } |
374 | else | 376 | else |
375 | { | 377 | { |
376 | bool found = false; | 378 | bool found = false; |
377 | for (item = mCardView->firstItem(); item && !found; | 379 | for (item = mCardView->firstItem(); item && !found; |
378 | item = item->nextItem()) | 380 | item = item->nextItem()) |
379 | { | 381 | { |
380 | #ifndef KAB_EMBEDDED | 382 | #ifndef KAB_EMBEDDED |
381 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 383 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
382 | #else //KAB_EMBEDDED | 384 | #else //KAB_EMBEDDED |
383 | aItem = (AddresseeCardViewItem*)(item); | 385 | aItem = (AddresseeCardViewItem*)(item); |
384 | #endif //KAB_EMBEDDED | 386 | #endif //KAB_EMBEDDED |
385 | 387 | ||
386 | if ((aItem) && (aItem->addressee().uid() == uid)) | 388 | if ((aItem) && (aItem->addressee().uid() == uid)) |
387 | { | 389 | { |
388 | mCardView->setSelected(aItem, selected); | 390 | mCardView->setSelected(aItem, selected); |
389 | mCardView->ensureItemVisible(item); | 391 | mCardView->ensureItemVisible(item); |
390 | found = true; | 392 | found = true; |
391 | } | 393 | } |
392 | } | 394 | } |
393 | } | 395 | } |
394 | } | 396 | } |
395 | 397 | ||
396 | //US added an additional method without parameter | 398 | //US added an additional method without parameter |
397 | void KAddressBookCardView::setSelected() | 399 | void KAddressBookCardView::setSelected() |
398 | { | 400 | { |
399 | setSelected(QString::null, true); | 401 | setSelected(QString::null, true); |
400 | } | 402 | } |
401 | 403 | ||
402 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | 404 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) |
403 | { | 405 | { |
404 | #ifndef KAB_EMBEDDED | 406 | #ifndef KAB_EMBEDDED |
405 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 407 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
406 | #else //KAB_EMBEDDED | 408 | #else //KAB_EMBEDDED |
407 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); | 409 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); |
408 | #endif //KAB_EMBEDDED | 410 | #endif //KAB_EMBEDDED |
409 | if (aItem) | 411 | if (aItem) |
410 | { | 412 | { |
411 | //kdDebug()<<"... even has a valid item:)"<<endl; | 413 | //kdDebug()<<"... even has a valid item:)"<<endl; |
412 | emit executed(aItem->addressee().uid()); | 414 | emit executed(aItem->addressee().uid()); |
413 | } | 415 | } |
414 | } | 416 | } |
415 | 417 | ||
416 | void KAddressBookCardView::addresseeSelected() | 418 | void KAddressBookCardView::addresseeSelected() |
417 | { | 419 | { |
418 | CardViewItem *item; | 420 | CardViewItem *item; |
419 | AddresseeCardViewItem *aItem; | 421 | AddresseeCardViewItem *aItem; |
420 | 422 | ||
421 | bool found = false; | 423 | bool found = false; |
422 | for (item = mCardView->firstItem(); item && !found; | 424 | for (item = mCardView->firstItem(); item && !found; |
423 | item = item->nextItem()) | 425 | item = item->nextItem()) |
424 | { | 426 | { |
425 | if (item->isSelected()) | 427 | if (item->isSelected()) |
426 | { | 428 | { |
427 | #ifndef KAB_EMBEDDED | 429 | #ifndef KAB_EMBEDDED |
428 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 430 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
429 | #else //KAB_EMBEDDED | 431 | #else //KAB_EMBEDDED |