author | zautrix <zautrix> | 2004-09-03 09:23:23 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-03 09:23:23 (UTC) |
commit | d171ed3b09665db0f511310d6c84a23d75135f50 (patch) (side-by-side diff) | |
tree | 557b3fd423a022559971ceafa61def5adbb7e828 /kaddressbook/kabcore.cpp | |
parent | f6b72fd55671131cd81a3357940c9337ea5d7494 (diff) | |
download | kdepimpi-d171ed3b09665db0f511310d6c84a23d75135f50.zip kdepimpi-d171ed3b09665db0f511310d6c84a23d75135f50.tar.gz kdepimpi-d171ed3b09665db0f511310d6c84a23d75135f50.tar.bz2 |
Much better search possibility in kapi
-rw-r--r-- | kaddressbook/kabcore.cpp | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f0f08f4..4299ebd 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -835,5 +835,10 @@ void KABCore::incrementalSearch( const QString& text ) 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 @@ -844,5 +849,13 @@ void KABCore::incrementalSearch( const QString& text ) 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; } @@ -855,5 +868,12 @@ void KABCore::incrementalSearch( const QString& text ) 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; } @@ -862,2 +882,4 @@ void KABCore::incrementalSearch( const QString& text ) } + if ( foundUids.count() > 0 ) + mViewManager->setListSelected( foundUids ); #else |