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 @@ -93,12 +93,13 @@ AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) } AddresseeIconView::~AddresseeIconView() { } + void AddresseeIconView::itemDropped(QDropEvent *e, const QValueList<QIconDragItem> &) { emit addresseeDropped(e); } @@ -229,13 +230,59 @@ void KAddressBookIconView::readConfig(KConfig *config) this, SLOT(addresseeExecuted(QIconViewItem *))); */ connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 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; QIconViewItem *item; AddresseeIconViewItem *aItem; |