author | zautrix <zautrix> | 2004-09-09 20:39:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-09 20:39:55 (UTC) |
commit | 480ffef4859d24cc0a936377f8983fd59312d4b6 (patch) (side-by-side diff) | |
tree | 9661e8b5e892ef653ffc2ed630dbe89acfeb4851 /kaddressbook/kabcore.cpp | |
parent | 880518b6f1d4b06e3df45224c244d9c62f6fb7a9 (diff) | |
download | kdepimpi-480ffef4859d24cc0a936377f8983fd59312d4b6.zip kdepimpi-480ffef4859d24cc0a936377f8983fd59312d4b6.tar.gz kdepimpi-480ffef4859d24cc0a936377f8983fd59312d4b6.tar.bz2 |
Added senseful searching in Kapi
-rw-r--r-- | kaddressbook/kabcore.cpp | 75 |
1 files changed, 1 insertions, 74 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 1a1bcff..2a2f904 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -840,98 +840,25 @@ void KABCore::setCategories() if ( uids.count() > 0 ) setModified( true ); } void KABCore::setSearchFields( const KABC::Field::List &fields ) { mIncSearchWidget->setFields( fields ); } void KABCore::incrementalSearch( const QString& text ) { - mViewManager->setSelected( QString::null, false ); - - if ( !text.isEmpty() ) { - KABC::Field *field = mIncSearchWidget->currentField(); - QString pattern = text.lower()+"*"; - QRegExp re; - re.setWildcard(true); // most people understand these better. - re.setCaseSensitive(false); - re.setPattern( pattern ); - QStringList foundUids; - if (!re.isValid()) - return; -#if 1 //KDE_VERSION >= 319 - KABC::AddresseeList list( mAddressBook->allAddressees() ); - if ( field ) { - list.sortByField( field ); - KABC::AddresseeList::Iterator it; - for ( it = list.begin(); it != list.end(); ++it ) { - -#if QT_VERSION >= 300 - if (re.search(field->value( *it ).lower()) != -1) -#else - if (re.match(field->value( *it ).lower()) != -1) -#endif - { - // if ( field->value( *it ).lower().startsWith( pattern ) ) { - //mViewManager->setSelected( (*it).uid(), true ); - foundUids.append( (*it).uid() ); - //return; - } - } - } else { - KABC::AddresseeList::Iterator it; - for ( it = list.begin(); it != list.end(); ++it ) { - KABC::Field::List fieldList = mIncSearchWidget->fields(); - KABC::Field::List::ConstIterator fieldIt; - 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 - { - // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { - //mViewManager->setSelected( (*it).uid(), true ); - foundUids.append( (*it).uid() ); - //return; - } - } - } - } - if ( foundUids.count() > 0 ) - mViewManager->setListSelected( foundUids ); -#else - KABC::AddressBook::Iterator it; - for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { - if ( field ) { - if ( field->value( *it ).lower().startsWith( pattern ) ) { - mViewManager->setSelected( (*it).uid(), true ); - return; - } - } else { - KABC::Field::List fieldList = mIncSearchWidget->fields(); - KABC::Field::List::ConstIterator fieldIt; - for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { - if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { - mViewManager->setSelected( (*it).uid(), true ); - return; - } - } - } - } -#endif - } + mViewManager->doSearch( text, mIncSearchWidget->currentField() ); } void KABCore::setModified() { setModified( true ); } void KABCore::setModifiedWOrefresh() { // qDebug("KABCore::setModifiedWOrefresh() "); mModified = true; mActionSave->setEnabled( mModified ); |