summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-08-22 15:42:41 (UTC)
committer zautrix <zautrix>2005-08-22 15:42:41 (UTC)
commit1d82d044bbdedd407f6d08305522187ffd256552 (patch) (unidiff)
tree08f5651d72548b643ed012e5f6ad938b36d1ae3f
parentf516a558e6d18982a54152b28ca3da78fe76e3fc (diff)
downloadkdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.zip
kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.gz
kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.bz2
kapi search fix
Diffstat (more/less context) (ignore 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.cpp22
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp39
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp16
7 files changed, 128 insertions, 7 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp
index 5ffe511..6151f9e 100644
--- a/kabc/address.cpp
+++ b/kabc/address.cpp
@@ -8,192 +8,219 @@
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28//US added kglobal.h 28//US added kglobal.h
29#include <kglobal.h> 29#include <kglobal.h>
30 30
31#include <kapplication.h> 31#include <kapplication.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <ksimpleconfig.h> 34#include <ksimpleconfig.h>
35#include <kstandarddirs.h> 35#include <kstandarddirs.h>
36 36
37#include <qfile.h> 37#include <qfile.h>
38 38
39#include "address.h" 39#include "address.h"
40 40
41using namespace KABC; 41using namespace KABC;
42 42
43QMap<QString, QString> Address::mISOMap; 43QMap<QString, QString> Address::mISOMap;
44 44
45Address::Address() : 45Address::Address() :
46 mEmpty( true ), mType( 0 ) 46 mEmpty( true ), mType( 0 )
47{ 47{
48 mId = KApplication::randomString( 10 ); 48 mId = KApplication::randomString( 10 );
49} 49}
50 50
51Address::Address( int type ) : 51Address::Address( int type ) :
52 mEmpty( true ), mType( type ) 52 mEmpty( true ), mType( type )
53{ 53{
54 mId = KApplication::randomString( 10 ); 54 mId = KApplication::randomString( 10 );
55} 55}
56 56
57bool Address::operator==( const Address &a ) const 57bool Address::operator==( const Address &a ) const
58{ 58{
59 if ( mPostOfficeBox != a.mPostOfficeBox ) return false; 59 if ( mPostOfficeBox != a.mPostOfficeBox ) return false;
60 if ( mExtended != a.mExtended ) return false; 60 if ( mExtended != a.mExtended ) return false;
61 if ( mStreet != a.mStreet ) return false; 61 if ( mStreet != a.mStreet ) return false;
62 if ( mLocality != a.mLocality ) return false; 62 if ( mLocality != a.mLocality ) return false;
63 if ( mRegion != a.mRegion ) return false; 63 if ( mRegion != a.mRegion ) return false;
64 if ( mPostalCode != a.mPostalCode ) return false; 64 if ( mPostalCode != a.mPostalCode ) return false;
65 if ( mCountry != a.mCountry ) return false; 65 if ( mCountry != a.mCountry ) return false;
66 if ( mLabel != a.mLabel ) return false; 66 if ( mLabel != a.mLabel ) return false;
67 67
68 return true; 68 return true;
69} 69}
70 70
71bool Address::operator!=( const Address &a ) const 71bool Address::operator!=( const Address &a ) const
72{ 72{
73 return !( a == *this ); 73 return !( a == *this );
74} 74}
75 75
76bool Address::isEmpty() const 76bool Address::isEmpty() const
77{ 77{
78 if ( mPostOfficeBox.isEmpty() && 78 if ( mPostOfficeBox.isEmpty() &&
79 mExtended.isEmpty() && 79 mExtended.isEmpty() &&
80 mStreet.isEmpty() && 80 mStreet.isEmpty() &&
81 mLocality.isEmpty() && 81 mLocality.isEmpty() &&
82 mRegion.isEmpty() && 82 mRegion.isEmpty() &&
83 mPostalCode.isEmpty() && 83 mPostalCode.isEmpty() &&
84 mCountry.isEmpty() && 84 mCountry.isEmpty() &&
85 mLabel.isEmpty() ) { 85 mLabel.isEmpty() ) {
86 return true; 86 return true;
87 } 87 }
88 return false; 88 return false;
89} 89}
90 90
91QStringList Address::asList() 91QStringList Address::asList()
92{ 92{
93 QStringList result; 93 QStringList result;
94 if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox); 94 if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox);
95 if ( ! mExtended.isEmpty())result.append(mExtended); 95 if ( ! mExtended.isEmpty())result.append(mExtended);
96 if ( ! mStreet.isEmpty())result.append(mStreet); 96 if ( ! mStreet.isEmpty())result.append(mStreet);
97 if ( ! mLocality.isEmpty() )result.append(mLocality); 97 if ( ! mLocality.isEmpty() )result.append(mLocality);
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 )
110{ 137{
111 mEmpty = false; 138 mEmpty = false;
112 139
113 mId = id; 140 mId = id;
114} 141}
115 142
116QString Address::id() const 143QString Address::id() const
117{ 144{
118 return mId; 145 return mId;
119} 146}
120 147
121void Address::setType( int type ) 148void Address::setType( int type )
122{ 149{
123 mEmpty = false; 150 mEmpty = false;
124 151
125 mType = type; 152 mType = type;
126} 153}
127 154
128int Address::type() const 155int Address::type() const
129{ 156{
130 return mType; 157 return mType;
131} 158}
132 159
133QString Address::typeLabel() const 160QString Address::typeLabel() const
134{ 161{
135 QString label; 162 QString label;
136 bool first = true; 163 bool first = true;
137 164
138 TypeList list = typeList(); 165 TypeList list = typeList();
139 166
140 TypeList::Iterator it; 167 TypeList::Iterator it;
141 for ( it = list.begin(); it != list.end(); ++it ) { 168 for ( it = list.begin(); it != list.end(); ++it ) {
142 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 169 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
143 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 170 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
144 if ( first ) 171 if ( first )
145 first = false; 172 first = false;
146 } 173 }
147 } 174 }
148 175
149 return label; 176 return label;
150} 177}
151 178
152void Address::setPostOfficeBox( const QString &s ) 179void Address::setPostOfficeBox( const QString &s )
153{ 180{
154 mEmpty = false; 181 mEmpty = false;
155 182
156 mPostOfficeBox = s; 183 mPostOfficeBox = s;
157} 184}
158 185
159QString Address::postOfficeBox() const 186QString Address::postOfficeBox() const
160{ 187{
161 return mPostOfficeBox; 188 return mPostOfficeBox;
162} 189}
163 190
164QString Address::postOfficeBoxLabel() 191QString Address::postOfficeBoxLabel()
165{ 192{
166 return i18n("Post Office Box"); 193 return i18n("Post Office Box");
167} 194}
168 195
169 196
170void Address::setExtended( const QString &s ) 197void Address::setExtended( const QString &s )
171{ 198{
172 mEmpty = false; 199 mEmpty = false;
173 200
174 mExtended = s; 201 mExtended = s;
175} 202}
176 203
177QString Address::extended() const 204QString Address::extended() const
178{ 205{
179 return mExtended; 206 return mExtended;
180} 207}
181 208
182QString Address::extendedLabel() 209QString Address::extendedLabel()
183{ 210{
184 return i18n("Extended Address Information"); 211 return i18n("Extended Address Information");
185} 212}
186 213
187 214
188void Address::setStreet( const QString &s ) 215void Address::setStreet( const QString &s )
189{ 216{
190 mEmpty = false; 217 mEmpty = false;
191 218
192 mStreet = s; 219 mStreet = s;
193} 220}
194 221
195QString Address::street() const 222QString Address::street() const
196{ 223{
197 return mStreet; 224 return mStreet;
198} 225}
199 226
diff --git a/kabc/address.h b/kabc/address.h
index 37dd851..38ad20b 100644
--- a/kabc/address.h
+++ b/kabc/address.h
@@ -1,193 +1,195 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
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")
39#define KABC_FMTTAG_company QString("%cm") 40#define KABC_FMTTAG_company QString("%cm")
40#define KABC_FMTTAG_COMPANY QString("%CM") 41#define KABC_FMTTAG_COMPANY QString("%CM")
41#define KABC_FMTTAG_pobox QString("%p") 42#define KABC_FMTTAG_pobox QString("%p")
42#define KABC_FMTTAG_street QString("%s") 43#define KABC_FMTTAG_street QString("%s")
43#define KABC_FMTTAG_STREET QString("%S") 44#define KABC_FMTTAG_STREET QString("%S")
44#define KABC_FMTTAG_zipcode QString("%z") 45#define KABC_FMTTAG_zipcode QString("%z")
45#define KABC_FMTTAG_location QString("%l") 46#define KABC_FMTTAG_location QString("%l")
46#define KABC_FMTTAG_LOCATION QString("%L") 47#define KABC_FMTTAG_LOCATION QString("%L")
47#define KABC_FMTTAG_region QString("%r") 48#define KABC_FMTTAG_region QString("%r")
48#define KABC_FMTTAG_REGION QString("%R") 49#define KABC_FMTTAG_REGION QString("%R")
49#define KABC_FMTTAG_newline QString("\\n") 50#define KABC_FMTTAG_newline QString("\\n")
50#define KABC_FMTTAG_condcomma QString("%,") 51#define KABC_FMTTAG_condcomma QString("%,")
51#define KABC_FMTTAG_condwhite QString("%w") 52#define KABC_FMTTAG_condwhite QString("%w")
52#define KABC_FMTTAG_purgeempty QString("%0") 53#define KABC_FMTTAG_purgeempty QString("%0")
53 54
54namespace KABC { 55namespace KABC {
55 56
56/** 57/**
57 @short Postal address information. 58 @short Postal address information.
58 59
59 This class represents information about a postal address. 60 This class represents information about a postal address.
60*/ 61*/
61class Address 62class Address
62{ 63{
63 friend QDataStream &operator<<( QDataStream &, const Address & ); 64 friend QDataStream &operator<<( QDataStream &, const Address & );
64 friend QDataStream &operator>>( QDataStream &, Address & ); 65 friend QDataStream &operator>>( QDataStream &, Address & );
65 66
66 public: 67 public:
67 /** 68 /**
68 List of addresses. 69 List of addresses.
69 */ 70 */
70 typedef QValueList<Address> List; 71 typedef QValueList<Address> List;
71 typedef QValueList<int> TypeList; 72 typedef QValueList<int> TypeList;
72 73
73 /** 74 /**
74 Address types: 75 Address types:
75 76
76 @li @p Dom - domestic 77 @li @p Dom - domestic
77 @li @p Intl - international 78 @li @p Intl - international
78 @li @p Postal - postal 79 @li @p Postal - postal
79 @li @p Parcel - parcel 80 @li @p Parcel - parcel
80 @li @p Home - home address 81 @li @p Home - home address
81 @li @p Work - address at work 82 @li @p Work - address at work
82 @li @p Pref - preferred address 83 @li @p Pref - preferred address
83 */ 84 */
84 enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, 85 enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32,
85 Pref = 64 }; 86 Pref = 64 };
86 87
87 /** 88 /**
88 Constructor that creates an empty Address, which is initialized 89 Constructor that creates an empty Address, which is initialized
89 with a unique id (see @ref id()). 90 with a unique id (see @ref id()).
90 */ 91 */
91 Address(); 92 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.
104 */ 106 */
105 bool isEmpty() const; 107 bool isEmpty() const;
106 108
107 /** 109 /**
108 Clears all entries of the address. 110 Clears all entries of the address.
109 */ 111 */
110 void clear(); 112 void clear();
111 QStringList asList(); 113 QStringList asList();
112 114
113 /** 115 /**
114 Sets the unique id. 116 Sets the unique id.
115 */ 117 */
116 void setId( const QString & ); 118 void setId( const QString & );
117 119
118 /* 120 /*
119 Returns the unique id. 121 Returns the unique id.
120 */ 122 */
121 QString id() const; 123 QString id() const;
122 124
123 /** 125 /**
124 Sets the type of address. See enum for definiton of types. 126 Sets the type of address. See enum for definiton of types.
125 127
126 @param type type, can be a bitwise or of multiple types. 128 @param type type, can be a bitwise or of multiple types.
127 */ 129 */
128 void setType( int type ); 130 void setType( int type );
129 131
130 /** 132 /**
131 Returns the type of address. Can be a bitwise or of multiple types. 133 Returns the type of address. Can be a bitwise or of multiple types.
132 */ 134 */
133 int type() const; 135 int type() const;
134 136
135 /** 137 /**
136 Returns a translated string of all types the address has. 138 Returns a translated string of all types the address has.
137 */ 139 */
138 QString typeLabel() const; 140 QString typeLabel() const;
139 141
140 /** 142 /**
141 Sets the post office box. 143 Sets the post office box.
142 */ 144 */
143 void setPostOfficeBox( const QString & ); 145 void setPostOfficeBox( const QString & );
144 146
145 /** 147 /**
146 Returns the post office box. 148 Returns the post office box.
147 */ 149 */
148 QString postOfficeBox() const; 150 QString postOfficeBox() const;
149 151
150 /** 152 /**
151 Returns the translated label for post office box field. 153 Returns the translated label for post office box field.
152 */ 154 */
153 static QString postOfficeBoxLabel(); 155 static QString postOfficeBoxLabel();
154 156
155 /** 157 /**
156 Sets the extended address information. 158 Sets the extended address information.
157 */ 159 */
158 void setExtended( const QString & ); 160 void setExtended( const QString & );
159 161
160 /** 162 /**
161 Returns the extended address information. 163 Returns the extended address information.
162 */ 164 */
163 QString extended() const; 165 QString extended() const;
164 166
165 /** 167 /**
166 Returns the translated label for extended field. 168 Returns the translated label for extended field.
167 */ 169 */
168 static QString extendedLabel(); 170 static QString extendedLabel();
169 171
170 /** 172 /**
171 Sets the street (including number). 173 Sets the street (including number).
172 */ 174 */
173 void setStreet( const QString & ); 175 void setStreet( const QString & );
174 176
175 /** 177 /**
176 Returns the street. 178 Returns the street.
177 */ 179 */
178 QString street() const; 180 QString street() const;
179 181
180 /** 182 /**
181 Returns the translated label for street field. 183 Returns the translated label for street field.
182 */ 184 */
183 static QString streetLabel(); 185 static QString streetLabel();
184 186
185 /** 187 /**
186 Sets the locality, e.g. city. 188 Sets the locality, e.g. city.
187 */ 189 */
188 void setLocality( const QString & ); 190 void setLocality( const QString & );
189 191
190 /** 192 /**
191 Returns the locality. 193 Returns the locality.
192 */ 194 */
193 QString locality() const; 195 QString locality() const;
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 155ce24..7e1e414 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -213,193 +213,218 @@ void Addressee::computeCsum(const QString &dev)
213 //if ( !mData->name.isEmpty() ) l.append(mData->name); 213 //if ( !mData->name.isEmpty() ) l.append(mData->name);
214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
225 if ( !mData->title .isEmpty() ) l.append( mData->title ); 225 if ( !mData->title .isEmpty() ) l.append( mData->title );
226 if ( !mData->role.isEmpty() ) l.append( mData->role ); 226 if ( !mData->role.isEmpty() ) l.append( mData->role );
227 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 227 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
228 if ( !mData->note.isEmpty() ) l.append( mData->note ); 228 if ( !mData->note.isEmpty() ) l.append( mData->note );
229 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 229 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
232 if ( !mData->logo.undefined() ) { 232 if ( !mData->logo.undefined() ) {
233 if ( !mData->logo.isIntern() ) 233 if ( !mData->logo.isIntern() )
234 l.append( mData->logo.url() ); 234 l.append( mData->logo.url() );
235 else 235 else
236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); 236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height()));
237 } else { 237 } else {
238 l.append( "nologo"); 238 l.append( "nologo");
239 } 239 }
240 if ( !mData->photo.undefined() ) { 240 if ( !mData->photo.undefined() ) {
241 if ( !mData->photo.isIntern() ) 241 if ( !mData->photo.isIntern() )
242 l.append( mData->photo.url() ); 242 l.append( mData->photo.url() );
243 else 243 else
244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); 244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height()));
245 } else { 245 } else {
246 l.append( "nophoto"); 246 l.append( "nophoto");
247 } 247 }
248#if 0 248#if 0
249 if ( !mData->sound.undefined() ) { 249 if ( !mData->sound.undefined() ) {
250 if ( !mData->sound.isIntern() ) 250 if ( !mData->sound.isIntern() )
251 l.append( mData->sound.url() ); 251 l.append( mData->sound.url() );
252 else 252 else
253 l.append( QString(mData->sound.data().with()* mData->sound.data().height())); 253 l.append( QString(mData->sound.data().with()* mData->sound.data().height()));
254 } else { 254 } else {
255 l.append( "nosound"); 255 l.append( "nosound");
256 } 256 }
257#endif 257#endif
258 //if ( !mData->agent.isEmpty() ) l.append( ); 258 //if ( !mData->agent.isEmpty() ) l.append( );
259 if ( mData->url.isValid() ) 259 if ( mData->url.isValid() )
260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
261 KABC::PhoneNumber::List phoneNumbers; 261 KABC::PhoneNumber::List phoneNumbers;
262 KABC::PhoneNumber::List::Iterator phoneIter; 262 KABC::PhoneNumber::List::Iterator phoneIter;
263 263
264 QStringList t; 264 QStringList t;
265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
266 ++phoneIter ) 266 ++phoneIter )
267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
268 t.sort(); 268 t.sort();
269 uint iii; 269 uint iii;
270 for ( iii = 0; iii < t.count(); ++iii) 270 for ( iii = 0; iii < t.count(); ++iii)
271 l.append( t[iii] ); 271 l.append( t[iii] );
272 t = mData->emails; 272 t = mData->emails;
273 t.sort(); 273 t.sort();
274 for ( iii = 0; iii < t.count(); ++iii) 274 for ( iii = 0; iii < t.count(); ++iii)
275 l.append( t[iii] ); 275 l.append( t[iii] );
276 t = mData->categories; 276 t = mData->categories;
277 t.sort(); 277 t.sort();
278 for ( iii = 0; iii < t.count(); ++iii) 278 for ( iii = 0; iii < t.count(); ++iii)
279 l.append( t[iii] ); 279 l.append( t[iii] );
280 t = mData->custom; 280 t = mData->custom;
281 t.sort(); 281 t.sort();
282 for ( iii = 0; iii < t.count(); ++iii) 282 for ( iii = 0; iii < t.count(); ++iii)
283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
284 int find = t[iii].find (':')+1; 284 int find = t[iii].find (':')+1;
285 //qDebug("lennnn %d %d ", find, t[iii].length()); 285 //qDebug("lennnn %d %d ", find, t[iii].length());
286 if ( find < t[iii].length()) 286 if ( find < t[iii].length())
287 l.append( t[iii] ); 287 l.append( t[iii] );
288 288
289 } 289 }
290 KABC::Address::List::Iterator addressIter; 290 KABC::Address::List::Iterator addressIter;
291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
292 ++addressIter ) { 292 ++addressIter ) {
293 t = (*addressIter).asList(); 293 t = (*addressIter).asList();
294 t.sort(); 294 t.sort();
295 for ( iii = 0; iii < t.count(); ++iii) 295 for ( iii = 0; iii < t.count(); ++iii)
296 l.append( t[iii] ); 296 l.append( t[iii] );
297 } 297 }
298 uint cs = getCsum4List(l); 298 uint cs = getCsum4List(l);
299 299
300#if 0 300#if 0
301 for ( iii = 0; iii < l.count(); ++iii) 301 for ( iii = 0; iii < l.count(); ++iii)
302 qDebug("%d***%s***",iii,l[iii].latin1()); 302 qDebug("%d***%s***",iii,l[iii].latin1());
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();
316 if ( isSubSet ) { 341 if ( isSubSet ) {
317 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 342 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
318 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 343 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
319 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 344 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
320 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 345 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
321 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 346 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
322 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 347 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
323 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 348 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
324 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 349 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
325 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 350 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
326 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 351 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
327 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 352 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
328 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 353 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
329 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 354 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
330 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 355 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
331 if ( !mData->birthday.isValid() ) 356 if ( !mData->birthday.isValid() )
332 if ( ad.mData->birthday.isValid()) 357 if ( ad.mData->birthday.isValid())
333 mData->birthday = ad.mData->birthday; 358 mData->birthday = ad.mData->birthday;
334 359
335 } 360 }
336 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 361 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
337 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 362 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
338 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 363 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
339 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 364 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
340 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 365 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
341 QStringList t; 366 QStringList t;
342 QStringList tAD; 367 QStringList tAD;
343 uint iii; 368 uint iii;
344 369
345 // ********** phone numbers 370 // ********** phone numbers
346 if ( isSubSet ) { 371 if ( isSubSet ) {
347 PhoneNumber::List phoneAD = ad.phoneNumbers(); 372 PhoneNumber::List phoneAD = ad.phoneNumbers();
348 PhoneNumber::List::Iterator phoneItAD; 373 PhoneNumber::List::Iterator phoneItAD;
349 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 374 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
350 bool found = false; 375 bool found = false;
351 PhoneNumber::List::Iterator it; 376 PhoneNumber::List::Iterator it;
352 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 377 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
353 if ( ( *phoneItAD ).contains( (*it) ) ) { 378 if ( ( *phoneItAD ).contains( (*it) ) ) {
354 found = true; 379 found = true;
355 (*it).setType( ( *phoneItAD ).type() ); 380 (*it).setType( ( *phoneItAD ).type() );
356 (*it).setNumber( ( *phoneItAD ).number() ); 381 (*it).setNumber( ( *phoneItAD ).number() );
357 break; 382 break;
358 } 383 }
359 } 384 }
360 // if ( isSubSet && ! found ) 385 // if ( isSubSet && ! found )
361 if ( ! found ) // LR try this one... 386 if ( ! found ) // LR try this one...
362 mData->phoneNumbers.append( *phoneItAD ); 387 mData->phoneNumbers.append( *phoneItAD );
363 } 388 }
364 } else { 389 } else {
365 PhoneNumber::List phoneAD = ad.phoneNumbers(); 390 PhoneNumber::List phoneAD = ad.phoneNumbers();
366 PhoneNumber::List::Iterator phoneItAD; 391 PhoneNumber::List::Iterator phoneItAD;
367 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 392 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
368 bool found = false; 393 bool found = false;
369 PhoneNumber::List::Iterator it; 394 PhoneNumber::List::Iterator it;
370 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 395 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
371 if ( ( *phoneItAD ).contains( (*it) ) ) { 396 if ( ( *phoneItAD ).contains( (*it) ) ) {
372 found = true; 397 found = true;
373 (*it).setType( ( *phoneItAD ).type() ); 398 (*it).setType( ( *phoneItAD ).type() );
374 (*it).setNumber( ( *phoneItAD ).number() ); 399 (*it).setNumber( ( *phoneItAD ).number() );
375 break; 400 break;
376 } 401 }
377 } 402 }
378 if ( ! found ) { // append numbers which do not have work or home type 403 if ( ! found ) { // append numbers which do not have work or home type
379 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 404 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
380 mData->phoneNumbers.append( *phoneItAD ); 405 mData->phoneNumbers.append( *phoneItAD );
381 } 406 }
382 } 407 }
383 } 408 }
384 if ( isSubSet ) { 409 if ( isSubSet ) {
385 // ************* emails; 410 // ************* emails;
386 t = mData->emails; 411 t = mData->emails;
387 tAD = ad.mData->emails; 412 tAD = ad.mData->emails;
388 for ( iii = 0; iii < tAD.count(); ++iii) 413 for ( iii = 0; iii < tAD.count(); ++iii)
389 if ( !t.contains(tAD[iii] ) ) 414 if ( !t.contains(tAD[iii] ) )
390 mData->emails.append( tAD[iii] ); 415 mData->emails.append( tAD[iii] );
391 } 416 }
392 417
393 // ************* categories; 418 // ************* categories;
394 if ( isSubSet ) { 419 if ( isSubSet ) {
395 t = mData->categories; 420 t = mData->categories;
396 tAD = ad.mData->categories; 421 tAD = ad.mData->categories;
397 for ( iii = 0; iii < tAD.count(); ++iii) 422 for ( iii = 0; iii < tAD.count(); ++iii)
398 if ( !t.contains(tAD[iii] ) ) 423 if ( !t.contains(tAD[iii] ) )
399 mData->categories.append( tAD[iii] ); 424 mData->categories.append( tAD[iii] );
400 } 425 }
401 QStringList::ConstIterator it; 426 QStringList::ConstIterator it;
402 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 427 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
403 QString qualifiedName = (*it).left( (*it).find( ":" )); 428 QString qualifiedName = (*it).left( (*it).find( ":" ));
404 bool found = false; 429 bool found = false;
405 QStringList::ConstIterator itL; 430 QStringList::ConstIterator itL;
diff --git a/kabc/addressee.h b/kabc/addressee.h
index a2fbcf5..d1c07cb 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,129 +1,130 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
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
40#include "address.h" 41#include "address.h"
41#include "agent.h" 42#include "agent.h"
42#include "geo.h" 43#include "geo.h"
43#include "key.h" 44#include "key.h"
44#include "phonenumber.h" 45#include "phonenumber.h"
45#include "picture.h" 46#include "picture.h"
46#include "secrecy.h" 47#include "secrecy.h"
47#include "sound.h" 48#include "sound.h"
48#include "timezone.h" 49#include "timezone.h"
49 50
50namespace KABC { 51namespace KABC {
51 52
52class Resource; 53class Resource;
53 54
54/** 55/**
55 @short address book entry 56 @short address book entry
56 57
57 This class represents an entry in the address book. 58 This class represents an entry in the address book.
58 59
59 The data of this class is implicitly shared. You can pass this class by value. 60 The data of this class is implicitly shared. You can pass this class by value.
60 61
61 If you need the name of a field for presenting it to the user you should use 62 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 63 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 64 used as label for the corresponding field.
64 65
65 About the name fields: 66 About the name fields:
66 67
67 givenName() is the first name and familyName() the last name. In some 68 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 69 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 70 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 71 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 72 from the other name fields automatically.
72 73
73 realName() returns a fully formatted name(). It uses formattedName, if set, 74 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 75 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 76 nothing else is set it uses name().
76 77
77 name() is the NAME type of RFC2426. It can be used as internal name for the 78 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 79 data enty, but shouldn't be used for displaying the data to the user.
79 */ 80 */
80class Addressee 81class Addressee
81{ 82{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 83 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 84 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 85
85 public: 86 public:
86 typedef QValueList<Addressee> List; 87 typedef QValueList<Addressee> List;
87 88
88 /** 89 /**
89 Construct an empty address book entry. 90 Construct an empty address book entry.
90 */ 91 */
91 Addressee(); 92 Addressee();
92 ~Addressee(); 93 ~Addressee();
93 94
94 Addressee( const Addressee & ); 95 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 96 Addressee &operator=( const Addressee & );
96 97
97 bool operator==( const Addressee & ) const; 98 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 99 bool operator!=( const Addressee & ) const;
99 // sync stuff 100 // sync stuff
100 void setTempSyncStat(int id); 101 void setTempSyncStat(int id);
101 int tempSyncStat() const; 102 int tempSyncStat() const;
102 void setIDStr( const QString & ); 103 void setIDStr( const QString & );
103 const QString IDStr() const; 104 const QString IDStr() const;
104 void setID( const QString &, const QString & ); 105 void setID( const QString &, const QString & );
105 const QString getID( const QString & ) const; 106 const QString getID( const QString & ) const;
106 void setCsum( const QString &, const QString & ); 107 void setCsum( const QString &, const QString & );
107 const QString getCsum( const QString & ) const ; 108 const QString getCsum( const QString & ) const ;
108 void removeID(const QString &); 109 void removeID(const QString &);
109 void computeCsum(const QString &dev); 110 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 111 ulong getCsum4List( const QStringList & attList);
111 /** 112 /**
112 Return, if the address book entry is empty. 113 Return, if the address book entry is empty.
113 */ 114 */
114 bool isEmpty() const; 115 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 116 void setExternalUID( const QString &id );
116 const QString externalUID() const; 117 const QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 118 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 119 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad, bool isSubSet ); 120 void mergeContact( const Addressee& ad, bool isSubSet );
120 void simplifyEmails(); 121 void simplifyEmails();
121 void simplifyAddresses(); 122 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 123 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 124 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 125 bool removeVoice();
125 bool containsAdr(const Addressee& addr ); 126 bool containsAdr(const Addressee& addr );
126 127
127 /** 128 /**
128 Set unique identifier. 129 Set unique identifier.
129 */ 130 */
@@ -557,192 +558,195 @@ class Addressee
557 */ 558 */
558 Sound sound() const; 559 Sound sound() const;
559 /** 560 /**
560 Return translated label for sound field. 561 Return translated label for sound field.
561 */ 562 */
562 static QString soundLabel(); 563 static QString soundLabel();
563 564
564 /** 565 /**
565 Set agent. 566 Set agent.
566 */ 567 */
567 void setAgent( const Agent &agent ); 568 void setAgent( const Agent &agent );
568 /** 569 /**
569 Return agent. 570 Return agent.
570 */ 571 */
571 Agent agent() const; 572 Agent agent() const;
572 /** 573 /**
573 Return translated label for agent field. 574 Return translated label for agent field.
574 */ 575 */
575 static QString agentLabel(); 576 static QString agentLabel();
576 577
577 /** 578 /**
578 Set name fields by parsing the given string and trying to associate the 579 Set name fields by parsing the given string and trying to associate the
579 parts of the string with according fields. This function should probably 580 parts of the string with according fields. This function should probably
580 be a bit more clever. 581 be a bit more clever.
581 */ 582 */
582 void setNameFromString( const QString & ); 583 void setNameFromString( const QString & );
583 584
584 /** 585 /**
585 Return the name of the addressee. This is calculated from all the name 586 Return the name of the addressee. This is calculated from all the name
586 fields. 587 fields.
587 */ 588 */
588 QString realName() const; 589 QString realName() const;
589 590
590 /** 591 /**
591 Return the name that consists of all name parts. 592 Return the name that consists of all name parts.
592 */ 593 */
593 QString assembledName() const; 594 QString assembledName() const;
594 595
595 /** 596 /**
596 Return email address including real name. 597 Return email address including real name.
597 598
598 @param email Email address to be used to construct the full email string. 599 @param email Email address to be used to construct the full email string.
599 If this is QString::null the preferred email address is used. 600 If this is QString::null the preferred email address is used.
600 */ 601 */
601 QString fullEmail( const QString &email=QString::null ) const; 602 QString fullEmail( const QString &email=QString::null ) const;
602 603
603 /** 604 /**
604 Insert an email address. If the email address already exists in this 605 Insert an email address. If the email address already exists in this
605 addressee it is not duplicated. 606 addressee it is not duplicated.
606 607
607 @param email Email address 608 @param email Email address
608 @param preferred Set to true, if this is the preferred email address of 609 @param preferred Set to true, if this is the preferred email address of
609 the addressee. 610 the addressee.
610 */ 611 */
611 void insertEmail( const QString &email, bool preferred=false ); 612 void insertEmail( const QString &email, bool preferred=false );
612 613
613 /** 614 /**
614 Remove email address. If the email address doesn't exist, nothing happens. 615 Remove email address. If the email address doesn't exist, nothing happens.
615 */ 616 */
616 void removeEmail( const QString &email ); 617 void removeEmail( const QString &email );
617 618
618 /** 619 /**
619 Return preferred email address. This is the first email address or the 620 Return preferred email address. This is the first email address or the
620 last one added with @ref insertEmail() with a set preferred parameter. 621 last one added with @ref insertEmail() with a set preferred parameter.
621 */ 622 */
622 QString preferredEmail() const; 623 QString preferredEmail() const;
623 624
624 /** 625 /**
625 Return list of all email addresses. 626 Return list of all email addresses.
626 */ 627 */
627 QStringList emails() const; 628 QStringList emails() const;
628 629
629 /** 630 /**
630 Set the emails to @param. 631 Set the emails to @param.
631 The first email address gets the preferred one! 632 The first email address gets the preferred one!
632 @param list The list of email addresses. 633 @param list The list of email addresses.
633 */ 634 */
634 void setEmails( const QStringList& list); 635 void setEmails( const QStringList& list);
635 636
636 /** 637 /**
637 Insert a phone number. If a phone number with the same id already exists 638 Insert a phone number. If a phone number with the same id already exists
638 in this addressee it is not duplicated. 639 in this addressee it is not duplicated.
639 */ 640 */
640 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 641 void insertPhoneNumber( const PhoneNumber &phoneNumber );
641 642
642 /** 643 /**
643 Remove phone number. If no phone number with the given id exists for this 644 Remove phone number. If no phone number with the given id exists for this
644 addresse nothing happens. 645 addresse nothing happens.
645 */ 646 */
646 void removePhoneNumber( const PhoneNumber &phoneNumber ); 647 void removePhoneNumber( const PhoneNumber &phoneNumber );
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 /**
659 Return list of phone numbers with a special type. 663 Return list of phone numbers with a special type.
660 */ 664 */
661 PhoneNumber::List phoneNumbers( int type ) const; 665 PhoneNumber::List phoneNumbers( int type ) const;
662 666
663 /** 667 /**
664 Return phone number with the given id. 668 Return phone number with the given id.
665 */ 669 */
666 PhoneNumber findPhoneNumber( const QString &id ) const; 670 PhoneNumber findPhoneNumber( const QString &id ) const;
667 671
668 /** 672 /**
669 Insert a key. If a key with the same id already exists 673 Insert a key. If a key with the same id already exists
670 in this addressee it is not duplicated. 674 in this addressee it is not duplicated.
671 */ 675 */
672 void insertKey( const Key &key ); 676 void insertKey( const Key &key );
673 677
674 /** 678 /**
675 Remove a key. If no key with the given id exists for this 679 Remove a key. If no key with the given id exists for this
676 addresse nothing happens. 680 addresse nothing happens.
677 */ 681 */
678 void removeKey( const Key &key ); 682 void removeKey( const Key &key );
679 683
680 /** 684 /**
681 Return key, which matches the given type. 685 Return key, which matches the given type.
682 If @p type == Key::Custom you can specify a string 686 If @p type == Key::Custom you can specify a string
683 that should match. If you leave the string empty, the first 687 that should match. If you leave the string empty, the first
684 key with a custom value is returned. 688 key with a custom value is returned.
685 */ 689 */
686 Key key( int type, QString customTypeString = QString::null ) const; 690 Key key( int type, QString customTypeString = QString::null ) const;
687 691
688 /** 692 /**
689 Return list of all keys. 693 Return list of all keys.
690 */ 694 */
691 Key::List keys() const; 695 Key::List keys() const;
692 696
693 /** 697 /**
694 Set the list of keys 698 Set the list of keys
695 @param keys The keys to be set. 699 @param keys The keys to be set.
696 */ 700 */
697 void setKeys( const Key::List& keys); 701 void setKeys( const Key::List& keys);
698 702
699 /** 703 /**
700 Return list of keys with a special type. 704 Return list of keys with a special type.
701 If @p type == Key::Custom you can specify a string 705 If @p type == Key::Custom you can specify a string
702 that should match. If you leave the string empty, all custom 706 that should match. If you leave the string empty, all custom
703 keys will be returned. 707 keys will be returned.
704 */ 708 */
705 Key::List keys( int type, QString customTypeString = QString::null ) const; 709 Key::List keys( int type, QString customTypeString = QString::null ) const;
706 710
707 /** 711 /**
708 Return key with the given id. 712 Return key with the given id.
709 */ 713 */
710 Key findKey( const QString &id ) const; 714 Key findKey( const QString &id ) const;
711 715
712 /** 716 /**
713 Insert an address. If an address with the same id already exists 717 Insert an address. If an address with the same id already exists
714 in this addressee it is not duplicated. 718 in this addressee it is not duplicated.
715 */ 719 */
716 void insertAddress( const Address &address ); 720 void insertAddress( const Address &address );
717 721
718 /** 722 /**
719 Remove address. If no address with the given id exists for this 723 Remove address. If no address with the given id exists for this
720 addresse nothing happens. 724 addresse nothing happens.
721 */ 725 */
722 void removeAddress( const Address &address ); 726 void removeAddress( const Address &address );
723 727
724 /** 728 /**
725 Return address, which matches the given type. 729 Return address, which matches the given type.
726 */ 730 */
727 Address address( int type ) const; 731 Address address( int type ) const;
728 732
729 /** 733 /**
730 Return list of all addresses. 734 Return list of all addresses.
731 */ 735 */
732 Address::List addresses() const; 736 Address::List addresses() const;
733 737
734 /** 738 /**
735 Return list of addresses with a special type. 739 Return list of addresses with a special type.
736 */ 740 */
737 Address::List addresses( int type ) const; 741 Address::List addresses( int type ) const;
738 742
739 /** 743 /**
740 Return address with the given id. 744 Return address with the given id.
741 */ 745 */
742 Address findAddress( const QString &id ) const; 746 Address findAddress( const QString &id ) const;
743 747
744 /** 748 /**
745 Insert category. If the category already exists it is not duplicated. 749 Insert category. If the category already exists it is not duplicated.
746 */ 750 */
747 void insertCategory( const QString & ); 751 void insertCategory( const QString & );
748 752
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
@@ -236,204 +236,222 @@ void KAddressBookCardView::readConfig(KConfig *config)
236 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 236 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
237 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
238 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 238 c = p.color(QPalette::Normal, QColorGroup::Highlight );
239 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 239 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
240 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 240 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
241 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 241 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
242 mCardView->viewport()->setPalette( p ); 242 mCardView->viewport()->setPalette( p );
243 } 243 }
244 else 244 else
245 { 245 {
246 // needed if turned off during a session. 246 // needed if turned off during a session.
247 mCardView->viewport()->setPalette( mCardView->palette() ); 247 mCardView->viewport()->setPalette( mCardView->palette() );
248 } 248 }
249 249
250 //custom fonts? 250 //custom fonts?
251 QFont f( font() ); 251 QFont f( font() );
252 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 252 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
253 { 253 {
254 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 254 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
255 f.setBold( true ); 255 f.setBold( true );
256 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 256 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
257 } 257 }
258 else 258 else
259 { 259 {
260 mCardView->setFont( f ); 260 mCardView->setFont( f );
261 f.setBold( true ); 261 f.setBold( true );
262 mCardView->setHeaderFont( f ); 262 mCardView->setHeaderFont( f );
263 } 263 }
264 264
265 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 265 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
266 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 266 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
267 true)); 267 true));
268 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 268 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
269 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 269 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
270 270
271 mCardView->setShowEmptyFields( mShowEmptyFields ); 271 mCardView->setShowEmptyFields( mShowEmptyFields );
272 272
273 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 273 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
274 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 274 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
275 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 275 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
276 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 276 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
277 277
278#if 0 278#if 0
279 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven 279 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven
280 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 280 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
281 this, SLOT(addresseeExecuted(CardViewItem *))); 281 this, SLOT(addresseeExecuted(CardViewItem *)));
282 282
283 if (KABPrefs::instance()->mHonorSingleClick) 283 if (KABPrefs::instance()->mHonorSingleClick)
284 connect(mCardView, SIGNAL(executed(CardViewItem *)), 284 connect(mCardView, SIGNAL(executed(CardViewItem *)),
285 this, SLOT(addresseeExecuted(CardViewItem *))); 285 this, SLOT(addresseeExecuted(CardViewItem *)));
286 else 286 else
287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
288 this, SLOT(addresseeExecuted(CardViewItem *))); 288 this, SLOT(addresseeExecuted(CardViewItem *)));
289#endif 289#endif
290 290
291 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 291 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
292 this, SLOT(addresseeExecuted(CardViewItem *))); 292 this, SLOT(addresseeExecuted(CardViewItem *)));
293} 293}
294 294
295void KAddressBookCardView::writeConfig( KConfig *config ) 295void KAddressBookCardView::writeConfig( KConfig *config )
296{ 296{
297 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 297 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
298 KAddressBookView::writeConfig( config ); 298 KAddressBookView::writeConfig( config );
299} 299}
300void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 300void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
301{ 301{
302 mCardView->clear(); 302 mCardView->clear();
303 if ( s.isEmpty() || s == "*" ) { 303 if ( s.isEmpty() || s == "*" ) {
304 refresh(); 304 refresh();
305 return; 305 return;
306 } 306 }
307 QRegExp re = getRegExp( s ); 307 QRegExp re = getRegExp( s );
308 if (!re.isValid()) 308 if (!re.isValid())
309 return; 309 return;
310 mCardView->viewport()->setUpdatesEnabled( false ); 310 mCardView->viewport()->setUpdatesEnabled( false );
311 KABC::Addressee::List addresseeList = addressees(); 311 KABC::Addressee::List addresseeList = addressees();
312 KABC::Addressee::List::Iterator it; 312 KABC::Addressee::List::Iterator it;
313 if ( field ) { 313 if ( field ) {
314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
316 continue; 316 continue;
317#if QT_VERSION >= 0x030000 317#if QT_VERSION >= 0x030000
318 if (re.search(field->value( *it ).lower()) == 0) 318 if (re.search(field->value( *it ).lower()) == 0)
319#else 319#else
320 if (re.match(field->value( *it ).lower()) == 0) 320 if (re.match(field->value( *it ).lower()) == 0)
321#endif 321#endif
322 new AddresseeCardViewItem(fields(), mShowEmptyFields, 322 new AddresseeCardViewItem(fields(), mShowEmptyFields,
323 addressBook(), *it, mCardView); 323 addressBook(), *it, mCardView);
324 324
325 } 325 }
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;
341 break; 343 break;
342 } 344 }
343 } 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;
359 break;
360 }
361 }
344 } 362 }
345 } 363 }
346 mCardView->viewport()->setUpdatesEnabled( true ); 364 mCardView->viewport()->setUpdatesEnabled( true );
347 mCardView->viewport()->update(); 365 mCardView->viewport()->update();
348 if ( mCardView->firstItem() ) { 366 if ( mCardView->firstItem() ) {
349 mCardView->setCurrentItem ( mCardView->firstItem() ); 367 mCardView->setCurrentItem ( mCardView->firstItem() );
350 mCardView->setSelected ( mCardView->firstItem() , true ); 368 mCardView->setSelected ( mCardView->firstItem() , true );
351 } 369 }
352 else 370 else
353 emit selected(QString::null); 371 emit selected(QString::null);
354} 372}
355QStringList KAddressBookCardView::selectedUids() 373QStringList KAddressBookCardView::selectedUids()
356{ 374{
357 QStringList uidList; 375 QStringList uidList;
358 CardViewItem *item; 376 CardViewItem *item;
359 AddresseeCardViewItem *aItem; 377 AddresseeCardViewItem *aItem;
360 378
361 for (item = mCardView->firstItem(); item; item = item->nextItem()) 379 for (item = mCardView->firstItem(); item; item = item->nextItem())
362 { 380 {
363 if (item->isSelected()) 381 if (item->isSelected())
364 { 382 {
365#ifndef KAB_EMBEDDED 383#ifndef KAB_EMBEDDED
366 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 384 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
367#else //KAB_EMBEDDED 385#else //KAB_EMBEDDED
368 aItem = (AddresseeCardViewItem*)(item); 386 aItem = (AddresseeCardViewItem*)(item);
369#endif //KAB_EMBEDDED 387#endif //KAB_EMBEDDED
370 if (aItem) 388 if (aItem)
371 uidList << aItem->addressee().uid(); 389 uidList << aItem->addressee().uid();
372 } 390 }
373 } 391 }
374 392
375 return uidList; 393 return uidList;
376} 394}
377 395
378void KAddressBookCardView::refresh(QString uid) 396void KAddressBookCardView::refresh(QString uid)
379{ 397{
380 CardViewItem *item; 398 CardViewItem *item;
381 AddresseeCardViewItem *aItem; 399 AddresseeCardViewItem *aItem;
382 400
383 if (uid.isNull()) 401 if (uid.isNull())
384 { 402 {
385 // Rebuild the view 403 // Rebuild the view
386 mCardView->viewport()->setUpdatesEnabled( false ); 404 mCardView->viewport()->setUpdatesEnabled( false );
387 mCardView->clear(); 405 mCardView->clear();
388 406
389 KABC::Addressee::List addresseeList = addressees(); 407 KABC::Addressee::List addresseeList = addressees();
390 KABC::Addressee::List::Iterator iter; 408 KABC::Addressee::List::Iterator iter;
391 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 409 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
392 { 410 {
393 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 411 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
394 continue; 412 continue;
395 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, 413 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields,
396 addressBook(), *iter, mCardView); 414 addressBook(), *iter, mCardView);
397 } 415 }
398 mCardView->viewport()->setUpdatesEnabled( true ); 416 mCardView->viewport()->setUpdatesEnabled( true );
399 mCardView->viewport()->update(); 417 mCardView->viewport()->update();
400 418
401 // by default nothing is selected 419 // by default nothing is selected
402 emit selected(QString::null); 420 emit selected(QString::null);
403 } 421 }
404 else 422 else
405 { 423 {
406 // Try to find the one to refresh 424 // Try to find the one to refresh
407 bool found = false; 425 bool found = false;
408 for (item = mCardView->firstItem(); item && !found; 426 for (item = mCardView->firstItem(); item && !found;
409 item = item->nextItem()) 427 item = item->nextItem())
410 { 428 {
411#ifndef KAB_EMBEDDED 429#ifndef KAB_EMBEDDED
412 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 430 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
413#else //KAB_EMBEDDED 431#else //KAB_EMBEDDED
414 aItem = (AddresseeCardViewItem*)(item); 432 aItem = (AddresseeCardViewItem*)(item);
415#endif //KAB_EMBEDDED 433#endif //KAB_EMBEDDED
416 434
417 if ((aItem) && (aItem->addressee().uid() == uid)) 435 if ((aItem) && (aItem->addressee().uid() == uid))
418 { 436 {
419 aItem->refresh(); 437 aItem->refresh();
420 found = true; 438 found = true;
421 } 439 }
422 } 440 }
423 } 441 }
424} 442}
425 443
426void KAddressBookCardView::setSelected(QString uid, bool selected) 444void KAddressBookCardView::setSelected(QString uid, bool selected)
427{ 445{
428 CardViewItem *item; 446 CardViewItem *item;
429 AddresseeCardViewItem *aItem; 447 AddresseeCardViewItem *aItem;
430 448
431 if (uid.isNull()) 449 if (uid.isNull())
432 { 450 {
433 mCardView->selectAll(selected); 451 mCardView->selectAll(selected);
434 } 452 }
435 else 453 else
436 { 454 {
437 bool found = false; 455 bool found = false;
438 for (item = mCardView->firstItem(); item && !found; 456 for (item = mCardView->firstItem(); item && !found;
439 item = item->nextItem()) 457 item = item->nextItem())
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
@@ -57,335 +57,364 @@ class IconViewFactory : public ViewFactory
57 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 57 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
58}; 58};
59 59
60*/ 60*/
61 61
62extern "C" { 62extern "C" {
63 void *init_libkaddrbk_iconview() 63 void *init_libkaddrbk_iconview()
64 { 64 {
65 return ( new IconViewFactory ); 65 return ( new IconViewFactory );
66 } 66 }
67} 67}
68 68
69//////////////////////////////// 69////////////////////////////////
70// AddresseeIconView (internal class) 70// AddresseeIconView (internal class)
71#ifndef KAB_EMBEDDED 71#ifndef KAB_EMBEDDED
72AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 72AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
73 : KIconView(parent, name) 73 : KIconView(parent, name)
74#else //KAB_EMBEDDED 74#else //KAB_EMBEDDED
75AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 75AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
76 : QIconView(parent, name) 76 : QIconView(parent, name)
77#endif //KAB_EMBEDDED 77#endif //KAB_EMBEDDED
78 78
79{ 79{
80 setSelectionMode( QIconView::Extended ); 80 setSelectionMode( QIconView::Extended );
81 setResizeMode( QIconView::Adjust ); 81 setResizeMode( QIconView::Adjust );
82 setWordWrapIconText( true ); 82 setWordWrapIconText( true );
83 setGridX( 100 ); 83 setGridX( 100 );
84 setItemsMovable(false); 84 setItemsMovable(false);
85 setSorting(true, true); 85 setSorting(true, true);
86 86
87 87
88//US ??? setMode( KIconView::Select ); 88//US ??? setMode( KIconView::Select );
89 89
90#ifndef KAB_EMBEDDED 90#ifndef KAB_EMBEDDED
91 91
92 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), 92 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)),
93 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); 93 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&)));
94#endif //KAB_EMBEDDED 94#endif //KAB_EMBEDDED
95} 95}
96 96
97AddresseeIconView::~AddresseeIconView() 97AddresseeIconView::~AddresseeIconView()
98{ 98{
99} 99}
100 100
101 101
102void AddresseeIconView::itemDropped(QDropEvent *e, 102void AddresseeIconView::itemDropped(QDropEvent *e,
103 const QValueList<QIconDragItem> &) 103 const QValueList<QIconDragItem> &)
104{ 104{
105 emit addresseeDropped(e); 105 emit addresseeDropped(e);
106} 106}
107 107
108QDragObject *AddresseeIconView::dragObject() 108QDragObject *AddresseeIconView::dragObject()
109{ 109{
110 emit startAddresseeDrag(); 110 emit startAddresseeDrag();
111 111
112 // We never want IconView to start the drag 112 // We never want IconView to start the drag
113 return 0; 113 return 0;
114} 114}
115//////////////////////////////// 115////////////////////////////////
116// AddresseeIconViewItem (internal class) 116// AddresseeIconViewItem (internal class)
117#ifndef KAB_EMBEDDED 117#ifndef KAB_EMBEDDED
118class AddresseeIconViewItem : public KIconViewItem 118class AddresseeIconViewItem : public KIconViewItem
119#else //KAB_EMBEDDED 119#else //KAB_EMBEDDED
120class AddresseeIconViewItem : public QIconViewItem 120class AddresseeIconViewItem : public QIconViewItem
121#endif //KAB_EMBEDDED 121#endif //KAB_EMBEDDED
122{ 122{
123 public: 123 public:
124#ifndef KAB_EMBEDDED 124#ifndef KAB_EMBEDDED
125 AddresseeIconViewItem(const KABC::Field::List &fields, 125 AddresseeIconViewItem(const KABC::Field::List &fields,
126 KABC::AddressBook *doc, const KABC::Addressee &a, 126 KABC::AddressBook *doc, const KABC::Addressee &a,
127 QIconView *parent) 127 QIconView *parent)
128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
129#else //KAB_EMBEDDED 129#else //KAB_EMBEDDED
130 AddresseeIconViewItem(const KABC::Field::List &fields, 130 AddresseeIconViewItem(const KABC::Field::List &fields,
131 KABC::AddressBook *doc, const KABC::Addressee &a, 131 KABC::AddressBook *doc, const KABC::Addressee &a,
132 QIconView *parent) 132 QIconView *parent)
133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 { 135 {
136 if ( mFields.isEmpty() ) { 136 if ( mFields.isEmpty() ) {
137 mFields = KABC::Field::defaultFields(); 137 mFields = KABC::Field::defaultFields();
138 } 138 }
139 refresh(); 139 refresh();
140 } 140 }
141 141
142 const KABC::Addressee &addressee() const { return mAddressee; } 142 const KABC::Addressee &addressee() const { return mAddressee; }
143 143
144 void refresh() 144 void refresh()
145 { 145 {
146 // Update our addressee, since it may have changed elsewhere 146 // Update our addressee, since it may have changed elsewhere
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;
179 KABC::Addressee mAddressee; 192 KABC::Addressee mAddressee;
180}; 193};
181 194
182/////////////////////////////// 195///////////////////////////////
183// KAddressBookView 196// KAddressBookView
184 197
185KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, 198KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab,
186 QWidget *parent, const char *name) 199 QWidget *parent, const char *name)
187 : KAddressBookView( ab, parent, name ) 200 : KAddressBookView( ab, parent, name )
188{ 201{
189 // Init the GUI 202 // Init the GUI
190 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 203 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
191 204
192 mIconView = new AddresseeIconView(viewWidget(), "mIconView"); 205 mIconView = new AddresseeIconView(viewWidget(), "mIconView");
193 layout->addWidget(mIconView); 206 layout->addWidget(mIconView);
194 207
195 // Connect up the signals 208 // Connect up the signals
196 209
197//US method executed is part of KIconView 210//US method executed is part of KIconView
198//US connect(mIconView, SIGNAL(executed(QIconViewItem *)), 211//US connect(mIconView, SIGNAL(executed(QIconViewItem *)),
199//US this, SLOT(addresseeExecuted(QIconViewItem *))); 212//US this, SLOT(addresseeExecuted(QIconViewItem *)));
200 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 213 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
201 this, SLOT(addresseeExecuted(QIconViewItem *))); 214 this, SLOT(addresseeExecuted(QIconViewItem *)));
202 215
203 connect(mIconView, SIGNAL(selectionChanged()), 216 connect(mIconView, SIGNAL(selectionChanged()),
204 this, SLOT(addresseeSelected())); 217 this, SLOT(addresseeSelected()));
205 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), 218 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)),
206 this, SIGNAL(dropped(QDropEvent*))); 219 this, SIGNAL(dropped(QDropEvent*)));
207 connect(mIconView, SIGNAL(startAddresseeDrag()), 220 connect(mIconView, SIGNAL(startAddresseeDrag()),
208 this, SIGNAL(startDrag())); 221 this, SIGNAL(startDrag()));
209} 222}
210 223
211KAddressBookIconView::~KAddressBookIconView() 224KAddressBookIconView::~KAddressBookIconView()
212{ 225{
213} 226}
214void KAddressBookIconView::setFocusAV() 227void KAddressBookIconView::setFocusAV()
215{ 228{
216 if ( mIconView ) 229 if ( mIconView )
217 mIconView->setFocus(); 230 mIconView->setFocus();
218} 231}
219 232
220 233
221void KAddressBookIconView::scrollUP() 234void KAddressBookIconView::scrollUP()
222{ 235{
223 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 236 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
224 QApplication::postEvent( mIconView, ev ); 237 QApplication::postEvent( mIconView, ev );
225} 238}
226void KAddressBookIconView::scrollDOWN() 239void KAddressBookIconView::scrollDOWN()
227{ 240{
228 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 241 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
229 QApplication::postEvent( mIconView, ev ); 242 QApplication::postEvent( mIconView, ev );
230} 243}
231void KAddressBookIconView::readConfig(KConfig *config) 244void KAddressBookIconView::readConfig(KConfig *config)
232{ 245{
233 KAddressBookView::readConfig(config); 246 KAddressBookView::readConfig(config);
234 247
235//US method executed is part of KIconView 248//US method executed is part of KIconView
236//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), 249//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
237//US this, SLOT(addresseeExecuted(QIconViewItem *))); 250//US this, SLOT(addresseeExecuted(QIconViewItem *)));
238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 251 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
239 this, SLOT(addresseeExecuted(QIconViewItem *))); 252 this, SLOT(addresseeExecuted(QIconViewItem *)));
240 253
241//US method executed is part of KIconView. Use selectionChanged instead 254//US method executed is part of KIconView. Use selectionChanged instead
242/*US 255/*US
243 if (KABPrefs::instance()->mHonorSingleClick) 256 if (KABPrefs::instance()->mHonorSingleClick)
244 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 257 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
245 this, SLOT(addresseeExecuted(QIconViewItem *))); 258 this, SLOT(addresseeExecuted(QIconViewItem *)));
246 else 259 else
247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 260 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
248 this, SLOT(addresseeExecuted(QIconViewItem *))); 261 this, SLOT(addresseeExecuted(QIconViewItem *)));
249*/ 262*/
250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 263 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
251 this, SLOT(addresseeExecuted(QIconViewItem *))); 264 this, SLOT(addresseeExecuted(QIconViewItem *)));
252 265
253} 266}
254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 267void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
255{ 268{
256 mIconView->clear(); 269 mIconView->clear();
257 mIconList.clear(); 270 mIconList.clear();
258 if ( s.isEmpty() || s == "*" ) { 271 if ( s.isEmpty() || s == "*" ) {
259 refresh(); 272 refresh();
260 return; 273 return;
261 } 274 }
262 QRegExp re = getRegExp( s ); 275 QRegExp re = getRegExp( s );
263 if (!re.isValid()) 276 if (!re.isValid())
264 return; 277 return;
265 KABC::Addressee::List addresseeList = addressees(); 278 KABC::Addressee::List addresseeList = addressees();
266 KABC::Addressee::List::Iterator it; 279 KABC::Addressee::List::Iterator it;
267 if ( field ) { 280 if ( field ) {
268 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 281 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
269 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 282 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
270 continue; 283 continue;
271#if QT_VERSION >= 0x030000 284#if QT_VERSION >= 0x030000
272 if (re.search(field->value( *it ).lower()) == 0) 285 if (re.search(field->value( *it ).lower()) == 0)
273#else 286#else
274 if (re.match(field->value( *it ).lower()) == 0) 287 if (re.match(field->value( *it ).lower()) == 0)
275#endif 288#endif
276 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 289 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
277 290
278 291
279 } 292 }
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;
294 break; 309 break;
295 } 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;
323 break;
324 }
296 } 325 }
297 } 326 }
298 } 327 }
299 mIconView->arrangeItemsInGrid( true ); 328 mIconView->arrangeItemsInGrid( true );
300 if ( mIconView->firstItem() ) { 329 if ( mIconView->firstItem() ) {
301 mIconView->setCurrentItem ( mIconView->firstItem() ); 330 mIconView->setCurrentItem ( mIconView->firstItem() );
302 mIconView->setSelected ( mIconView->firstItem() , true ); 331 mIconView->setSelected ( mIconView->firstItem() , true );
303 } 332 }
304 else 333 else
305 emit selected(QString::null); 334 emit selected(QString::null);
306} 335}
307QStringList KAddressBookIconView::selectedUids() 336QStringList KAddressBookIconView::selectedUids()
308{ 337{
309 QStringList uidList; 338 QStringList uidList;
310 QIconViewItem *item; 339 QIconViewItem *item;
311 AddresseeIconViewItem *aItem; 340 AddresseeIconViewItem *aItem;
312 341
313 for (item = mIconView->firstItem(); item; item = item->nextItem()) 342 for (item = mIconView->firstItem(); item; item = item->nextItem())
314 { 343 {
315 if (item->isSelected()) 344 if (item->isSelected())
316 { 345 {
317#ifndef KAB_EMBEDDED 346#ifndef KAB_EMBEDDED
318 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 347 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
319#else //KAB_EMBEDDED 348#else //KAB_EMBEDDED
320 aItem = (AddresseeIconViewItem*)(item); 349 aItem = (AddresseeIconViewItem*)(item);
321#endif //KAB_EMBEDDED 350#endif //KAB_EMBEDDED
322 if (aItem) 351 if (aItem)
323 uidList << aItem->addressee().uid(); 352 uidList << aItem->addressee().uid();
324 } 353 }
325 } 354 }
326 355
327 return uidList; 356 return uidList;
328} 357}
329 358
330void KAddressBookIconView::refresh(QString uid) 359void KAddressBookIconView::refresh(QString uid)
331{ 360{
332 QIconViewItem *item; 361 QIconViewItem *item;
333 AddresseeIconViewItem *aItem; 362 AddresseeIconViewItem *aItem;
334 363
335 if ( uid.isNull() ) { 364 if ( uid.isNull() ) {
336 // Rebuild the view 365 // Rebuild the view
337 mIconView->clear(); 366 mIconView->clear();
338 mIconList.clear(); 367 mIconList.clear();
339 368
340 KABC::Addressee::List addresseeList = addressees(); 369 KABC::Addressee::List addresseeList = addressees();
341 KABC::Addressee::List::Iterator iter; 370 KABC::Addressee::List::Iterator iter;
342 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { 371 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
343 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 372 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
344 continue; 373 continue;
345 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); 374 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView );
346 } 375 }
347 376
348 mIconView->arrangeItemsInGrid( true ); 377 mIconView->arrangeItemsInGrid( true );
349 378
350 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) 379 for ( item = mIconView->firstItem(); item; item = item->nextItem() )
351 { 380 {
352#ifndef KAB_EMBEDDED 381#ifndef KAB_EMBEDDED
353 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); 382 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item );
354#else //KAB_EMBEDDED 383#else //KAB_EMBEDDED
355 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); 384 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item );
356#endif //KAB_EMBEDDED 385#endif //KAB_EMBEDDED
357 mIconList.append( aivi ); 386 mIconList.append( aivi );
358 } 387 }
359 388
360 } else { 389 } else {
361 // Try to find the one to refresh 390 // Try to find the one to refresh
362 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { 391 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) {
363#ifndef KAB_EMBEDDED 392#ifndef KAB_EMBEDDED
364 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 393 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
365#else //KAB_EMBEDDED 394#else //KAB_EMBEDDED
366 aItem = (AddresseeIconViewItem*)(item); 395 aItem = (AddresseeIconViewItem*)(item);
367#endif //KAB_EMBEDDED 396#endif //KAB_EMBEDDED
368 if ((aItem) && (aItem->addressee().uid() == uid)) { 397 if ((aItem) && (aItem->addressee().uid() == uid)) {
369 aItem->refresh(); 398 aItem->refresh();
370 mIconView->arrangeItemsInGrid( true ); 399 mIconView->arrangeItemsInGrid( true );
371 return; 400 return;
372 } 401 }
373 } 402 }
374 refresh( QString::null ); 403 refresh( QString::null );
375 } 404 }
376} 405}
377 406
378void KAddressBookIconView::setSelected(QString uid, bool selected) 407void KAddressBookIconView::setSelected(QString uid, bool selected)
379{ 408{
380 QIconViewItem *item; 409 QIconViewItem *item;
381 AddresseeIconViewItem *aItem; 410 AddresseeIconViewItem *aItem;
382 411
383 if (uid.isNull()) 412 if (uid.isNull())
384 { 413 {
385 mIconView->selectAll(selected); 414 mIconView->selectAll(selected);
386 } 415 }
387 else 416 else
388 { 417 {
389 bool found = false; 418 bool found = false;
390 for (item = mIconView->firstItem(); item && !found; 419 for (item = mIconView->firstItem(); item && !found;
391 item = item->nextItem()) 420 item = item->nextItem())
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
@@ -77,204 +77,220 @@ void KAddressBookTableView::reconstructListView()
77 { 77 {
78 disconnect(mListView, SIGNAL(selectionChanged()), 78 disconnect(mListView, SIGNAL(selectionChanged()),
79 this, SLOT(addresseeSelected())); 79 this, SLOT(addresseeSelected()));
80 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 80 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
81 this, SLOT(addresseeExecuted(QListViewItem*))); 81 this, SLOT(addresseeExecuted(QListViewItem*)));
82 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 82 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
83 this, SLOT(addresseeExecuted(QListViewItem*))); 83 this, SLOT(addresseeExecuted(QListViewItem*)));
84 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 84 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
85 SIGNAL(startDrag())); 85 SIGNAL(startDrag()));
86 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 86 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
87 this, SLOT(addresseeExecuted(QListViewItem*))); 87 this, SLOT(addresseeExecuted(QListViewItem*)));
88 88
89 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 89 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
90 SIGNAL(dropped(QDropEvent*))); 90 SIGNAL(dropped(QDropEvent*)));
91 delete mListView; 91 delete mListView;
92 } 92 }
93 93
94 mListView = new ContactListView( this, addressBook(), viewWidget() ); 94 mListView = new ContactListView( this, addressBook(), viewWidget() );
95 95
96 connect(this, SIGNAL(printView()), 96 connect(this, SIGNAL(printView()),
97 mListView , SLOT(printMe())); 97 mListView , SLOT(printMe()));
98 //US set singleClick manually, because it is no global configparameter in embedded space 98 //US set singleClick manually, because it is no global configparameter in embedded space
99 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 99 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
100 100
101 // Add the columns 101 // Add the columns
102 KABC::Field::List fieldList = fields(); 102 KABC::Field::List fieldList = fields();
103 KABC::Field::List::ConstIterator it; 103 KABC::Field::List::ConstIterator it;
104 104
105 int c = 0; 105 int c = 0;
106 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 106 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
107 mListView->addColumn( (*it)->label() ); 107 mListView->addColumn( (*it)->label() );
108 mListView->setColumnWidthMode(c++, QListView::Manual); 108 mListView->setColumnWidthMode(c++, QListView::Manual);
109//US 109//US
110 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 110 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
111 } 111 }
112 112
113 connect(mListView, SIGNAL(selectionChanged()), 113 connect(mListView, SIGNAL(selectionChanged()),
114 this, SLOT(addresseeSelected())); 114 this, SLOT(addresseeSelected()));
115 connect(mListView, SIGNAL(startAddresseeDrag()), this, 115 connect(mListView, SIGNAL(startAddresseeDrag()), this,
116 SIGNAL(startDrag())); 116 SIGNAL(startDrag()));
117 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 117 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
118 SIGNAL(dropped(QDropEvent*))); 118 SIGNAL(dropped(QDropEvent*)));
119 119
120 if (KABPrefs::instance()->mHonorSingleClick) { 120 if (KABPrefs::instance()->mHonorSingleClick) {
121 // qDebug("KAddressBookTableView::reconstructListView single"); 121 // qDebug("KAddressBookTableView::reconstructListView single");
122 connect(mListView, SIGNAL(executed(QListViewItem*)), 122 connect(mListView, SIGNAL(executed(QListViewItem*)),
123 this, SLOT(addresseeExecuted(QListViewItem*))); 123 this, SLOT(addresseeExecuted(QListViewItem*)));
124 } else { 124 } else {
125 // qDebug("KAddressBookTableView::reconstructListView double"); 125 // qDebug("KAddressBookTableView::reconstructListView double");
126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
127 this, SLOT(addresseeExecuted(QListViewItem*))); 127 this, SLOT(addresseeExecuted(QListViewItem*)));
128 } 128 }
129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
130 this, SLOT(addresseeExecuted(QListViewItem*))); 130 this, SLOT(addresseeExecuted(QListViewItem*)));
131 connect(mListView, SIGNAL(signalDelete()), 131 connect(mListView, SIGNAL(signalDelete()),
132 this, SLOT(addresseeDeleted())); 132 this, SLOT(addresseeDeleted()));
133 133
134//US performceimprovement. Refresh is done from the outside 134//US performceimprovement. Refresh is done from the outside
135//US refresh(); 135//US refresh();
136 136
137 mListView->setSorting( 0, true ); 137 mListView->setSorting( 0, true );
138 mainLayout->addWidget( mListView ); 138 mainLayout->addWidget( mListView );
139 mainLayout->activate(); 139 mainLayout->activate();
140 mListView->show(); 140 mListView->show();
141} 141}
142 142
143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
144{ 144{
145 mListView->clear(); 145 mListView->clear();
146 if ( s.isEmpty() || s == "*" ) { 146 if ( s.isEmpty() || s == "*" ) {
147 refresh(); 147 refresh();
148 return; 148 return;
149 } 149 }
150 QRegExp re = getRegExp( s ); 150 QRegExp re = getRegExp( s );
151 if (!re.isValid()) 151 if (!re.isValid())
152 return; 152 return;
153 KABC::Addressee::List addresseeList = addressees(); 153 KABC::Addressee::List addresseeList = addressees();
154 KABC::Addressee::List::Iterator it; 154 KABC::Addressee::List::Iterator it;
155 if ( field ) { 155 if ( field ) {
156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
158 continue; 158 continue;
159#if QT_VERSION >= 0x030000 159#if QT_VERSION >= 0x030000
160 if (re.search(field->value( *it ).lower()) == 0) 160 if (re.search(field->value( *it ).lower()) == 0)
161#else 161#else
162 if (re.match(field->value( *it ).lower()) == 0) 162 if (re.match(field->value( *it ).lower()) == 0)
163#endif 163#endif
164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
165 165
166 } 166 }
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;
182 break; 184 break;
183 } 185 }
184 } 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;
198 break;
199 }
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
188 // of items. 204 // of items.
189 //mListView->repaint(); 205 //mListView->repaint();
190 if ( mListView->firstChild() ) { 206 if ( mListView->firstChild() ) {
191 mListView->setCurrentItem ( mListView->firstChild() ); 207 mListView->setCurrentItem ( mListView->firstChild() );
192 mListView->setSelected ( mListView->firstChild(), true ); 208 mListView->setSelected ( mListView->firstChild(), true );
193 } 209 }
194 else 210 else
195 emit selected(QString::null); 211 emit selected(QString::null);
196 212
197} 213}
198void KAddressBookTableView::writeConfig(KConfig *config) 214void KAddressBookTableView::writeConfig(KConfig *config)
199{ 215{
200 KAddressBookView::writeConfig(config); 216 KAddressBookView::writeConfig(config);
201 217
202 mListView->saveLayout(config, config->group()); 218 mListView->saveLayout(config, config->group());
203} 219}
204 220
205void KAddressBookTableView::readConfig(KConfig *config) 221void KAddressBookTableView::readConfig(KConfig *config)
206{ 222{
207 KAddressBookView::readConfig( config ); 223 KAddressBookView::readConfig( config );
208 // The config could have changed the fields, so we need to reconstruct 224 // The config could have changed the fields, so we need to reconstruct
209 // the listview. 225 // the listview.
210 reconstructListView(); 226 reconstructListView();
211 227
212 // costum colors? 228 // costum colors?
213 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 229 if ( config->readBoolEntry( "EnableCustomColors", false ) )
214 { 230 {
215 QPalette p( mListView->palette() ); 231 QPalette p( mListView->palette() );
216 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 232 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
217 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 233 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
218 c = p.color(QPalette::Normal, QColorGroup::Text ); 234 c = p.color(QPalette::Normal, QColorGroup::Text );
219 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 235 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
220 c = p.color(QPalette::Normal, QColorGroup::Button ); 236 c = p.color(QPalette::Normal, QColorGroup::Button );
221 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
222 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 238 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
223 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 239 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
224 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 240 c = p.color(QPalette::Normal, QColorGroup::Highlight );
225 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 241 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
226 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 242 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
227 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 243 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
228#ifndef KAB_EMBEDDED 244#ifndef KAB_EMBEDDED
229 c = KGlobalSettings::alternateBackgroundColor(); 245 c = KGlobalSettings::alternateBackgroundColor();
230#else //KAB_EMBEDDED 246#else //KAB_EMBEDDED
231 c = QColor(240, 240, 240); 247 c = QColor(240, 240, 240);
232#endif //KAB_EMBEDDED 248#endif //KAB_EMBEDDED
233 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 249 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
234 mListView->setAlternateColor(c); 250 mListView->setAlternateColor(c);
235 251
236 252
237 //US mListView->viewport()->setPalette( p ); 253 //US mListView->viewport()->setPalette( p );
238 mListView->setPalette( p ); 254 mListView->setPalette( p );
239 } 255 }
240 else 256 else
241 { 257 {
242 // needed if turned off during a session. 258 // needed if turned off during a session.
243 //US mListView->viewport()->setPalette( mListView->palette() ); 259 //US mListView->viewport()->setPalette( mListView->palette() );
244 mListView->setPalette( mListView->palette() ); 260 mListView->setPalette( mListView->palette() );
245 } 261 }
246 262
247 //custom fonts? 263 //custom fonts?
248 QFont f( font() ); 264 QFont f( font() );
249 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 265 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
250 { 266 {
251 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 267 mListView->setFont( config->readFontEntry( "TextFont", &f) );
252 f.setBold( true ); 268 f.setBold( true );
253 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 269 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
254 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 270 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
255 } 271 }
256 else 272 else
257 { 273 {
258 mListView->setFont( f ); 274 mListView->setFont( f );
259 f.setBold( true ); 275 f.setBold( true );
260 //US mListView->setHeaderFont( f ); 276 //US mListView->setHeaderFont( f );
261 mListView->header()->setFont( f ); 277 mListView->header()->setFont( f );
262 } 278 }
263 279
264 // Set the list view options 280 // Set the list view options
265 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 281 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
266 true)); 282 true));
267 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 283 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
268 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 284 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
269 285
270 if (config->readBoolEntry("Background", false)) 286 if (config->readBoolEntry("Background", false))
271 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 287 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
272 288
273 // Restore the layout of the listview 289 // Restore the layout of the listview
274 mListView->restoreLayout(config, config->group()); 290 mListView->restoreLayout(config, config->group());
275} 291}
276 292
277void KAddressBookTableView::refresh(QString uid) 293void KAddressBookTableView::refresh(QString uid)
278{ 294{
279 // For now just repopulate. In reality this method should 295 // For now just repopulate. In reality this method should
280 // check the value of uid, and if valid iterate through 296 // check the value of uid, and if valid iterate through