Diffstat (limited to 'kaddressbook/views/kaddressbookcardview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 239429f..49c0691 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp @@ -112,12 +112,13 @@ AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) } AddresseeCardView::~AddresseeCardView() { } + void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) { #ifndef KAB_EMBEDDED if (QTextDrag::canDecode(e)) e->accept(); #else //KAB_EMBEDDED @@ -237,13 +238,63 @@ void KAddressBookCardView::readConfig(KConfig *config) void KAddressBookCardView::writeConfig( KConfig *config ) { config->writeEntry( "ItemWidth", mCardView->itemWidth() ); KAddressBookView::writeConfig( config ); } - +void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) +{ + mCardView->clear(); + if ( s.isEmpty() || s == "*" ) { + refresh(); + return; + } + QString pattern = s.lower()+"*"; + QRegExp re; + re.setWildcard(true); // most people understand these better. + re.setCaseSensitive(false); + re.setPattern( pattern ); + if (!re.isValid()) + return; + mCardView->viewport()->setUpdatesEnabled( false ); + KABC::Addressee::List addresseeList = addressees(); + KABC::Addressee::List::Iterator it; + if ( field ) { + for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { +#if QT_VERSION >= 300 + if (re.search(field->value( *it ).lower()) != -1) +#else + if (re.match(field->value( *it ).lower()) != -1) +#endif + new AddresseeCardViewItem(fields(), mShowEmptyFields, + addressBook(), *it, mCardView); + + } + } else { + KABC::Field::List fieldList = fields(); + KABC::Field::List::ConstIterator fieldIt; + for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { + for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { +#if QT_VERSION >= 300 + if (re.search((*fieldIt)->value( *it ).lower()) != -1) +#else + if (re.match((*fieldIt)->value( *it ).lower()) != -1) +#endif + { + new AddresseeCardViewItem(fields(), mShowEmptyFields, + addressBook(), *it, mCardView); + continue; + } + } + } + } + mCardView->viewport()->setUpdatesEnabled( true ); + mCardView->viewport()->update(); + // by default nothing is selected + emit selected(QString::null); +} QStringList KAddressBookCardView::selectedUids() { QStringList uidList; CardViewItem *item; AddresseeCardViewItem *aItem; |