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
@@ -67,12 +67,15 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
// resize( QSize(30, 10).expandedTo( sizeHint() ) );
// #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
@@ -833,19 +833,32 @@ 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() );
if ( field ) {
list.sortByField( field );
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 {
KABC::AddresseeList::Iterator it;
@@ -853,13 +866,22 @@ void KABCore::incrementalSearch( const QString& text )
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;
+#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 ) {
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 45c7b55..c93d51a 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -178,6 +178,13 @@ void ViewManager::setSelected( const QString &uid, bool selected )
mActiveView->setSelected( uid, selected );
}
+void ViewManager::setListSelected(QStringList list)
+{
+ int i, count = list.count();
+ for ( i = 0; i < count;++i )
+ setSelected( list[i], true );
+
+}
void ViewManager::unloadViews()
{
mViewDict.clear();
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index a18e87d..97c2275 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -62,6 +62,7 @@ class ViewManager : public QWidget
QStringList selectedUids() const;
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
@@ -122,6 +122,9 @@ void KAddressBookTableView::writeConfig(KConfig *config)
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?
if ( config->readBoolEntry( "EnableCustomColors", false ) )
@@ -167,9 +170,6 @@ 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
mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",