author | zautrix <zautrix> | 2005-08-22 15:42:41 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-22 15:42:41 (UTC) |
commit | 1d82d044bbdedd407f6d08305522187ffd256552 (patch) (unidiff) | |
tree | 08f5651d72548b643ed012e5f6ad938b36d1ae3f /kaddressbook/views/kaddressbookcardview.cpp | |
parent | f516a558e6d18982a54152b28ca3da78fe76e3fc (diff) | |
download | kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.zip kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.gz kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.bz2 |
kapi search fix
Diffstat (limited to 'kaddressbook/views/kaddressbookcardview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index ca21016..b503652 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -284,108 +284,126 @@ void KAddressBookCardView::readConfig(KConfig *config) | |||
284 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 284 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
285 | this, SLOT(addresseeExecuted(CardViewItem *))); | 285 | this, SLOT(addresseeExecuted(CardViewItem *))); |
286 | else | 286 | else |
287 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 287 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
288 | this, SLOT(addresseeExecuted(CardViewItem *))); | 288 | this, SLOT(addresseeExecuted(CardViewItem *))); |
289 | #endif | 289 | #endif |
290 | 290 | ||
291 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 291 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
292 | this, SLOT(addresseeExecuted(CardViewItem *))); | 292 | this, SLOT(addresseeExecuted(CardViewItem *))); |
293 | } | 293 | } |
294 | 294 | ||
295 | void KAddressBookCardView::writeConfig( KConfig *config ) | 295 | void KAddressBookCardView::writeConfig( KConfig *config ) |
296 | { | 296 | { |
297 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 297 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
298 | KAddressBookView::writeConfig( config ); | 298 | KAddressBookView::writeConfig( config ); |
299 | } | 299 | } |
300 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 300 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) |
301 | { | 301 | { |
302 | mCardView->clear(); | 302 | mCardView->clear(); |
303 | if ( s.isEmpty() || s == "*" ) { | 303 | if ( s.isEmpty() || s == "*" ) { |
304 | refresh(); | 304 | refresh(); |
305 | return; | 305 | return; |
306 | } | 306 | } |
307 | QRegExp re = getRegExp( s ); | 307 | QRegExp re = getRegExp( s ); |
308 | if (!re.isValid()) | 308 | if (!re.isValid()) |
309 | return; | 309 | return; |
310 | mCardView->viewport()->setUpdatesEnabled( false ); | 310 | mCardView->viewport()->setUpdatesEnabled( false ); |
311 | KABC::Addressee::List addresseeList = addressees(); | 311 | KABC::Addressee::List addresseeList = addressees(); |
312 | KABC::Addressee::List::Iterator it; | 312 | KABC::Addressee::List::Iterator it; |
313 | if ( field ) { | 313 | if ( field ) { |
314 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 314 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
315 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 315 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
316 | continue; | 316 | continue; |
317 | #if QT_VERSION >= 0x030000 | 317 | #if QT_VERSION >= 0x030000 |
318 | if (re.search(field->value( *it ).lower()) == 0) | 318 | if (re.search(field->value( *it ).lower()) == 0) |
319 | #else | 319 | #else |
320 | if (re.match(field->value( *it ).lower()) == 0) | 320 | if (re.match(field->value( *it ).lower()) == 0) |
321 | #endif | 321 | #endif |
322 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 322 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
323 | addressBook(), *it, mCardView); | 323 | addressBook(), *it, mCardView); |
324 | 324 | ||
325 | } | 325 | } |
326 | } else { | 326 | } else { |
327 | KABC::Field::List fieldList = allFields(); | 327 | KABC::Field::List fieldList = allFields(); |
328 | KABC::Field::List::ConstIterator fieldIt; | 328 | KABC::Field::List::ConstIterator fieldIt; |
329 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 329 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
330 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 330 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
331 | continue; | 331 | continue; |
332 | bool match = false; | ||
332 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 333 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
333 | #if QT_VERSION >= 0x030000 | 334 | #if QT_VERSION >= 0x030000 |
334 | if (re.search((*fieldIt)->value( *it ).lower()) == 0) | 335 | if (re.search((*fieldIt)->value( *it ).lower()) == 0) |
335 | #else | 336 | #else |
336 | if (re.match((*fieldIt)->value( *it ).lower()) == 0) | 337 | if (re.match((*fieldIt)->value( *it ).lower()) == 0) |
337 | #endif | 338 | #endif |
338 | { | 339 | { |
339 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 340 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
340 | addressBook(), *it, mCardView); | 341 | addressBook(), *it, mCardView); |
342 | match = true; | ||
341 | break; | 343 | break; |
342 | } | 344 | } |
343 | } | 345 | } |
346 | if ( ! match ) { | ||
347 | if ( (*it).matchPhoneNumber( &re ) ) { | ||
348 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | ||
349 | addressBook(), *it, mCardView); | ||
350 | match = true; | ||
351 | break; | ||
352 | } | ||
353 | } | ||
354 | if ( ! match ) { | ||
355 | if ( (*it).matchAddress( &re ) ) { | ||
356 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | ||
357 | addressBook(), *it, mCardView); | ||
358 | match = true; | ||
359 | break; | ||
360 | } | ||
361 | } | ||
344 | } | 362 | } |
345 | } | 363 | } |
346 | mCardView->viewport()->setUpdatesEnabled( true ); | 364 | mCardView->viewport()->setUpdatesEnabled( true ); |
347 | mCardView->viewport()->update(); | 365 | mCardView->viewport()->update(); |
348 | if ( mCardView->firstItem() ) { | 366 | if ( mCardView->firstItem() ) { |
349 | mCardView->setCurrentItem ( mCardView->firstItem() ); | 367 | mCardView->setCurrentItem ( mCardView->firstItem() ); |
350 | mCardView->setSelected ( mCardView->firstItem() , true ); | 368 | mCardView->setSelected ( mCardView->firstItem() , true ); |
351 | } | 369 | } |
352 | else | 370 | else |
353 | emit selected(QString::null); | 371 | emit selected(QString::null); |
354 | } | 372 | } |
355 | QStringList KAddressBookCardView::selectedUids() | 373 | QStringList KAddressBookCardView::selectedUids() |
356 | { | 374 | { |
357 | QStringList uidList; | 375 | QStringList uidList; |
358 | CardViewItem *item; | 376 | CardViewItem *item; |
359 | AddresseeCardViewItem *aItem; | 377 | AddresseeCardViewItem *aItem; |
360 | 378 | ||
361 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 379 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
362 | { | 380 | { |
363 | if (item->isSelected()) | 381 | if (item->isSelected()) |
364 | { | 382 | { |
365 | #ifndef KAB_EMBEDDED | 383 | #ifndef KAB_EMBEDDED |
366 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 384 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
367 | #else //KAB_EMBEDDED | 385 | #else //KAB_EMBEDDED |
368 | aItem = (AddresseeCardViewItem*)(item); | 386 | aItem = (AddresseeCardViewItem*)(item); |
369 | #endif //KAB_EMBEDDED | 387 | #endif //KAB_EMBEDDED |
370 | if (aItem) | 388 | if (aItem) |
371 | uidList << aItem->addressee().uid(); | 389 | uidList << aItem->addressee().uid(); |
372 | } | 390 | } |
373 | } | 391 | } |
374 | 392 | ||
375 | return uidList; | 393 | return uidList; |
376 | } | 394 | } |
377 | 395 | ||
378 | void KAddressBookCardView::refresh(QString uid) | 396 | void KAddressBookCardView::refresh(QString uid) |
379 | { | 397 | { |
380 | CardViewItem *item; | 398 | CardViewItem *item; |
381 | AddresseeCardViewItem *aItem; | 399 | AddresseeCardViewItem *aItem; |
382 | 400 | ||
383 | if (uid.isNull()) | 401 | if (uid.isNull()) |
384 | { | 402 | { |
385 | // Rebuild the view | 403 | // Rebuild the view |
386 | mCardView->viewport()->setUpdatesEnabled( false ); | 404 | mCardView->viewport()->setUpdatesEnabled( false ); |
387 | mCardView->clear(); | 405 | mCardView->clear(); |
388 | 406 | ||
389 | KABC::Addressee::List addresseeList = addressees(); | 407 | KABC::Addressee::List addresseeList = addressees(); |
390 | KABC::Addressee::List::Iterator iter; | 408 | KABC::Addressee::List::Iterator iter; |
391 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 409 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |