-rw-r--r-- | kaddressbook/incsearchwidget.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 42 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 6 |
5 files changed, 48 insertions, 15 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp index 94c37e7..2ffa357 100644 --- a/kaddressbook/incsearchwidget.cpp +++ b/kaddressbook/incsearchwidget.cpp @@ -68,10 +68,13 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) // #endif //KAB_EMBEDDED +#ifdef DESKTOP_VERSION + // for performance reasons, we do a search on the pda only after return is pressed connect( mSearchText, SIGNAL( textChanged( const QString& ) ), SLOT( announceDoSearch() ) ); - connect( mSearchText, SIGNAL( returnPressed() ), - SLOT( announceDoSearch() ) ); connect( mFieldCombo, SIGNAL( activated( const QString& ) ), SLOT( announceDoSearch() ) ); +#endif + connect( mSearchText, SIGNAL( returnPressed() ), + SLOT( announceDoSearch() ) ); connect( mFieldCombo, SIGNAL( activated( const QString& ) ), SLOT( announceFieldChanged() ) ); diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f0f08f4..4299ebd 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -834,7 +834,12 @@ void KABCore::incrementalSearch( const QString& text ) if ( !text.isEmpty() ) { KABC::Field *field = mIncSearchWidget->currentField(); - - QString pattern = text.lower(); - + 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() ); @@ -843,8 +848,16 @@ void KABCore::incrementalSearch( const QString& text ) KABC::AddresseeList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { - if ( field->value( *it ).lower().startsWith( pattern ) ) { - mViewManager->setSelected( (*it).uid(), true ); - return; - } + +#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 { @@ -854,11 +867,20 @@ void KABCore::incrementalSearch( const QString& text ) 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; +#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; diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 45c7b55..c93d51a 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp @@ -179,4 +179,11 @@ void ViewManager::setSelected( const QString &uid, bool selected ) } +void ViewManager::setListSelected(QStringList list) +{ + int i, count = list.count(); + for ( i = 0; i < count;++i ) + setSelected( list[i], true ); + +} void ViewManager::unloadViews() { diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index a18e87d..97c2275 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h @@ -63,4 +63,5 @@ class ViewManager : public QWidget QStringList selectedEmails() const; KABC::Addressee::List selectedAddressees() const; + void setListSelected(QStringList); public slots: diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 66a3f0b..0847b64 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -123,4 +123,7 @@ void KAddressBookTableView::readConfig(KConfig *config) { KAddressBookView::readConfig( config ); + // The config could have changed the fields, so we need to reconstruct + // the listview. + reconstructListView(); // costum colors? @@ -168,7 +171,4 @@ void KAddressBookTableView::readConfig(KConfig *config) - // The config could have changed the fields, so we need to reconstruct - // the listview. - reconstructListView(); // Set the list view options |