-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 | |||
@@ -848,82 +848,9 @@ void KABCore::setSearchFields( const KABC::Field::List &fields ) | |||
848 | } | 848 | } |
849 | 849 | ||
850 | void KABCore::incrementalSearch( const QString& text ) | 850 | void KABCore::incrementalSearch( const QString& text ) |
851 | { | 851 | { |
852 | mViewManager->setSelected( QString::null, false ); | 852 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
853 | |||
854 | if ( !text.isEmpty() ) { | ||
855 | KABC::Field *field = mIncSearchWidget->currentField(); | ||
856 | QString pattern = text.lower()+"*"; | ||
857 | QRegExp re; | ||
858 | re.setWildcard(true); // most people understand these better. | ||
859 | re.setCaseSensitive(false); | ||
860 | re.setPattern( pattern ); | ||
861 | QStringList foundUids; | ||
862 | if (!re.isValid()) | ||
863 | return; | ||
864 | #if 1 //KDE_VERSION >= 319 | ||
865 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | ||
866 | if ( field ) { | ||
867 | list.sortByField( field ); | ||
868 | KABC::AddresseeList::Iterator it; | ||
869 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
870 | |||
871 | #if QT_VERSION >= 300 | ||
872 | if (re.search(field->value( *it ).lower()) != -1) | ||
873 | #else | ||
874 | if (re.match(field->value( *it ).lower()) != -1) | ||
875 | #endif | ||
876 | { | ||
877 | // if ( field->value( *it ).lower().startsWith( pattern ) ) { | ||
878 | //mViewManager->setSelected( (*it).uid(), true ); | ||
879 | foundUids.append( (*it).uid() ); | ||
880 | //return; | ||
881 | } | ||
882 | } | ||
883 | } else { | ||
884 | KABC::AddresseeList::Iterator it; | ||
885 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
886 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | ||
887 | KABC::Field::List::ConstIterator fieldIt; | ||
888 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
889 | #if QT_VERSION >= 300 | ||
890 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
891 | #else | ||
892 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
893 | #endif | ||
894 | { | ||
895 | // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | ||
896 | //mViewManager->setSelected( (*it).uid(), true ); | ||
897 | foundUids.append( (*it).uid() ); | ||
898 | //return; | ||
899 | } | ||
900 | } | ||
901 | } | ||
902 | } | ||
903 | if ( foundUids.count() > 0 ) | ||
904 | mViewManager->setListSelected( foundUids ); | ||
905 | #else | ||
906 | KABC::AddressBook::Iterator it; | ||
907 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | ||
908 | if ( field ) { | ||
909 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | ||
910 | mViewManager->setSelected( (*it).uid(), true ); | ||
911 | return; | ||
912 | } | ||
913 | } else { | ||
914 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | ||
915 | KABC::Field::List::ConstIterator fieldIt; | ||
916 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
917 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | ||
918 | mViewManager->setSelected( (*it).uid(), true ); | ||
919 | return; | ||
920 | } | ||
921 | } | ||
922 | } | ||
923 | } | ||
924 | #endif | ||
925 | } | ||
926 | } | 853 | } |
927 | 854 | ||
928 | void KABCore::setModified() | 855 | void KABCore::setModified() |
929 | { | 856 | { |