summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-09-03 09:23:23 (UTC)
committer zautrix <zautrix>2004-09-03 09:23:23 (UTC)
commitd171ed3b09665db0f511310d6c84a23d75135f50 (patch) (side-by-side diff)
tree557b3fd423a022559971ceafa61def5adbb7e828 /kaddressbook
parentf6b72fd55671131cd81a3357940c9337ea5d7494 (diff)
downloadkdepimpi-d171ed3b09665db0f511310d6c84a23d75135f50.zip
kdepimpi-d171ed3b09665db0f511310d6c84a23d75135f50.tar.gz
kdepimpi-d171ed3b09665db0f511310d6c84a23d75135f50.tar.bz2
Much better search possibility in kapi
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp7
-rw-r--r--kaddressbook/kabcore.cpp42
-rw-r--r--kaddressbook/viewmanager.cpp7
-rw-r--r--kaddressbook/viewmanager.h1
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp6
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
@@ -69,8 +69,11 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
+#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& ) ),
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,6 +849,14 @@ 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
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 45c7b55..c93d51a 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -180,2 +180,9 @@ 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
@@ -64,2 +64,3 @@ class ViewManager : public QWidget
KABC::Addressee::List selectedAddressees() const;
+ void setListSelected(QStringList);
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
@@ -124,2 +124,5 @@ void KAddressBookTableView::readConfig(KConfig *config)
KAddressBookView::readConfig( config );
+ // The config could have changed the fields, so we need to reconstruct
+ // the listview.
+ reconstructListView();
@@ -169,5 +172,2 @@ void KAddressBookTableView::readConfig(KConfig *config)
- // The config could have changed the fields, so we need to reconstruct
- // the listview.
- reconstructListView();