author | zautrix <zautrix> | 2004-09-09 20:39:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-09 20:39:55 (UTC) |
commit | 480ffef4859d24cc0a936377f8983fd59312d4b6 (patch) (side-by-side diff) | |
tree | 9661e8b5e892ef653ffc2ed630dbe89acfeb4851 /kaddressbook/views/kaddressbookiconview.cpp | |
parent | 880518b6f1d4b06e3df45224c244d9c62f6fb7a9 (diff) | |
download | kdepimpi-480ffef4859d24cc0a936377f8983fd59312d4b6.zip kdepimpi-480ffef4859d24cc0a936377f8983fd59312d4b6.tar.gz kdepimpi-480ffef4859d24cc0a936377f8983fd59312d4b6.tar.bz2 |
Added senseful searching in Kapi
Diffstat (limited to 'kaddressbook/views/kaddressbookiconview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index 50ff285..78d63b0 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp @@ -96,6 +96,7 @@ AddresseeIconView::~AddresseeIconView() { } + void AddresseeIconView::itemDropped(QDropEvent *e, const QValueList<QIconDragItem> &) { @@ -232,7 +233,53 @@ void KAddressBookIconView::readConfig(KConfig *config) this, SLOT(addresseeExecuted(QIconViewItem *))); } +void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) +{ + mIconView->clear(); + mIconList.clear(); + if ( s.isEmpty() || s == "*" ) { + refresh(); + return; + } + QString pattern = s.lower()+"*"; + QRegExp re; + re.setWildcard(true); // most people understand these better. + re.setCaseSensitive(false); + re.setPattern( pattern ); + if (!re.isValid()) + return; + KABC::Addressee::List addresseeList = addressees(); + KABC::Addressee::List::Iterator it; + if ( field ) { + for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { +#if QT_VERSION >= 300 + if (re.search(field->value( *it ).lower()) != -1) +#else + if (re.match(field->value( *it ).lower()) != -1) +#endif + mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); + + } + } else { + KABC::Field::List fieldList = fields(); + KABC::Field::List::ConstIterator fieldIt; + for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { + for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { +#if QT_VERSION >= 300 + if (re.search((*fieldIt)->value( *it ).lower()) != -1) +#else + if (re.match((*fieldIt)->value( *it ).lower()) != -1) +#endif + { + mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); + continue; + } + } + } + } + mIconView->arrangeItemsInGrid( true ); +} QStringList KAddressBookIconView::selectedUids() { QStringList uidList; |