summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/address.cpp27
-rw-r--r--kabc/address.h2
-rw-r--r--kabc/addressee.cpp25
-rw-r--r--kabc/addressee.h4
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp18
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp39
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp16
7 files changed, 126 insertions, 5 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp
index 5ffe511..6151f9e 100644
--- a/kabc/address.cpp
+++ b/kabc/address.cpp
@@ -101,6 +101,33 @@ QStringList Address::asList()
if ( ! mLabel.isEmpty() )result.append(mLabel);
return result;
}
+
+bool Address::matchAddress( QRegExp* re ) const
+{
+
+#if QT_VERSION >= 0x030000
+ if (re->search( mPostOfficeBox ) == 0) return true;
+ if (re->search( mExtended ) == 0) return true;
+ if (re->search( mStreet ) == 0) return true;
+ if (re->search( mLocality ) == 0) return true;
+ if (re->search( mRegion ) == 0) return true;
+ if (re->search( mPostalCode ) == 0) return true;
+ if (re->search( mCountry ) == 0) return true;
+ if (re->search( mLabel ) == 0) return true;
+#else
+ if (re->match( mPostOfficeBox ) == 0) return true;
+ if (re->match( mExtended ) == 0) return true;
+ if (re->match( mStreet ) == 0) return true;
+ if (re->match( mLocality ) == 0) return true;
+ if (re->match( mRegion ) == 0) return true;
+ if (re->match( mPostalCode ) == 0) return true;
+ if (re->match( mCountry ) == 0) return true;
+ if (re->match( mLabel ) == 0) return true;
+#endif
+
+ return false;
+}
+
void Address::clear()
{
*this = Address();
diff --git a/kabc/address.h b/kabc/address.h
index 37dd851..38ad20b 100644
--- a/kabc/address.h
+++ b/kabc/address.h
@@ -30,6 +30,7 @@ $Id$
#include <qmap.h>
#include <qstring.h>
+#include <qregexp.h>
#include <qstringlist.h>
#include <qvaluelist.h>
@@ -95,6 +96,7 @@ class Address
that you can specify the type.
*/
Address( int );
+ bool matchAddress( QRegExp* searchExp ) const;
bool operator==( const Address & ) const;
bool operator!=( const Address & ) const;
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 155ce24..7e1e414 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -306,7 +306,32 @@ void Addressee::computeCsum(const QString &dev)
setCsum( dev, QString::number (cs ));
}
+bool Addressee::matchAddress( QRegExp* re ) const
+{
+ KABC::Address::List::Iterator addressIter;
+ for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
+ ++addressIter ) {
+ if ( (*addressIter).matchAddress( re ) )
+ return true;
+ }
+ return false;
+}
+bool Addressee::matchPhoneNumber( QRegExp* re ) const
+{
+ KABC::PhoneNumber::List::Iterator phoneIter;
+
+ for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) {
+#if QT_VERSION >= 0x030000
+ if (re->search( (*phoneIter).number() ) == 0)
+#else
+ if (re->match( (*phoneIter).number() ) == 0)
+#endif
+ return true;
+ }
+ return false;
+
+}
void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
{
// merge all standard non-outlook fields.
diff --git a/kabc/addressee.h b/kabc/addressee.h
index a2fbcf5..d1c07cb 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -31,6 +31,7 @@ $Id$
#include <qdatetime.h>
#include <qstring.h>
+#include <qregexp.h>
#include <qstringlist.h>
#include <qvaluelist.h>
@@ -650,6 +651,9 @@ class Addressee
*/
PhoneNumber phoneNumber( int type ) const;
+ bool matchPhoneNumber( QRegExp* searchExp ) const;
+ bool matchAddress( QRegExp* searchExp ) const;
+
/**
Return list of all phone numbers.
*/
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index ca21016..b503652 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -329,6 +329,7 @@ void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
continue;
+ bool match = false;
for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
#if QT_VERSION >= 0x030000
if (re.search((*fieldIt)->value( *it ).lower()) == 0)
@@ -338,6 +339,23 @@ void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
{
new AddresseeCardViewItem(fields(), mShowEmptyFields,
addressBook(), *it, mCardView);
+ match = true;
+ break;
+ }
+ }
+ if ( ! match ) {
+ if ( (*it).matchPhoneNumber( &re ) ) {
+ new AddresseeCardViewItem(fields(), mShowEmptyFields,
+ addressBook(), *it, mCardView);
+ match = true;
+ break;
+ }
+ }
+ if ( ! match ) {
+ if ( (*it).matchAddress( &re ) ) {
+ new AddresseeCardViewItem(fields(), mShowEmptyFields,
+ addressBook(), *it, mCardView);
+ match = true;
break;
}
}
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index 4bbdf1d..d6ddec3 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -150,7 +150,7 @@ class AddresseeIconViewItem : public QIconViewItem
setText( mAddressee.givenName() + " " + mAddressee.familyName() );
QPixmap icon;
- QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) );
+
KABC::Picture pic = mAddressee.photo();
if ( pic.data().isNull() )
pic = mAddressee.logo();
@@ -163,13 +163,26 @@ class AddresseeIconViewItem : public QIconViewItem
else
icon = img.scaleHeight( 32 );
#else //KAB_EMBEDDED
+
+ int wid = pic.data().width();
+ int hei = pic.data().height();
+ int max = 48;
+ if ( wid > max || hei > max ) {
+ if ( wid > hei ) {
+ hei = (hei*max)/wid;
+ wid = max;
+ } else {
+ wid = (wid*max)/hei;
+ hei = max;
+ }
+ }
qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor");
- icon.convertFromImage(img.smoothScale(32, 32));
+ icon.convertFromImage(img.smoothScale(wid, hei));
#endif //KAB_EMBEDDED
- } else
- icon = defaultIcon;
-
+ } else {
+ icon = KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 );
+ }
setPixmap( icon );
}
@@ -283,6 +296,7 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
continue;
+ bool match = false;
for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
#if QT_VERSION >= 0x030000
if (re.search((*fieldIt)->value( *it ).lower()) == 0)
@@ -291,6 +305,21 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
#endif
{
mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
+ match = true;
+ break;
+ }
+ }
+ if ( ! match ) {
+ if ( (*it).matchPhoneNumber( &re ) ) {
+ mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
+ match = true;
+ break;
+ }
+ }
+ if ( ! match ) {
+ if ( (*it).matchAddress( &re ) ) {
+ mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
+ match = true;
break;
}
}
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 348f491..02fc40a 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -170,6 +170,7 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
continue;
+ bool match = false;
for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
#if QT_VERSION >= 0x030000
if (re.search((*fieldIt)->value( *it ).lower()) == 0)
@@ -179,6 +180,21 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
{
//qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() );
ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
+ match = true;
+ break;
+ }
+ }
+ if ( ! match ) {
+ if ( (*it).matchPhoneNumber( &re ) ) {
+ ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
+ match = true;
+ break;
+ }
+ }
+ if ( ! match ) {
+ if ( (*it).matchAddress( &re ) ) {
+ ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
+ match = true;
break;
}
}