summaryrefslogtreecommitdiffabout
Unidiff
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()
98 if ( ! mRegion.isEmpty())result.append(mRegion); 98 if ( ! mRegion.isEmpty())result.append(mRegion);
99 if ( ! mPostalCode.isEmpty())result.append(mPostalCode); 99 if ( ! mPostalCode.isEmpty())result.append(mPostalCode);
100 if ( ! mCountry.isEmpty())result.append(mCountry); 100 if ( ! mCountry.isEmpty())result.append(mCountry);
101 if ( ! mLabel.isEmpty() )result.append(mLabel); 101 if ( ! mLabel.isEmpty() )result.append(mLabel);
102 return result; 102 return result;
103} 103}
104
105bool Address::matchAddress( QRegExp* re ) const
106{
107
108#if QT_VERSION >= 0x030000
109 if (re->search( mPostOfficeBox ) == 0) return true;
110 if (re->search( mExtended ) == 0) return true;
111 if (re->search( mStreet ) == 0) return true;
112 if (re->search( mLocality ) == 0) return true;
113 if (re->search( mRegion ) == 0) return true;
114 if (re->search( mPostalCode ) == 0) return true;
115 if (re->search( mCountry ) == 0) return true;
116 if (re->search( mLabel ) == 0) return true;
117#else
118 if (re->match( mPostOfficeBox ) == 0) return true;
119 if (re->match( mExtended ) == 0) return true;
120 if (re->match( mStreet ) == 0) return true;
121 if (re->match( mLocality ) == 0) return true;
122 if (re->match( mRegion ) == 0) return true;
123 if (re->match( mPostalCode ) == 0) return true;
124 if (re->match( mCountry ) == 0) return true;
125 if (re->match( mLabel ) == 0) return true;
126#endif
127
128 return false;
129}
130
104void Address::clear() 131void Address::clear()
105{ 132{
106 *this = Address(); 133 *this = Address();
107} 134}
108 135
109void Address::setId( const QString &id ) 136void 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$
27 27
28#ifndef KABC_ADDRESS_H 28#ifndef KABC_ADDRESS_H
29#define KABC_ADDRESS_H 29#define KABC_ADDRESS_H
30 30
31#include <qmap.h> 31#include <qmap.h>
32#include <qstring.h> 32#include <qstring.h>
33#include <qregexp.h>
33#include <qstringlist.h> 34#include <qstringlist.h>
34#include <qvaluelist.h> 35#include <qvaluelist.h>
35 36
36// template tags for address formatting localization 37// template tags for address formatting localization
37#define KABC_FMTTAG_realname QString("%n") 38#define KABC_FMTTAG_realname QString("%n")
38#define KABC_FMTTAG_REALNAME QString("%N") 39#define KABC_FMTTAG_REALNAME QString("%N")
@@ -92,12 +93,13 @@ class Address
92 93
93 /** 94 /**
94 This is like @ref Address() just above, with the difference 95 This is like @ref Address() just above, with the difference
95 that you can specify the type. 96 that you can specify the type.
96 */ 97 */
97 Address( int ); 98 Address( int );
99 bool matchAddress( QRegExp* searchExp ) const;
98 100
99 bool operator==( const Address & ) const; 101 bool operator==( const Address & ) const;
100 bool operator!=( const Address & ) const; 102 bool operator!=( const Address & ) const;
101 103
102 /** 104 /**
103 Returns true, if the address is empty. 105 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)
303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
304#endif 304#endif
305 305
306 306
307 setCsum( dev, QString::number (cs )); 307 setCsum( dev, QString::number (cs ));
308} 308}
309bool Addressee::matchAddress( QRegExp* re ) const
310{
311 KABC::Address::List::Iterator addressIter;
312 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
313 ++addressIter ) {
314 if ( (*addressIter).matchAddress( re ) )
315 return true;
316 }
317 return false;
318}
319bool Addressee::matchPhoneNumber( QRegExp* re ) const
320{
321 KABC::PhoneNumber::List::Iterator phoneIter;
322
323 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) {
324#if QT_VERSION >= 0x030000
325 if (re->search( (*phoneIter).number() ) == 0)
326#else
327 if (re->match( (*phoneIter).number() ) == 0)
328#endif
329 return true;
309 330
331 }
332 return false;
333
334}
310void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 335void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
311{ 336{
312 // merge all standard non-outlook fields. 337 // merge all standard non-outlook fields.
313 //if isSubSet (e.g. mobile phone sync) merge all fields 338 //if isSubSet (e.g. mobile phone sync) merge all fields
314 339
315 detach(); 340 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$
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qregexp.h>
34#include <qstringlist.h> 35#include <qstringlist.h>
35#include <qvaluelist.h> 36#include <qvaluelist.h>
36 37
37#include <ksharedptr.h> 38#include <ksharedptr.h>
38#include <kurl.h> 39#include <kurl.h>
39 40
@@ -647,12 +648,15 @@ class Addressee
647 648
648 /** 649 /**
649 Return phone number, which matches the given type. 650 Return phone number, which matches the given type.
650 */ 651 */
651 PhoneNumber phoneNumber( int type ) const; 652 PhoneNumber phoneNumber( int type ) const;
652 653
654 bool matchPhoneNumber( QRegExp* searchExp ) const;
655 bool matchAddress( QRegExp* searchExp ) const;
656
653 /** 657 /**
654 Return list of all phone numbers. 658 Return list of all phone numbers.
655 */ 659 */
656 PhoneNumber::List phoneNumbers() const; 660 PhoneNumber::List phoneNumbers() const;
657 661
658 /** 662 /**
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 )
326 } else { 326 } else {
327 KABC::Field::List fieldList = allFields(); 327 KABC::Field::List fieldList = allFields();
328 KABC::Field::List::ConstIterator fieldIt; 328 KABC::Field::List::ConstIterator fieldIt;
329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
331 continue; 331 continue;
332 bool match = false;
332 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 333 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
333#if QT_VERSION >= 0x030000 334#if QT_VERSION >= 0x030000
334 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 335 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
335#else 336#else
336 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 337 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
337#endif 338#endif
338 { 339 {
339 new AddresseeCardViewItem(fields(), mShowEmptyFields, 340 new AddresseeCardViewItem(fields(), mShowEmptyFields,
340 addressBook(), *it, mCardView); 341 addressBook(), *it, mCardView);
342 match = true;
343 break;
344 }
345 }
346 if ( ! match ) {
347 if ( (*it).matchPhoneNumber( &re ) ) {
348 new AddresseeCardViewItem(fields(), mShowEmptyFields,
349 addressBook(), *it, mCardView);
350 match = true;
351 break;
352 }
353 }
354 if ( ! match ) {
355 if ( (*it).matchAddress( &re ) ) {
356 new AddresseeCardViewItem(fields(), mShowEmptyFields,
357 addressBook(), *it, mCardView);
358 match = true;
341 break; 359 break;
342 } 360 }
343 } 361 }
344 } 362 }
345 } 363 }
346 mCardView->viewport()->setUpdatesEnabled( true ); 364 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
147 mAddressee = mDocument->findByUid(mAddressee.uid()); 147 mAddressee = mDocument->findByUid(mAddressee.uid());
148 148
149 if (!mAddressee.isEmpty()) 149 if (!mAddressee.isEmpty())
150 setText( mAddressee.givenName() + " " + mAddressee.familyName() ); 150 setText( mAddressee.givenName() + " " + mAddressee.familyName() );
151 151
152 QPixmap icon; 152 QPixmap icon;
153 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); 153
154 KABC::Picture pic = mAddressee.photo(); 154 KABC::Picture pic = mAddressee.photo();
155 if ( pic.data().isNull() ) 155 if ( pic.data().isNull() )
156 pic = mAddressee.logo(); 156 pic = mAddressee.logo();
157 157
158 if ( pic.isIntern() && !pic.data().isNull() ) { 158 if ( pic.isIntern() && !pic.data().isNull() ) {
159 QImage img = pic.data(); 159 QImage img = pic.data();
160#ifndef KAB_EMBEDDED 160#ifndef KAB_EMBEDDED
161 if ( img.width() > img.height() ) 161 if ( img.width() > img.height() )
162 icon = img.scaleWidth( 32 ); 162 icon = img.scaleWidth( 32 );
163 else 163 else
164 icon = img.scaleHeight( 32 ); 164 icon = img.scaleHeight( 32 );
165#else //KAB_EMBEDDED 165#else //KAB_EMBEDDED
166
167 int wid = pic.data().width();
168 int hei = pic.data().height();
169 int max = 48;
170 if ( wid > max || hei > max ) {
171 if ( wid > hei ) {
172 hei = (hei*max)/wid;
173 wid = max;
174 } else {
175 wid = (wid*max)/hei;
176 hei = max;
177 }
178 }
166 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); 179 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor");
167 icon.convertFromImage(img.smoothScale(32, 32)); 180 icon.convertFromImage(img.smoothScale(wid, hei));
168#endif //KAB_EMBEDDED 181#endif //KAB_EMBEDDED
169 182
170 } else 183 } else {
171 icon = defaultIcon; 184 icon = KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 );
172 185 }
173 setPixmap( icon ); 186 setPixmap( icon );
174 } 187 }
175 188
176 private: 189 private:
177 KABC::Field::List mFields; 190 KABC::Field::List mFields;
178 KABC::AddressBook *mDocument; 191 KABC::AddressBook *mDocument;
@@ -280,20 +293,36 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
280 } else { 293 } else {
281 KABC::Field::List fieldList = allFields(); 294 KABC::Field::List fieldList = allFields();
282 KABC::Field::List::ConstIterator fieldIt; 295 KABC::Field::List::ConstIterator fieldIt;
283 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 296 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
284 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 297 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
285 continue; 298 continue;
299 bool match = false;
286 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 300 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
287#if QT_VERSION >= 0x030000 301#if QT_VERSION >= 0x030000
288 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 302 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
289#else 303#else
290 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 304 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
291#endif 305#endif
292 { 306 {
293 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 307 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
308 match = true;
309 break;
310 }
311 }
312 if ( ! match ) {
313 if ( (*it).matchPhoneNumber( &re ) ) {
314 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
315 match = true;
316 break;
317 }
318 }
319 if ( ! match ) {
320 if ( (*it).matchAddress( &re ) ) {
321 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
322 match = true;
294 break; 323 break;
295 } 324 }
296 } 325 }
297 } 326 }
298 } 327 }
299 mIconView->arrangeItemsInGrid( true ); 328 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 )
167 } else { 167 } else {
168 KABC::Field::List fieldList = allFields(); 168 KABC::Field::List fieldList = allFields();
169 KABC::Field::List::ConstIterator fieldIt; 169 KABC::Field::List::ConstIterator fieldIt;
170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
172 continue; 172 continue;
173 bool match = false;
173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 174 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
174#if QT_VERSION >= 0x030000 175#if QT_VERSION >= 0x030000
175 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 176 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
176#else 177#else
177 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 178 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
178#endif 179#endif
179 { 180 {
180 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); 181 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() );
181 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 182 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
183 match = true;
184 break;
185 }
186 }
187 if ( ! match ) {
188 if ( (*it).matchPhoneNumber( &re ) ) {
189 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
190 match = true;
191 break;
192 }
193 }
194 if ( ! match ) {
195 if ( (*it).matchAddress( &re ) ) {
196 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
197 match = true;
182 break; 198 break;
183 } 199 }
184 } 200 }
185 } 201 }
186 } 202 }
187 // Sometimes the background pixmap gets messed up when we add lots 203 // Sometimes the background pixmap gets messed up when we add lots