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
@@ -98,12 +98,39 @@ QStringList Address::asList()
if ( ! mRegion.isEmpty())result.append(mRegion);
if ( ! mPostalCode.isEmpty())result.append(mPostalCode);
if ( ! mCountry.isEmpty())result.append(mCountry);
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();
}
void Address::setId( const QString &id )
diff --git a/kabc/address.h b/kabc/address.h
index 37dd851..38ad20b 100644
--- a/kabc/address.h
+++ b/kabc/address.h
@@ -27,12 +27,13 @@ $Id$
#ifndef KABC_ADDRESS_H
#define KABC_ADDRESS_H
#include <qmap.h>
#include <qstring.h>
+#include <qregexp.h>
#include <qstringlist.h>
#include <qvaluelist.h>
// template tags for address formatting localization
#define KABC_FMTTAG_realname QString("%n")
#define KABC_FMTTAG_REALNAME QString("%N")
@@ -92,12 +93,13 @@ class Address
/**
This is like @ref Address() just above, with the difference
that you can specify the type.
*/
Address( int );
+ bool matchAddress( QRegExp* searchExp ) const;
bool operator==( const Address & ) const;
bool operator!=( const Address & ) const;
/**
Returns true, if the address is empty.
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 155ce24..7e1e414 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -303,13 +303,38 @@ void Addressee::computeCsum(const QString &dev)
qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
#endif
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.
//if isSubSet (e.g. mobile phone sync) merge all fields
detach();
diff --git a/kabc/addressee.h b/kabc/addressee.h
index a2fbcf5..d1c07cb 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -28,12 +28,13 @@ $Id$
#ifndef KABC_ADDRESSEE_H
#define KABC_ADDRESSEE_H
#include <qdatetime.h>
#include <qstring.h>
+#include <qregexp.h>
#include <qstringlist.h>
#include <qvaluelist.h>
#include <ksharedptr.h>
#include <kurl.h>
@@ -647,12 +648,15 @@ class Addressee
/**
Return phone number, which matches the given type.
*/
PhoneNumber phoneNumber( int type ) const;
+ bool matchPhoneNumber( QRegExp* searchExp ) const;
+ bool matchAddress( QRegExp* searchExp ) const;
+
/**
Return list of all phone numbers.
*/
PhoneNumber::List phoneNumbers() const;
/**
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
@@ -326,21 +326,39 @@ void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
} else {
KABC::Field::List fieldList = allFields();
KABC::Field::List::ConstIterator fieldIt;
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)
#else
if (re.match((*fieldIt)->value( *it ).lower()) == 0)
#endif
{
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;
}
}
}
}
mCardView->viewport()->setUpdatesEnabled( true );
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
@@ -147,32 +147,45 @@ class AddresseeIconViewItem : public QIconViewItem
mAddressee = mDocument->findByUid(mAddressee.uid());
if (!mAddressee.isEmpty())
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();
if ( pic.isIntern() && !pic.data().isNull() ) {
QImage img = pic.data();
#ifndef KAB_EMBEDDED
if ( img.width() > img.height() )
icon = img.scaleWidth( 32 );
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 );
}
private:
KABC::Field::List mFields;
KABC::AddressBook *mDocument;
@@ -280,20 +293,36 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
} else {
KABC::Field::List fieldList = allFields();
KABC::Field::List::ConstIterator fieldIt;
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)
#else
if (re.match((*fieldIt)->value( *it ).lower()) == 0)
#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;
}
}
}
}
mIconView->arrangeItemsInGrid( true );
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
@@ -167,21 +167,37 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
} else {
KABC::Field::List fieldList = allFields();
KABC::Field::List::ConstIterator fieldIt;
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)
#else
if (re.match((*fieldIt)->value( *it ).lower()) == 0)
#endif
{
//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;
}
}
}
}
// Sometimes the background pixmap gets messed up when we add lots