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) (show whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp7
-rw-r--r--kaddressbook/kabcore.cpp40
-rw-r--r--kaddressbook/viewmanager.cpp7
-rw-r--r--kaddressbook/viewmanager.h1
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp6
5 files changed, 47 insertions, 14 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index 94c37e7..2ffa357 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -64,18 +64,21 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
// #ifndef KAB_EMBEDDED
// resize( QSize(420, 50).expandedTo( sizeHint() ) );
// #else //KAB_EMBEDDED
// 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() ) );
setFocusProxy( mSearchText );
}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index f0f08f4..4299ebd 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -830,39 +830,61 @@ void KABCore::setSearchFields( const KABC::Field::List &fields )
void KABCore::incrementalSearch( const QString& text )
{
mViewManager->setSelected( QString::null, false );
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;
for ( it = list.begin(); it != list.end(); ++it ) {
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 ) {
if ( field ) {
if ( field->value( *it ).lower().startsWith( pattern ) ) {
mViewManager->setSelected( (*it).uid(), true );
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 45c7b55..c93d51a 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -175,12 +175,19 @@ void ViewManager::setSelected()
void ViewManager::setSelected( const QString &uid, bool selected )
{
if ( mActiveView )
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();
mActiveView = 0;
}
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index a18e87d..97c2275 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -59,12 +59,13 @@ class ViewManager : public QWidget
void unloadViews();
KSelectAction * getFilterAction() { return mActionSelectFilter; }
QStringList selectedUids() const;
QStringList selectedEmails() const;
KABC::Addressee::List selectedAddressees() const;
+ void setListSelected(QStringList);
public slots:
//US void setSelected( const QString &uid = QString::null, bool selected = true );
void setSelected( const QString &uid, bool);
//US added another method with no parameter, since my moc compiler does not support default parameters.
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
@@ -119,12 +119,15 @@ void KAddressBookTableView::writeConfig(KConfig *config)
mListView->saveLayout(config, config->group());
}
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 ) )
{
QPalette p( mListView->palette() );
QColor c = p.color(QPalette::Normal, QColorGroup::Base );
@@ -164,15 +167,12 @@ void KAddressBookTableView::readConfig(KConfig *config)
// mListView->setHeaderFont( f );
}
- // 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",
true));
mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));