summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views/kaddressbookcardview.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/views/kaddressbookcardview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 239429f..49c0691 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -115,6 +115,7 @@ AddresseeCardView::~AddresseeCardView()
{
}
+
void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
{
#ifndef KAB_EMBEDDED
@@ -240,7 +241,57 @@ void KAddressBookCardView::writeConfig( KConfig *config )
config->writeEntry( "ItemWidth", mCardView->itemWidth() );
KAddressBookView::writeConfig( config );
}
+void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
+{
+ mCardView->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;
+ mCardView->viewport()->setUpdatesEnabled( false );
+ 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
+ new AddresseeCardViewItem(fields(), mShowEmptyFields,
+ addressBook(), *it, mCardView);
+ }
+ } 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
+ {
+ new AddresseeCardViewItem(fields(), mShowEmptyFields,
+ addressBook(), *it, mCardView);
+ continue;
+ }
+ }
+ }
+ }
+ mCardView->viewport()->setUpdatesEnabled( true );
+ mCardView->viewport()->update();
+ // by default nothing is selected
+ emit selected(QString::null);
+}
QStringList KAddressBookCardView::selectedUids()
{
QStringList uidList;